Esempio n. 1
0
    /// <summary>
    /// Add health by value
    /// </summary>
    /// <param name="health"></param>
    public void AddHealth(float health)
    {
        currentHealth += health;

        if (currentHealth > maxHealth)
        {
            currentHealth = maxHealth;
        }
        else if (currentHealth < 0)
        {
            // Dead
            currentHealth = 0;
            gameEventManager.Death();
        }

        healthBar.fillAmount = currentHealth / maxHealth;
        healthText.text      = "Health: " + currentHealth.ToString();
    }