Пример #1
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)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back ==
                ButtonState.Pressed)
            {
                this.Exit();
            }

            switch (gameState)
            {
            case GameStates.TitleScreen:
                if ((GamePad.GetState(PlayerIndex.One).Buttons.A ==
                     ButtonState.Pressed) ||
                    (Keyboard.GetState().IsKeyDown(Keys.Space)))
                {
                    GameManager.StartNewGame();
                    gameState = GameStates.Playing;
                }
                break;

            case GameStates.Playing:
                Player.Update(gameTime);
                WeaponManager.Update(gameTime);
                EnemyManager.Update(gameTime);
                EffectsManager.Update(gameTime);
                GoalManager.Update(gameTime);
                if (GoalManager.ActiveTerminals == 0)
                {
                    gameState = GameStates.WaveComplete;
                }
                break;

            case GameStates.WaveComplete:
                waveCompleteTimer +=
                    (float)gameTime.ElapsedGameTime.TotalSeconds;
                if (waveCompleteTimer > waveCompleteDelay)
                {
                    GameManager.StartNewWave();
                    gameState         = GameStates.Playing;
                    waveCompleteTimer = 0.0f;
                }
                break;

            case GameStates.GameOver:
                gameOverTimer +=
                    (float)gameTime.ElapsedGameTime.TotalSeconds;
                if (gameOverTimer > gameOverDelay)
                {
                    gameState     = GameStates.TitleScreen;
                    gameOverTimer = 0.0f;
                }
                break;
            }

            base.Update(gameTime);
        }
Пример #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)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            // TODO: Add your update logic here
            Player.Update(gameTime);
            EffectsManager.Update(gameTime);


            base.Update(gameTime);
        }