Ejemplo n.º 1
0
    public void DecreaseCurrentLife()
    {
        CurrentHealth -= 1;

        // If we hit 0. Die.
        if (CurrentHealth == 0)
        {
            OnHealthReachedZero?.Invoke();
        }
    }
Ejemplo n.º 2
0
    public void DecreaseCurrentLife(int amount)
    {
        CurrentHealth -= amount;
        CurrentHealth  = Mathf.Clamp(CurrentHealth, 0, MaxHealth);

        // If we hit 0. Die.
        if (CurrentHealth == 0)
        {
            OnHealthReachedZero?.Invoke();
        }
    }
Ejemplo n.º 3
0
    public void TakeDamage(int damage)
    {
        currentHealth -= damage;
        Debug.Log(transform.name + " takes " + damage + " damage.");

        // If we hit 0, Die.
        if (currentHealth <= 0)
        {
            currentHealth = 0;
            OnHealthReachedZero?.Invoke();
        }
    }