示例#1
0
    public void TakeDamage(int dam)
    {
        health -= dam;
        if (health > maxHealth)
        {
            health = maxHealth;
        }
        healthBar.value = health;
        if (health <= 0)
        {
            PlayerDied();
        }

        if (dam > 0)
        {
            screenFlash.StartCoroutine("Flash");
            screenShake.TriggerShake();
            sound.PlaySound("hurt");
        }

        healhText.text = "<b>Health </b>" + health + " / " + maxHealth;
    }
示例#2
0
 public static void Flash(float duration)
 {
     _instance.StartCoroutine(DoFlash(duration));
 }