/// <summary> /// Perform the game's update logic. /// </summary> /// <param name="gameTime">Game time information.</param> /// <param name="otherScreenHasFocus">Whether or not another screen currently has the focus.</param> /// <param name="coveredByOtherScreen">Whether or not this screen is covered by another.</param> public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) { gameElapsed -= gameTime.ElapsedGameTime; if (vat.CurrentVatCapacity >= vat.MaxVatCapacity || gameElapsed <= TimeSpan.Zero) { isLevelEnd = true; } if (isLevelEnd) { return; } // Update the time remaining displayed by the vat vat.DrawTimeLeft(gameElapsed); // If active and running handle all game component if (!IsActive) { base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen); return; } HandleThumbStick(); HandleSmoke(); beeKeeper.SetDirection(VirtualThumbsticks.LeftThumbstick); HandleCollision(gameTime); HandleVatHoneyArrow(); beeKeeper.DrawOrder = 1; int beeKeeperY = (int)(beeKeeper.Position.Y + beeKeeper.Bounds.Height - 2); // We want to determine the draw order of the beekeeper, // if the beekeeper is under half the height of the beehive // it should be drawn over the beehive. foreach (Beehive beehive in beehives) { if (beeKeeperY > beehive.Bounds.Y) { if (beehive.Bounds.Y + beehive.Bounds.Height / 2 < beeKeeperY) { beeKeeper.DrawOrder = Math.Max(beeKeeper.DrawOrder, beehive.Bounds.Y + 1); } } } base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen); }
/// <summary> /// Perform the game's update logic. /// </summary> /// <param name="gameTime">Game time information.</param> /// <param name="otherScreenHasFocus">Whether or not another screen currently has the focus.</param> /// <param name="coveredByOtherScreen">Whether or not this screen is covered by another.</param> public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) { // When the game starts the first thing the user sees is the count down before the game actually begins if (isAtStartupCountDown) { startScreenTime -= gameTime.ElapsedGameTime; } // Check for and handle a game over if (CheckIfCurrentGameFinished()) { base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen); return; } if (!(IsActive && IsStarted && !Guide.IsVisible)) { if (Guide.IsVisible && IsActive) { PauseCurrentGame(); } base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen); return; } // Show all diagnostic counters debugSystem.FpsCounter.Visible = showDebugInfo; debugSystem.TimeRuler.Visible = showDebugInfo; debugSystem.TimeRuler.ShowLog = showDebugInfo; gameElapsed -= gameTime.ElapsedGameTime; #if WINDOWS_PHONE HandleThumbStick(); #endif HandleSmoke(); HandleCollision(gameTime); HandleVatHoneyArrow(); beeKeeper.DrawOrder = 1; int beeKeeperY = (int)(beeKeeper.Position.Y + beeKeeper.Bounds.Height - 2); // We want to determine the draw order of the beekeeper, // if the beekeeper is under half the height of the beehive // it should be drawn over the beehive. foreach (Beehive beehive in beehives) { if (beeKeeperY > beehive.Bounds.Y) { if (beehive.Bounds.Y + beehive.Bounds.Height / 2 < beeKeeperY) { beeKeeper.DrawOrder = Math.Max(beeKeeper.DrawOrder, beehive.Bounds.Y + 1); } } } if (gameElapsed.Minutes == 0 && gameElapsed.Seconds == 10) { AudioManager.PlaySound("10SecondCountDown"); } if (gameElapsed.Minutes == 0 && gameElapsed.Seconds == 30) { AudioManager.PlaySound("30SecondWarning"); } // Update the time remaining displayed on the vat vat.DrawTimeLeft(gameElapsed); base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen); }