public void CheckGameEnd(GameObject destroyedEnemy) { for (int i = 0; i < enemies.Count; i++) { if (enemies[i].gameObject == destroyedEnemy) { GameObject newExplosion = Instantiate(explosion, destroyedEnemy.transform.position + new Vector3(0f, 0f, -3f), destroyedEnemy.transform.rotation); Destroy(newExplosion, 1f); enemies.RemoveAt(i); break; } } if (enemies.Count == 0) { _isGameEnded = true; menu.Finish(); } }