void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Missile") { seekerShotScript = other.GetComponent <EnemySeekerShot>(); if (seekerShotScript.teamCount != myTurretScript.teamCount) { //Damage myTurretScript.DamageThis(seekerShotScript.seekerDamage); } } else if (other.tag == "ShieldMine") { mineScript = other.GetComponent <ShieldMine>(); if (mineScript.teamCount != myTurretScript.teamCount) { myTurretScript.DamageThis(mineScript.mineDamage); } } else if (other.tag == "SniperBullet") { bulletScript = other.GetComponent <LineSniperShot>(); if (bulletScript.teamCount != myTurretScript.teamCount) { //Damage myTurretScript.DamageThis(bulletScript.lineSniperShotDamage); } } else if (other.tag == "Shot") { shotScript = other.GetComponent <ProtoShotPrefab>(); if (shotScript.teamCount != myTurretScript.teamCount) { //Damage myTurretScript.DamageThis(shotScript.shotDamage); } } else if (other.tag == "PhaseBlast") { phaseBlastScript = other.GetComponent <PhaseBlast>(); if (phaseBlastScript.teamCount != myTurretScript.teamCount) { myTurretScript.DamageThis(phaseBlastScript.phaseBlastDamage); } } else if (other.tag == "Plasma") { plasmaScript = other.GetComponent <Plasma>(); if (plasmaScript.teamCount != myTurretScript.teamCount) { myTurretScript.DamageThis(plasmaScript.plasmaDamage); } } }
void BlowUp() { if (!exploded) { exploded = true; if (this != null) { Collider2D[] hitThings = Physics2D.OverlapCircleAll(transform.position, blastRadius); if (hitThings != null) { for (int i = 0; i < hitThings.Length; i++) { if (hitThings[i].tag == "Player1(Black)" || hitThings[i].tag == "Player2(White)" || hitThings[i].tag == "Player3" || hitThings[i].tag == "Player4") { enemyHealthScript = hitThings[i].GetComponent <PlayerHealth>(); if (enemyHealthScript.teamCount != teamCount) { enemyHealthScript.Damage(blastDamage, false); } } else if (hitThings[i].tag == "Enemy") { aiHealthScript = hitThings[i].GetComponent <EnemyHealth>(); aiHealthScript.DamageEnemy(blastDamage); } else if (hitThings[i].tag == "Asteroid") { asteroidScript = hitThings[i].GetComponent <Asteroid>(); asteroidScript.DamageAsteroid(blastDamage); } else if (hitThings[i].tag == "RocketAmmo") { rocketScript = hitThings[i].GetComponent <RemoteLauncherShot>(); if (rocketScript.teamCount != teamCount) { rocketScript.DestroyThis(); } } else if (hitThings[i].tag == "DamageBug") { damageBugScript = hitThings[i].transform.GetComponent <DamageBug>(); if (damageBugScript.teamCount != teamCount) { //damage the bug damageBugScript.DamageThis(blastDamage); } } else if (hitThings[i].tag == "AutoTurretHitBox") { autoTurretScript = hitThings[i].transform.GetComponentInParent <AutoTurret>(); if (autoTurretScript != null) { if (autoTurretScript.teamCount != teamCount) { //damage the Turret autoTurretScript.DamageThis(blastDamage); } } } else if (hitThings[i].tag == "TripMine") { tripMineScript = hitThings[i].transform.GetComponent <TripMine>(); if (tripMineScript.teamCount != teamCount) { //Blow up tripMine tripMineScript.BlowUp(); } } else if (hitThings[i].tag == "Junk") { junkScript = hitThings[i].GetComponent <JunkHealth>(); junkScript.DamageJunk(blastDamage); } } DestroyThis(); } else { //Debug.Log("hit nothin"); } DestroyThis(); } } }
void BlowUp() { if (this != null) { Collider2D[] hitThings = Physics2D.OverlapCircleAll(transform.position, range); if (hitThings != null) { for (int i = 0; i < hitThings.Length; i++) { if (hitThings[i].tag == "Player1(Black)" || hitThings[i].tag == "Player2(White)" || hitThings[i].tag == "Player3" || hitThings[i].tag == "Player4") { playerHealthScript = hitThings[i].GetComponent <PlayerHealth>(); if (playerHealthScript.teamCount != teamCount) { playerHealthScript.Damage(grenadeDamage, false); } } else if (hitThings[i].tag == "Asteroid") { asteroidScript = hitThings[i].GetComponent <Asteroid>(); asteroidScript.DamageAsteroid(grenadeDamage); } else if (hitThings[i].tag == "RocketAmmo") { rocketScript = hitThings[i].GetComponent <RemoteLauncherShot>(); if (rocketScript.teamCount != teamCount) { rocketScript.DestroyThis(); } } else if (hitThings[i].tag == "DamageBug") { damageBugScript = hitThings[i].transform.GetComponent <DamageBug>(); if (damageBugScript.teamCount != teamCount) { //damage the bug damageBugScript.DamageThis(grenadeDamage); } } else if (hitThings[i].tag == "AutoTurretHitBox") { autoTurretScript = hitThings[i].transform.GetComponentInParent <AutoTurret>(); if (autoTurretScript != null) { if (autoTurretScript.teamCount != teamCount) { //damage the Turret autoTurretScript.DamageThis(grenadeDamage); } } } else if (hitThings[i].tag == "TripMine") { tripMineScript = hitThings[i].transform.GetComponent <TripMine>(); if (tripMineScript.teamCount != teamCount) { //Blow up tripMine tripMineScript.BlowUp(); } } else if (hitThings[i].tag == "Junk") { junkScript = hitThings[i].GetComponent <JunkHealth>(); junkScript.DamageJunk(grenadeDamage); } } } Destroy(this.gameObject, 3f); } }