using UnityEngine;
using UnityEngine.UI;

public class StaminaBarScript : MonoBehaviour
{
    [SerializeField] private Image StaminaBar;
    [SerializeField] private Image PreRecoveryStaminaBar;

    [SerializeField] private SwingingArmMotionScript SwingingArmMotionScript;
    private float MaxStamina;

    private void Start()
    {
        MaxStamina = SwingingArmMotionScript.MaxStamina;
    }

    // Update is called once per frame
    private void Update()
    {
        float Stamina = SwingingArmMotionScript.Stamina;

        float percent = Stamina / MaxStamina;

        StaminaBar.fillAmount = percent;
        PreRecoveryStaminaBar.fillAmount = percent;

        if (!SwingingArmMotionScript.IsPreRecovery)
        {
            StaminaBar.enabled = true;
            PreRecoveryStaminaBar.enabled = false;
        }
        else if (SwingingArmMotionScript)
        {
            StaminaBar.enabled = false;
            PreRecoveryStaminaBar.enabled = true;
        }
    }
}
