protected override void Update(GameTime gameTime) { if (Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } player.Update(gameTime); floor.Update(gameTime); ui.Update(gameTime); enemy.Update(gameTime); if (player.IsGrounded == false) { floor.CheckGrounded(player); } base.Update(gameTime); }
public override void Update(GameTime gameTime) { if (MonsterGame.Instance.IsPaused) { _pauseDialog.Update(gameTime); return; } if (InputManager.CurrentState.Start || InputManager.CurrentState.Back) { _pauseDialog.Show(); MonsterGame.Instance.IsPaused = !MonsterGame.Instance.IsPaused; } switch (_state) { case GameScreenState.GetReady: if (AudioManager.SoundEffectInstances[AudioManager.Cue.GetReadyMusic].State == SoundState.Stopped) { _getReady.Hide(); _state = GameScreenState.Play; AudioManager.SoundEffectInstances[AudioManager.Cue.GameplayMusic].IsLooped = true; AudioManager.SoundEffectInstances[AudioManager.Cue.GameplayMusic].Volume = 0.6f; AudioManager.SoundEffectInstances[AudioManager.Cue.GameplayMusic].Play(); } break; case GameScreenState.Play: MovePlayer(); MoveEnemy(); HandleCollisions(); break; case GameScreenState.PlayerEaten: if (AudioManager.SoundEffectInstances[AudioManager.Cue.PlayerEaten].State != SoundState.Playing) { _numLives--; ResetLevel(); } break; case GameScreenState.LevelComplete: if (AudioManager.SoundEffectInstances[AudioManager.Cue.LevelCompleted].State != SoundState.Playing) { MoveToNextLevel(); } break; case GameScreenState.GameOver: _gameOverTimer += gameTime.ElapsedGameTime.Milliseconds; if (_gameOverTimer >= GameOverTimeout) { MonsterGame.Instance.SetState(GameState.TitleScreen); } break; } _player.Update(gameTime); MazeTile mt = _maze.GetTile(_player.Row, _player.Column); if (mt != null) { switch (mt.DotType) { case MazeTile.DotTileType.None: break; case MazeTile.DotTileType.Dot: _player.EatDot(); _score += 100; break; case MazeTile.DotTileType.Icon: _player.EatIcon(); _score += 1000; break; default: throw new ArgumentOutOfRangeException(); } mt.DotType = MazeTile.DotTileType.None; if (_maze.IsComplete) { _state = GameScreenState.LevelComplete; AudioManager.SoundEffectInstances[AudioManager.Cue.GameplayMusic].Stop(); _player.Move(Direction.None); _enemy.Move(Direction.None); AudioManager.SoundEffectInstances[AudioManager.Cue.LevelCompleted].Play(); } } _enemy.Update(gameTime); _getReady.Update(gameTime); _gameOver.Update(gameTime); _livesDisplay.NumberOfLives = _numLives; _livesDisplay.Update(gameTime); _maze.Update(gameTime); _scoreDisplay.Update(gameTime, XboxLiveManager.Profile.Gamertag, _score); }