public void OnAttacked(AttackManager.Attack attack)
 {
     if (attack.GetTarget().Equals(gameObject))
     {
         if (this.status == null || !(this.status.type == "shielded"))
         {
             Debug.Log("No current status");
             if (overhead.TakeDamage(attack.GetDamage()))
             {
                 Debug.Log("Made damage call");
                 // alive
                 if (attack.GetAbility() != null)
                 {
                     Debug.Log("Ally ability called");
                     attack.GetAbility().DoAbilityEffect(attack.GetOwner(), gameObject);
                 }
             }
             else
             {
                 // dead
                 isDead = true;
                 animator.SetTrigger("IsDead");
                 SetSelected(false);
                 gameObject.GetComponentInChildren <Renderer>().material.shader = Shader.Find("Diffuse");
                 attackManager.Unsubscribe(this);
                 eventManager.Unsubscribe(this);
                 Destroy(this);
             }
         }
     }
 }
Esempio n. 2
0
 public void OnAttacked(AttackManager.Attack attack)
 {
     if (attack.GetTarget().Equals(gameObject))
     {
         if (healthBar.TakeDamage(attack.GetDamage()))
         {
             // alive
             if (attack.GetAbility() != null)
             {
                 attack.GetAbility().DoAbilityEffect(attack.GetOwner(), gameObject);
             }
         }
         else
         {
             // dead
             animator.enabled = true;
             animator.SetTrigger("IsDead");
             attackManager.Unsubscribe(this);
             Destroy(gameObject);
             Destroy(this);
         }
     }
 }