public void Update(GameTime gameTime) { // Do state-specific update logic. CurrentState.OnStateUpdate(gameTime); // Update current menu. CurrentMenu?.Update(gameTime); #region Global input handling if (Control.MuteSound.IsJustPressed) { SoundController.ToggleMute(); SoundController.Play(Sound.Bip2); } if (Control.MuteMusic.IsJustPressed) { SoundController.ToggleMuteMusic(); SoundController.Play(Sound.Bip2); } if (Control.SkipTutorial.IsJustPressed) { skipTutorial = !skipTutorial; SoundController.Play(Sound.Bip2); } #endregion }
public void Update(GameTime gameTime) { CurrentMenu.Update(gameTime); ContentLoader.Shaders["menu"].Parameters["Time"].SetValue((float)gameTime.TotalGameTime.TotalSeconds); TotemAnimator.Update((float)gameTime.ElapsedGameTime.TotalMilliseconds); TotemAnimator.Position = TotemPositionResolver.Resolve(); TotemAnimator.Scale = new Vector2(TotemScaleResolver.Resolve()); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { FilteredInputListener.Update(gameTime); if (GameState != GameStates.Paused) { if (FilteredInputListener.WasKeyPressed(Keys.Escape)) { GameState = GameStates.Paused; FilteredInputListener.ResetKey(Keys.Escape); } if (GameState == GameStates.Normal) { var modeState = CurrentGameMode.Update(gameTime); PhysicsWorld.Step(1.0f / 120.0f, 1, 1); if (Player.LivesRemaining <= 0) { Exit(); } if (modeState != GameModeStatus.Continue) { LastRespawnTime = gameTime.TotalGameTime; GameState = GameStates.WaitingForRespawn; } } else if (GameState == GameStates.WaitingForRespawn) { var timeWaited = gameTime.TotalGameTime - LastRespawnTime; if (timeWaited >= RespawnWaitTime) { GameState = GameStates.Normal; Player.Reset(); CurrentGameMode.Spawn(); } } base.Update(gameTime); } else { if (FilteredInputListener.WasKeyPressed(Keys.Escape)) { GameState = GameStates.Normal; FilteredInputListener.ResetKey(Keys.Escape); } else { var menuResult = CurrentMenu.Update(gameTime); if (menuResult != null) { if (menuResult.Action == MenuAction.Navigate) { CurrentMenu = Container.Resolve <MenuFactory>().Get(menuResult.NextMenuName); } else if (menuResult.Action == MenuAction.NewGame) { Player.SetUpForNewGame(); CurrentGameMode.SetUpForNewGame(); } else if (menuResult.Action == MenuAction.QuitGame) { GameWorld.SetUpForNewGame(); Exit(); } } } } }