public void TakeDamage(float damage)
    {
        IDamageReceiver d = Behaviour as IDamageReceiver;

        if (d == null)
        {
            throw new Exception("Behaviour does not implement 'IDamageReceiver'.");
        }
        d.Damage(damage);
    }
Example #2
0
 /// <summary>
 /// Deal damage
 /// </summary>
 /// <param name="receiver">Damage receiver</param>
 public void DealDamage(IDamageReceiver damageReceiver)
 {
     if (damageReceiver == null)
     {
         Debug.LogError("Damage receiver is null");
         return;
     }
     damageReceiver.Damage(Damage);
     if (DamageDealedEvent != null)
     {
         DamageDealedEvent(Damage);
     }
 }