Пример #1
0
        protected override void Update(GameTime gameTime)
        {
            if (GlobalVariables.EnableKeyboard)
            {
                controller.Update();
            }
            if (GlobalVariables.Reset)
            {
                GlobalVariables.Reset = false;
                ResetLevel();
            }
            else if (!GlobalVariables.Paused && !GlobalVariables.GameOver)
            {
                level.Update();

                view.Update();
                base.Update(gameTime);
            }
            if (GlobalVariables.FlagDescend)
            {
                GlobalVariables.EndGame();
            }
            if (GlobalVariables.EndOfGame)
            {
                MediaPlayer.Stop();
            }
        }
Пример #2
0
        protected override void Update(GameTime gameTime)
        {
            newKeyboardState = Keyboard.GetState();
            newGamepadState  = GamePad.GetState(PlayerIndex.One);
            MouseState       = Mouse.GetState();
            if ((newKeyboardState.IsKeyDown(Keys.P) && oldKeyboardState.IsKeyUp(Keys.P)) ||
                newGamepadState.IsButtonDown(Buttons.Start) && oldGamepadState.IsButtonUp(Buttons.Start))
            {
                if (GameStatus == GameState.Pause)
                {
                    MediaPlayer.Resume();
                    GameStatus = GameState.Playing;
                    pauseSoundEffect.Play();
                }
                else if (GameStatus == GameState.Playing)
                {
                    MediaPlayer.Pause();
                    GameStatus = GameState.Pause;
                    pauseSoundEffect.Play();
                }
            }

            if ((newKeyboardState.IsKeyDown(Keys.M) && oldKeyboardState.IsKeyUp(Keys.M)))
            {
                MouseControl   = !MouseControl;
                IsMouseVisible = !IsMouseVisible;
            }

            Cheat.Update(oldKeyboardState, newKeyboardState);

            oldKeyboardState = newKeyboardState;
            oldGamepadState  = newGamepadState;
            if (GameStatus == GameState.Playing)
            {
                this.GameTime = gameTime;
                if (!DisableControl)
                {
                    KeyboardController.Update();
                    GamepadController.Update();
                    MouseController.Update();
                    CameraPointer.UpdateX(Mario.LocationX);
                }
                MarioSprite.Update(gameTime);
                World.Update(gameTime);
                Collision_Detection_and_Responses.CollisionHandling.Update(World.Level, this);
                PlayerStat.Update(gameTime);
                base.Update(gameTime);
            }
        }