private void Setup() { //Debug.Log("Setup() called"); _index++; if (_index >= waves.Count) { bool allDead = true; foreach (Wave w in waves) { allDead = allDead && w.AllDead; } if (allDead) { state = WavesState.Finished; } return; } else { Wave current = waves[_index]; current.initUnits(); current.started = true; if (_index + 1 == waves.Count) { current.last = true; } state = WavesState.Idle; } }
IEnumerator Start() { state = WavesState.Initialize; while (true) { switch (state) { case WavesState.Initialize: Initialize(); break; case WavesState.NotStarted: break; case WavesState.Setup: Setup(); break; case WavesState.Idle: Wait(); break; case WavesState.Finished: Finish(); break; default: break; } yield return(0); } }
private void Initialize() { //Debug.Log("Initialize() called"); _index = -1; _autoStartNextWave = true; //Begin(); state = WavesState.NotStarted; }
private void Wait() { if (!waves[_index].last) { GUIManager.instance.UpdateWaveCounter(_index + 1, WavesCount); } else { GUIManager.instance.UpdateWaveCounter(_index + 1, WavesCount, true); } if (waves[_index].Done) { state = WavesState.Setup; } }