Ejemplo n.º 1
0
 void DetectDamage(Collider other)
 {
     if (Owner == null) {
         if (Attacker == null)
             return;
         //角色发射出的特效攻击盒
         SceneItemAgent target = other.gameObject.GetComponentInParent<SceneItemAgent>();
         if (target != null) {
             if (Attacker.ExistDamage(target))
                 return;
             Attacker.Attack(target);
             target.OnDamage(Attacker.mOwner, AttackDef);
         } else {
             MeteorUnit unit = other.gameObject.GetComponentInParent<MeteorUnit>();
             if (unit != null) {
                 if (Attacker.mOwner == unit)
                     return;
                 if (Attacker.mOwner.SameCamp(unit))
                     return;
                 if (Attacker.ExistDamage(unit))
                     return;
                 //Debug.LogError("name:" + name + " hit other:" + other.name);
                 Attacker.Attack(unit);
                 unit.OnAttack(Attacker.mOwner, AttackDef == null ? Attacker.mOwner.CurrentDamage : AttackDef);
             }
         }
         return;
     }
     //角色身体上的攻击盒/武器上的攻击盒
     SceneItemAgent agent = other.gameObject.GetComponentInParent<SceneItemAgent>();
     if (agent != null) {
         if (Owner.ExistDamage(agent))
             return;
         Owner.Attack(agent);
         agent.OnDamage(Owner, AttackDef);
     } else {
         MeteorUnit unit = other.gameObject.GetComponentInParent<MeteorUnit>();
         if (unit != null) {
             if (Owner == unit)
                 return;
             if (Owner.SameCamp(unit))
                 return;
             if (Owner.ExistDamage(unit))
                 return;
             //Debug.LogError("name:" + name + " hit other:" + other.name);
             Owner.Attack(unit);
             unit.OnAttack(Owner, AttackDef == null ? Owner.CurrentDamage : AttackDef);
         }
     }
 }