void Update() { if (toWait) { periodTimer += Time.deltaTime; timerText = "Wave In: " + ((int)(cooldownPeriod - periodTimer) + 1).ToString(); waveTimerUI.SetTimer(timerText); if (periodTimer >= cooldownPeriod) { StartWave(); } else { return; } } if (!isOnBonusWave) { if (GameState.WaveNumber % bonusWave == 0 && GameState.WaveNumber > 0) { isOnBonusWave = true; headingText = "Bonus Wave"; waveTimerUI.SetHeading(headingText); } } if (isWaveActive) { setTimer += Time.deltaTime; if (setTimer >= setPeriod) { setCount++; if (setCount <= setNumber) { spawnIndex = Random.Range(0, spawnPoints.Length); toSpawn = true; } setTimer = 0f; } spawnTimer += Time.deltaTime; if (spawnTimer >= spawnRate) { if (toSpawn) { Spawn(); } } if (enemyList.Count == 0 && setCount >= setNumber) { EndWave(); } } }
void Start() { spawnIndex = 0; enemyIndex = 0; headingText = "Cooldown"; timerText = "Wave In: " + ((int)(cooldownPeriod - periodTimer) + 1).ToString(); waveTimerUI = GameObject.Find("UIManager/WaveTimerUI").GetComponent <WaveTimerUI>(); waveTimerUI.SetHeading(headingText); waveTimerUI.SetTimer(timerText); enemyList = new List <GameObject>(); }