Update() public method

public Update ( ) : void
return void
Example #1
0
        public override void Update(GameTime gameTime, bool otherWindowHasFocus, bool coveredByOtherScreen)
        {
            base.Update(gameTime, otherWindowHasFocus, coveredByOtherScreen);

            inGameTime = inGameTime.Add(gameTime.ElapsedGameTime);

            userInterfaceManager.Update(gameTime, inGameTime);

            agentManager.Update(gameTime, isArrowLeftDown, isArrowRightDown, isLeftMouseButtonDown, isSpacebarDown);

            opponent.Update(gameTime);

            UpdateBullets(gameTime);

            UpdateCollisions();
        }
Example #2
0
        /// <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)
        {
            if (running)
            {
                base.Update(gameTime);
                Debug.Write("UPS", 1d / gameTime.ElapsedGameTime.TotalSeconds);

                // Allows the game to exit
                if (Keyboard.GetState().IsKeyDown(Keys.Escape))
                {
                    this.Restart();
                    return;
                }
                bool opponentInTheSameQuarter = opponent.Position.Quarter == town.CurrentQuarter;
                if (!opponentInTheSameQuarter)
                {
                    opponent.Position.Quarter.Update(gameTime, true);
                }
                if (town.SecondaryDrawnQuarter != null && town.SecondaryDrawnQuarter != opponent.Position.Quarter && town.SecondaryDrawnQuarter != player.Position.Quarter && !gameTime.IsRunningSlowly)
                {
                    town.SecondaryDrawnQuarter.Update(gameTime, false);
                }
                opponent.Update(gameTime, !opponentInTheSameQuarter);
                player.Update(gameTime);

                ITownQuarterOwner owner = town.Quarters[0].Owner;

                if ((owner == player || owner == opponent) && town.Quarters.All(q => q.Owner == owner))
                {
                    System.Drawing.Bitmap townMap = town.CreateTownMapImage();
                    PrepareEnd();
                    bool playAgain;
                    using (GameOver gameOver = new GameOver(owner == player, townMap))
                    {
                        System.Windows.Forms.DialogResult result = gameOver.ShowDialog();
                        playAgain = result != System.Windows.Forms.DialogResult.Cancel;
                    }
                    townMap.Dispose();
                    if (playAgain)
                    {
                        ShowMainMenuDialog(false);
                        PrepareStart();
                    }
                    else
                    {
                        Exit();
                    }
                    return;
                }

                if (player.Health <= 0)
                {
                    TownQuarter newQuarter = FindAndRespawnQuartersFor(player, gameTime);
                    player.RespawnInto(newQuarter);
                    drawer.ShowMessage(gameTime, String.Format("You were killed! You are now in {0}.", newQuarter.Name));
                    town.CurrentQuarter = newQuarter;
                    drawer.ShowFullscreenEffect(gameTime, contentRepository.RespawnFullscreenEffect, Player.RespawnFullscreenEffectDuration);
                }
                if (opponent.Health <= 0)
                {
                    TownQuarter newQuarter = FindAndRespawnQuartersFor(opponent, gameTime);
                    opponent.RespawnInto(newQuarter);
                    opponent.ClearTasks();
                    drawer.ShowMessage(gameTime, String.Format("Congratulations, your opponent was killed. He respawned in {0}.", newQuarter.Name));
                }
            }
        }
Example #3
0
 public void UpdateArmy(World world)
 {
     Mine.Update(world);
     Opponent.Update(world);
 }