/// <summary> /// Updates the state of the game. This method checks the GameScreen.IsActive /// property, so the game will stop updating when the pause menu is active, /// or if you tab away to a different application. /// </summary> public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) { base.Update(gameTime, otherScreenHasFocus, false); // Gradually fade in or out depending on whether we are covered by the pause screen. if (coveredByOtherScreen) { pauseAlpha = Math.Min(pauseAlpha + 1f / 32, 1); } else { pauseAlpha = Math.Max(pauseAlpha - 1f / 32, 0); } if (IsActive) // indicates whether this screen is front most, ie: active { //Duplicate and store game time to allow other functions to acccess the game time var. gameTimeManager.GameTime = gameTime; // Question related variables initialization float SecondsPassed = (float)gameTime.ElapsedGameTime.TotalSeconds; particleEffect.Update(SecondsPassed); // Update Interactive elements. textAnim_GameOver.updateTweener(gameTime); textAnim_GoodJob.updateTweener(gameTime); if (gameTimeManager.intervalPerQuestionUp(gameTime)) { generateGameSet(); gameTimeManager.restartQuestionTimeCounter(); } // Check whether Question is correct first before processing gameTimeManager if (questionIsCorrect && gameTimeManager.intervalBtwQuestionUp(gameTime)) { textAnim_GoodJob.Stop(); generateGameSet(); gameTimeManager.restartQuestionTimeCounter(); } // Each Game has only a fixed time if (gameTimeManager.intervalPerGameRoundUp(gameTime)) { textAnim_GameOver.Start(); if (gameTimeManager.pause(gameTime, 6)) // pause to display textAnim to allow user to read. { textAnim_GameOver.Stop(); // For now we would indicate that the game is up by simply going back to the main menu. LoadingScreen.Load(ScreenManager, false, null, new BackgroundScreen(), new MainMenuScreen()); // Explicitly Reset score, due to singleton property. GameScoringSystem.Instance.resetScore(); } } } }