/// <summary> /// Update the AI in 'BuildUp' mode. Enemies should start to spawn in order to reach the 'peakThreshold' intensity. /// </summary> private void UpdateBuildUp() { // Debug.Log ("Currently in BUILD UP mode. Number of enemies spawned: " + enemiesSpawned + ". Enemies remaining: " + enemyMob.EnemyCount); // If all enemies have been spawned this epoch and all of them are dead, the user killed all the enemies before reaching the SustainPeak mode if (enemiesSpawned == epochSettings.maxEnemies && enemyMob.EnemyCount == 0) { // The current epoch is finished since all enemies are dead. Thus, skip directly to RELAX mode to get ready for the next epoch intensityMode = IntensityMode.Relax; Debug.LogWarning("All enemies killed. Skip to RELAX mode"); // Return from this function. This avoids spawning another enemy before entering RELAX mode. return; } // If there are less enemies spawned than the current epoch permits, keep spawning enemies until the max is reached. if (enemyMob.EnemyCount < epochSettings.maxEnemies) { // If at least '1/buildUpSpawnRate' seconds have passed since the last enemy was spawned, it is time to spawn another enemy. Note that // 'epochSettings.buildUpSpawnRate' enemies should be spawned every second. if ((Time.time - lastEnemySpawnTime) >= (1 / epochSettings.buildUpSpawnRate)) { // Spawn a new enemy in the level. The difficulty setting and 'maxEnemyWorth' is directly proportional to the current epoch number enemySpawner.SpawnEnemy(epoch, epoch, enemyMob); Debug.LogWarning("Spawn an enemy"); // Update the time at which the last enemy was spawned. lastEnemySpawnTime = Time.time; // Increment the number of enemies spawned this epoch. enemiesSpawned++; } } // If the game's intensity has reached the peak intensity threshold, sustain this peak before ramping down again if (gameIntensity >= epochSettings.peakIntensityThreshold) { // Sustain the peak intensity threshold for 'sustainPeakDuration' and then ramp down the intensity intensityMode = IntensityMode.SustainPeak; Debug.LogWarning("Enter SUSTAIN PEAK mode"); } }