Time for action – updating the Game1 class
Add the following declarations to the Game1 class:
enum GameStates {TitleScreen, Playing, WaveComplete, GameOver}; GameStates gameState = GameStates.TitleScreen; float gameOverTimer = 0.0f; float gameOverDelay = 6.0f; float waveCompleteTimer = 0.0f; float waveCompleteDelay = 6.0f;
Remove the call to
GoalManager.GenerateComputers()
from theLoadContent()
method of the Game1 class.Add the
checkPlayerDeath()
method to the Game1 class:private void checkPlayerDeath() { foreach (Enemy enemy in EnemyManager.Enemies) { if (enemy.EnemyBase.IsCircleColliding( Player.BaseSprite.WorldCenter, Player.BaseSprite.CollisionRadius)) { gameState = GameStates.GameOver; } } }
Replace the existing
Update()
method of the Game1 class with the following:protected override void Update(GameTime gameTime) { // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ...