2025-12-04 08:22:30 +01:00

24 lines
506 B
C#

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