private void OnTriggerEnter2D(Collider2D other) { IDamageReceiver receiver = other.GetComponent <IDamageReceiver>(); if (receiver != null) { if (receiver.OnDamage(hitTarget)) { Destroy(gameObject); } } }
public virtual void ProcessAttack(AttackData attackData) { IDamageReceiver damageReceiver = attackData.target as IDamageReceiver; if (damageReceiver != null) { damageReceiver.OnDamage(attackData); } else { if (attackData.target.HasMethod(attackData.method)) { attackData.target.Call(attackData.method, attackData); } } }
public virtual void ProcessAttack(AttackData attackData) { IDamageReceiver damageReceiver = attackData.target as IDamageReceiver; damageReceiver.OnDamage(attackData); }