public void UpdateHealth(int currentHealth) { if (currentHealth > maxHealth) { currentHealth = maxHealth; } if (updateHealthEvent == null) { updateHealthEvent = new UpdateHealthEvent(); } updateHealthEvent.Invoke(currentHealth); if (currentHealth <= 0) { Kill(); } }
public void SubtractLife(int value) { if (currentArmor == 0) { currentLife -= value; } else if (currentArmor < value) { _ = currentArmor - value * -1; currentArmor = 0; currentLife -= value; } if (currentArmor >= value) { currentArmor -= value; } UpdateHealthEvent?.Invoke(currentLife); UpdateArmorEvent?.Invoke(currentArmor); CheckLife(); }
public void AddLife(int value) { currentLife += value; currentLife = Mathf.Clamp(currentLife, 0, maxLife); UpdateHealthEvent?.Invoke(currentLife); }