using UnityEngine;
using UnityEngine.Events;

public class Health : MonoBehaviour
{
    [SerializeField] float health = 100;
    
    public UnityAction<float> onChange;
    public UnityAction OnDeath;
    
    public bool IsDead { get { return health <= 0; } }

    public void TakeDamage(float damage)
    {
        if(GameManager.Instance.IsWinScore)
            return;
        
        health -= damage;
        onChange?.Invoke(health);
        if(health <= 0)
            OnDeath?.Invoke();
    }
}
