first commit
This commit is contained in:
42
Assets/Scripts/ScaleTest/WeighingManager.cs
Normal file
42
Assets/Scripts/ScaleTest/WeighingManager.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class WeighingManager : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private DraggableObject[] _balls;
|
||||
[SerializeField] private float _normalMass = 1f;
|
||||
[SerializeField] private float _heavyMass = 1.5f;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
AssignMasses();
|
||||
}
|
||||
|
||||
public void AssignMasses()
|
||||
{
|
||||
foreach (var ball in _balls)
|
||||
{
|
||||
ball.mass = _normalMass;
|
||||
ball.isHeavy = false;
|
||||
ball.GetComponent<Rigidbody>().mass = _normalMass;
|
||||
}
|
||||
int heavyIndex = Random.Range(0, _balls.Length);
|
||||
_balls[heavyIndex].mass = _heavyMass;
|
||||
_balls[heavyIndex].isHeavy = true;
|
||||
_balls[heavyIndex].GetComponent<Rigidbody>().mass = _heavyMass;
|
||||
}
|
||||
|
||||
public void ResetAllBalls()
|
||||
{
|
||||
foreach (var ball in _balls)
|
||||
ball.ResetToStart();
|
||||
}
|
||||
|
||||
public void FullRestart()
|
||||
{
|
||||
foreach (var ball in _balls)
|
||||
ball.ResetToStart();
|
||||
AssignMasses();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user