Example #1
0
    public void UpdateHealth(int currentHealth)
    {
        if (currentHealth > maxHealth)
        {
            currentHealth = maxHealth;
        }
        if (updateHealthEvent == null)
        {
            updateHealthEvent = new UpdateHealthEvent();
        }
        updateHealthEvent.Invoke(currentHealth);

        if (currentHealth <= 0)
        {
            Kill();
        }
    }
Example #2
0
 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();
 }
Example #3
0
 public void AddLife(int value)
 {
     currentLife += value;
     currentLife  = Mathf.Clamp(currentLife, 0, maxLife);
     UpdateHealthEvent?.Invoke(currentLife);
 }