public void takeDamage(float dps) { if (alive) { script_hit.PlayHitSound(); actualHealth -= dps; temp = damageImage.color; temp.a = 1 - (actualHealth / maxHealth); damageImage.color = temp; recoverTimer = recoverDelay; } if (actualHealth <= 0 && Alive) { Alive = false; if (froze) { anim.speed = 1f; goAttachedToModel.GetComponent <Renderer>().material.SetColor("_Color", normalColor); } anim.SetTrigger("dead"); onTriggerDead.Invoke(); StartCoroutine(Respawn()); } }
public void takeDamage(float dps) { actualHealth -= dps; if (actualHealth <= 0 && alive) { alive = false; //anim.SetTrigger("dead"); onTriggerDead.Invoke(); Destroy(gameObject); } }
//****************************************************************** //Prise de dégats de l'enclos //****************************************************************** public void DamageEnclos(int degats) { health -= degats; if (health <= 0) { health = 0; //santé min //Debug.LogError("Enclos Mort"); onTriggerDead.Invoke(); onTriggerDead = null; //On reset le delegate } int diffSheep = (nbSheep + 1) - Mathf.RoundToInt(health / 10.0f); for (int i = 0; i < diffSheep; i++) { KillSheep(); } }