private void GetCollider(TowerInstance t) { float rangeWithBonus = range * (float)t.GetTotalUpgrades(Upgrade.UpgradeType.Range); Vector3 center = t.GetPosition() + new Vector3(0, 8f, 0); Collider[] hitColliders = Physics.OverlapSphere(center, rangeWithBonus); double max = -9999; attackCollider = null; for (int i = 0; i < hitColliders.Length; i++) { if (hitColliders[i].tag == "enemy") { EnemyInstance ei = hitColliders[i].GetComponentInParent <EnemyScript>().enemy; if (ei != null) { double thisValue = Math.Pow(ei.GetAttackPriority(), 2); if (thisValue > max) { max = thisValue; attackCollider = hitColliders[i]; } } } } }