/// <summary> /// Spawn every enemy in the formation that you are in and then switch to the next wave. Uses Invoke /// Command to call it self and when full then it sets the currentroundphase to the next wave. /// </summary> public void SpawnUntilFull() { // Get the ntxt Free position that is empty in the formation. Transform freePosition = NextFreePosition(); Transform spawnPoint = GalagaHelper.RespawnPoint(gameObject.name, spawnEntranceRight); if (freePosition) { currentSpawnPos = freePosition; // Alternate between Left and Right entrance. if (spawnEntranceRight) { spawnEntranceRight = false; } else { spawnEntranceRight = true; } // Spawn enemy in enemy1Prefab. SpawnEnemy(spawnPoint, freePosition); } if (NextFreePosition() && this.isFull == false) { Debug.Log(gameObject.name.Bold() + " Free position"); Invoke("SpawnUntilFull", spawnDelay); } else { isFormationUp = true; Debug.Log(gameObject.name + " is formUp"); //GalagaHelper.CurrentRoundPhase += 1; } }