private void RemoveFromPool(Enemy enemy) { if (Enemies.Contains(enemy)) { Enemies.Remove(enemy); } if (Enemies.Count <= 0) { AllEnemiesDestroyed?.Invoke(); } }
//============================================================ // Event Handlers: //============================================================ private void Enemy_EnemyDestroyed() { // if we have more to spawn, spawn one after a delay if (enemiesToSpawnThisWave > 0) { SpawnEnemy(ENEMY_NEW_SPAWN_DELAY); } // otherwise, signal that all the enemies have been destroyed else { if (AllEnemiesDestroyed != null) { AllEnemiesDestroyed.Invoke(); } } }