using UnityEngine;
using UnityEngine.UI;

namespace Nan.Scripts
{
    public class PlayerStatusUI : MonoBehaviour
    {
        [SerializeField] private Slider _attackSlider;
        [SerializeField] private Slider _defenceSlider;
        [SerializeField] private Slider _speedSlider;
        [SerializeField] private Slider _hpSlider;

        private PlayerStatus _status;

        public void Initialize(PlayerStatus status)
        {
            _status = status;
            _attackSlider.maxValue = PlayerStatus.MaxAttack;
            _defenceSlider.maxValue = PlayerStatus.MaxDefence;
            _speedSlider.maxValue = PlayerStatus.MaxSpeed;
            _hpSlider.maxValue = 1;
        }

        private void Update()
        {
            _attackSlider.value = _status.Attack;
            _defenceSlider.value = _status.Defense;
            _speedSlider.value = _status.Speed;
            _hpSlider.value = _status.Health;
        }
    }
}