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();
    }
}
