Files
CourierOld/Game/CourierOld/Assets/Code/Gameplay/Player/PlayerHP.cs
T

27 lines
666 B
C#

namespace Code.Gameplay.Player
{
public class PlayerHealthPoints
{
public delegate void OnDeathDelegate();
public event OnDeathDelegate OnDeath;
public delegate void OnDamageDelegate(int damage);
public event OnDamageDelegate OnDamage;
private int _healthPoints;
public int HealthPoints => _healthPoints;
public void GetDamage(int count)
{
_healthPoints -= count;
OnDamage?.Invoke(count);
if (_healthPoints <= 0) OnDeath?.Invoke();
}
public PlayerHealthPoints(int healthPoints = 1) => _healthPoints = healthPoints;
}
}