예제 #1
0
        protected override void Update(GameTime gameTime)
        {
            //Set the new keyboardstate.
            InputHelper.SetKeyboardState();
            InputHelper.SetGamePadStatePlayer1();
            InputHelper.SetGamePadStatePlayer2();
            InputHelper.SetGamePadStatePlayer3();
            InputHelper.SetGamePadStatePlayer4();

            //Workout which GameState you are in and load the right module.
            if (GameStateManager.HasChanged)
            {
                switch (GameStateManager.CurrentGameState)
                {
                case GameState.MainMenu:
                    this.CurrentModule = new MainMenuModule(this);
                    this.CurrentModule.Initialize();
                    this.CurrentModule.LoadContent(spriteBatch);
                    break;

                case GameState.InGame:
                    //If the game is new load new game module.
                    if (_pausedGameModule == null)
                    {
                        this.CurrentModule = new GameModule(this);
                        this.CurrentModule.Initialize();
                        this.CurrentModule.LoadContent(spriteBatch);
                    }
                    else
                    {
                        //If the game was paused re-load the last game module.
                        this.CurrentModule = _pausedGameModule;
                        _pausedGameModule  = null;
                    }
                    break;

                case GameState.GameOver:
                    this.CurrentModule = new FinalScoreModule(this);
                    this.CurrentModule.Initialize();
                    this.CurrentModule.LoadContent(spriteBatch);
                    break;
                }
            }

            //Reset the haschanged flag.
            if (GameStateManager.HasChanged)
            {
                GameStateManager.HasChanged = false;
            }

            //Update the current module.
            this.CurrentModule.Update(gameTime, spriteBatch);

            //if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed | InputHelper.IsButtonDown(Keys.Escape))
            //  this.Exit();

            base.Update(gameTime);
        }
예제 #2
0
        protected override void Update(GameTime gameTime)
        {
            //Set the new keyboardstate.
            InputHelper.SetKeyboardState();
            InputHelper.SetGamePadStatePlayer1();
            InputHelper.SetGamePadStatePlayer2();
            InputHelper.SetGamePadStatePlayer3();
            InputHelper.SetGamePadStatePlayer4();

            //Workout which GameState you are in and load the right module.
            if (GameStateManager.HasChanged)
            {
                switch (GameStateManager.CurrentGameState)
                {
                    case GameState.MainMenu:
                        this.CurrentModule = new MainMenuModule(this);
                        this.CurrentModule.Initialize();
                        this.CurrentModule.LoadContent(spriteBatch);
                        break;
                    case GameState.InGame:
                        //If the game is new load new game module.
                        if (_pausedGameModule == null)
                        {
                            this.CurrentModule = new GameModule(this);
                            this.CurrentModule.Initialize();
                            this.CurrentModule.LoadContent(spriteBatch);
                        }
                        else
                        {
                            //If the game was paused re-load the last game module.
                            this.CurrentModule = _pausedGameModule;
                            _pausedGameModule = null;
                        }
                        break;
                    case GameState.GameOver:
                        this.CurrentModule = new FinalScoreModule(this);
                        this.CurrentModule.Initialize();
                        this.CurrentModule.LoadContent(spriteBatch);
                        break;
                }
            }

            //Reset the haschanged flag.
            if (GameStateManager.HasChanged)
            {
                GameStateManager.HasChanged = false;
            }

            //Update the current module.
            this.CurrentModule.Update(gameTime, spriteBatch);

            //if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed | InputHelper.IsButtonDown(Keys.Escape))
              //  this.Exit();

            base.Update(gameTime);
        }