public void SpawnWave() { if (spawnIndex >= waveDatabase.waves.Count) { GameOver(); return; } ; //Create Wave activeEnemyWave = Instantiate(new GameObject("EnemyWave")).AddComponent <EnemyWave>(); activeEnemyWave.transform.position = Vector3.zero; activeEnemyWave.transform.parent = this.transform; activeEnemyWave.Initialise( //OnWaveFinishedCallback () => { spawnIndex++; waveIsActive = false; SpawnButton.interactable = true; activeEnemyWave.ForceRemove(); }, //OnEnemyDieCallback (enemy) => { CurrentMoney += enemy.wealth; CurrentScore += enemy.score; }, //OnEnemyReachGoalCallback (enemy) => { CurrentLife -= 1; }, //enemy prefab ref waveDatabase.enemyPrefabs ); waveIsActive = true; SpawnButton.interactable = false; activeEnemyWave.SpawnWave(waveDatabase.waves[spawnIndex]); }