protected virtual void Explode() { if (!isAlive) return; rigid.velocity = Vector2.zero; isAlive = false; if (Owner == null) { Despawn(); return; } if (ExplosionRange > 0) { attackables.Clear(); Collider2D[] targets = Physics2D.OverlapCircleAll(rigid.position, ExplosionRange); for (int i = 0; i < targets.Length; i++) { attackable = targets[i].GetComponent<Attackable>(); attackableCollider = targets[i].GetComponent<AttackableCollider>(); if (attackable == null && attackableCollider != null) attackable = attackableCollider.Target; if (attackable == null) continue; if (attackable.Owner == Owner.Owner) continue; attackables.Add(attackable); } for (int i = 0; i < attackables.Count; i++) { ExplodeTarget(attackables[i]); } } else { ExplodeTarget(Target); } if (Animator != null) Animator.SetTrigger("Explode"); else Despawn(); }
protected virtual void UpdateThingsNearMe() { if (CheckNearFieldTimer.UpdateAutoReset()) { ColliderNear = Physics2D.OverlapCircleAll(transform.position, SightRange, SightMask); EnemiesNear.Clear(); for (int i = 0; i < ColliderNear.Length; i++) { otherCollider = ColliderNear[i].GetComponent<AttackableCollider>(); if (otherCollider == null) { ColliderNear[i] = null; continue; } other = otherCollider.Target; if (other == this) { ColliderNear[i] = null; continue; } //If Collider has MinionScript, compare Owners to find out if its an enemy if (ShouldAttack(other) && Owner != null) Owner.IHaveSeenAttackable(other); if (CanAttack(other)) EnemiesNear.Add(other); } } }