/// <summary> /// Updates the loading screen. /// </summary> public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) { base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen); // If all the previous screens have finished transitioning // off, it is time to actually perform the load. if (otherScreensAreGone) { TankWars.RemoveScreen(this); foreach (GameScreen screen in screensToLoad) { if (screen != null) { TankWars.AddScreen(screen); } } // Once the load has finished, we use ResetElapsedTime to tell // the game timing mechanism that we have just finished a very // long frame, and that it should not try to catch up. TankWars.ResetElapsedTime(); } }
void QuitGameMenuEntrySelected(object sender, EventArgs e) { const string message = "Are you sure you want to quit current game?"; MessageBoxScreen confirmQuitMessageBox = new MessageBoxScreen(message); confirmQuitMessageBox.Accepted += ConfirmQuitMessageBoxAccepted; TankWars.AddScreen(confirmQuitMessageBox); }
protected override void OnCancel() { const string message = "Are you sure you want to exit Tank Wars?"; MessageBoxScreen confirmExitMessageBox = new MessageBoxScreen(message); confirmExitMessageBox.Accepted += ConfirmExitMessageBoxAccepted; TankWars.AddScreen(confirmExitMessageBox); }
// Xử lý trường hợp người chơi nhấn Esc public override void HandleInput(InputState input) { if (input == null) { throw new ArgumentNullException("input"); } if (!Player.IsDead) { Player.HandleInput(input); Cursor.HandleInput(input); } if (input.IsPauseGame) { Content.Audio.BackgroundBattlefieldLoop.Pause(); TankWars.AddScreen(new PauseMenuScreen()); } }
/// <summary> /// Allows the game component to update itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> 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) { Content.Audio.BackgroundBattlefieldLoop.Play(); Camera.Update(gameTime); Cursor.Update(gameTime); Minimap.Update(gameTime); // Update Sprite người chơi và các thao tác điều khiển if (!Player.IsDead) { Player.Update(gameTime); Direction.Update(gameTime); } // Update các viên đạn đã đc bắn ra for (CurrentListItem = 0; CurrentListItem < AmmunitionList.Count; CurrentListItem++) { Ammunition ammunition = AmmunitionList[CurrentListItem]; ammunition.Update(gameTime); } // Update các vụ nổ for (CurrentListItem = 0; CurrentListItem < EffectList.Count; CurrentListItem++) { Sprite effect = EffectList[CurrentListItem]; effect.Update(gameTime); } // Update Enemy RandomMovableEnemy(); for (CurrentListItem = 0; CurrentListItem < EnemyList.Count; CurrentListItem++) { Tank enemy = EnemyList[CurrentListItem]; enemy.Update(gameTime); } foreach (PowerIcon power in PowerIconList) { power.Update(gameTime); } if (Player.IsDead) { MissionEndDelay += gameTime.ElapsedGameTime; if (MissionEndDelay >= TimeSpan.FromSeconds(2)) { Content.Audio.MissionFailed.Play(); Content.Audio.BackgroundBattlefieldLoop.Pause(); TankWars.AddScreen(new MissionFailedMenuScreen()); } } if (IsMissionAccomplished) { MissionEndDelay += gameTime.ElapsedGameTime; if (MissionEndDelay >= TimeSpan.FromSeconds(2)) { Content.Audio.MissionAccomplished.Play(); Content.Audio.BackgroundBattlefieldLoop.Pause(); if (IsCampaignAccomplished) { TankWars.AddScreen(new CampaignAccomplishedMenuScreen()); } else { TankWars.AddScreen(new MissionAccomplishedMenuScreen()); } } } } }
void AboutMenuEntrySelected(object sender, EventArgs e) { TankWars.AddScreen(new AboutMenuScreen()); }
void OptionsMenuEntrySelected(object sender, EventArgs e) { TankWars.AddScreen(new OptionsMenuScreen()); }
void SinglePlayerMenuEntrySelected(object sender, EventArgs e) { TankWars.AddScreen(new SinglePlayerMenuScreen()); }