protected override void Update(GameTime gameTime) { if (Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds; switch (gameState) { case GameState.menu: menuState.Update(); if (menuState.newGame.IsClicked) { gameState = GameState.play; playState = new PlayState(); IsMouseVisible = false; } if (menuState.exit.IsClicked) { Exit(); } break; case GameState.play: playState.Update(elapsed); if (playState.HasWon) { gameState = GameState.win; winState = new WinState(); IsMouseVisible = true; } if (playState.HasLost) { gameState = GameState.lose; loseState = new LoseState(); IsMouseVisible = true; } break; case GameState.win: winState.Update(); if (winState.mainMenu.IsClicked) { gameState = GameState.menu; menuState = new MenuState(); IsMouseVisible = true; } if (winState.restart.IsClicked) { gameState = GameState.play; playState = new PlayState(); IsMouseVisible = false; } break; case GameState.lose: loseState.Update(); if (loseState.mainMenu.IsClicked) { gameState = GameState.menu; menuState = new MenuState(); IsMouseVisible = true; } if (loseState.restart.IsClicked) { gameState = GameState.play; playState = new PlayState(); IsMouseVisible = false; } break; } base.Update(gameTime); }
public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; winState = WinState.PLAYING; }