/// <summary>
 /// Damage the character the specified amount.
 /// </summary>
 /// <param name="amount">Amount of damage to cause.</param>
 virtual public void Damage(int amount)
 {
     if (invulnerableTimer <= 0.0f)
     {
         float originalHealthPercentage = HealthAsPercentage;
         health -= Mathf.Abs(amount);
         if (health <= 0)
         {
             health = 0;
         }
         if (healthBar != null)
         {
             healthBar.AnimateHealthChange(originalHealthPercentage, HealthAsPercentage);
         }
         if (health <= 0)
         {
             StartCoroutine(DoZeroHealthAction());
         }
         else
         {
             controller.Stun(stunTime);
         }
         invulnerableTimer = invulnerableTime;
     }
 }
Exemple #2
0
    private void Land()
    {
        isFalling = false;
        if (fallSpeed <= minSpeedForAction)
        {
            switch (fallDamageAction)
            {
            case FallDamageAction.STUN: controller.Stun(stunTime); break;

            case FallDamageAction.SEND_MESSAGE_DIE: controller.SendMessage("Die", null, SendMessageOptions.DontRequireReceiver);  break;

            case FallDamageAction.SEND_MESSAGE_HIT: controller.SendMessage("Hit", fallSpeed, SendMessageOptions.DontRequireReceiver); break;

            case FallDamageAction.SIMPLE_HEALTH_DAMAGE: controller.GetComponent <SimpleHealth>().FallDamage(fallSpeed); break;
            }
        }
        fallSpeed = 0.0f;
    }