void CheckForCollisionsOnHurtboxes() { for (int i = 0; i < activeHurtboxes.Length; i++) { RaycastHit2D[] hits = Physics2D.BoxCastAll((Vector2)activeHurtboxes[i].transform.position + activeHurtboxes[i].offset, activeHurtboxes[i].bounds.size, 0f, Vector2.zero, 1f, hitboxMask); for (int j = 0; j < hits.Length; j++) { BattleAgent atk = null, def = null; for (int k = 0; k < agentList.Length; k++) { if (agentList[k].hurtboxes.Contains(activeHurtboxes[i])) { atk = agentList[k]; } if (agentList[k].hitboxes.Contains(hits[j].collider)) { def = agentList[k]; } } if ((atk == def) || atk == null || def == null) { continue; } LandedAttack LA = new LandedAttack(atk, def); LA.hit = hits[j]; if (!openAttacksList.Contains(LA) && !resolvedAttacksList.Contains(LA)) { openAttacksList.Add(LA); Debug.Log(atk.name + " hit " + def.name + " at " + LA.hit.point); } } } }
public override bool Equals(object obj) { LandedAttack LAObj = (LandedAttack)obj; return((attacker.Equals(LAObj.attacker)) && (defender.Equals(LAObj.defender))); }