// Destroy this gameObject private void killThisObj() { EnemyHP[] EHPs = gameObject.GetComponentsInChildren <EnemyHP> (); foreach (EnemyHP EHP in EHPs) { EHP.die(); } Destroy(gameObject); }
// Checks for any attached EnemyHP components (if this is a missile) and kills them if they exist private void destroyAttachedEnemyHP() { if (_type != bulletType.missile) { return; } EnemyHP[] EHPs = transform.root.gameObject.GetComponentsInChildren <EnemyHP>(); foreach (EnemyHP EHP in EHPs) { EHP.die(); } }
void Update() { _location = Camera.main.WorldToViewportPoint(transform.position); if (not_percent(_location.x) || not_percent(_location.y)) { EnemyHP[] EHPs = transform.root.gameObject.GetComponentsInChildren <EnemyHP>(); foreach (EnemyHP EHP in EHPs) { EHP.die(); } Destroy(transform.root.gameObject); //Scary Bugs! } }
void Update() { _location = Camera.main.WorldToViewportPoint(transform.position); if (not_percent(_location.x) || not_percent(_location.y)) { GetComponent <BoxCollider2D>().enabled = false; float destroy_delay = 3.0f; if (GetComponent <seeking_missile>()) { destroy_delay = 0.15f; } EnemyHP[] EHPs = transform.root.gameObject.GetComponentsInChildren <EnemyHP>(); foreach (EnemyHP EHP in EHPs) { EHP.die(); } Destroy(transform.root.gameObject, destroy_delay); //Scary Bugs! } }
// Stop all SpawnManager coroutines, and then destroy all enemies public void resetEnemies() { SpawnManager.Instance.reset(); seeking_missile.destroyAllMissiles(); while (enemies.Count != 0) { EnemyHP EHP; if (enemies [0] != null && (EHP = enemies [0].GetComponent <EnemyHP> ())) { enemies.RemoveAt(0); EHP.die(); } else { enemies.RemoveAt(0); } } enemies.Clear(); }