示例#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)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                Exit();
            }

            //Get current state and execute said states update method
            switch (GameElements.currentState)
            {
            case GameElements.State.Run:
                GameElements.currentState = GameElements.RunUpdate(Content, Window, gameTime);
                break;

            case GameElements.State.Highscore:
                GameElements.currentState = GameElements.HighScoreUpdate(gameTime);
                break;

            case GameElements.State.NewHighscore:
                GameElements.currentState = GameElements.NewHighScoreUpdate(gameTime, Content, Window);
                break;

            case GameElements.State.Quit:
                this.Exit();
                break;

            default:                     //By default, set state as menu (Game start).
                GameElements.currentState = GameElements.MenuUpdate(gameTime);
                break;
            }
            base.Update(gameTime);
        }
示例#2
0
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(Microsoft.Xna.Framework.PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                this.Exit();
            }

            switch (GameElements.currentState)
            {
            case GameElements.State.Run:
                GameElements.currentState = GameElements.RunUpdate(Content, Window, gameTime);
                break;

            case GameElements.State.Highscore:
                GameElements.currentState = GameElements.HighScoreUpdate();
                break;

            case GameElements.State.Quit:
                this.Exit();
                break;

            default: GameElements.currentState = GameElements.MenuUpdate();
                break;
            }



            base.Update(gameTime);
        }
示例#3
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
            switch (GameElements.currentState)
            {
            case GameElements.state.Run:
                GameElements.currentState = GameElements.RunUpdate(Content, Window, gameTime);
                break;

            case GameElements.state.EnterHighScore:
                GameElements.currentState = GameElements.EnterUpdate(gameTime, points);
                break;

            case GameElements.state.PrintHighScore:
                GameElements.currentState = GameElements.printUpdate();
                KeyboardState keyboardState = Keyboard.GetState();
                if (keyboardState.IsKeyDown(Keys.E))
                {
                    GameElements.currentState = GameElements.state.EnterHighScore;
                }
                break;

            case GameElements.state.Quit:
                this.Exit();
                break;

            default:
                GameElements.currentState = GameElements.MenuUpdate(gameTime);
                break;
            }
            base.Update(gameTime);
        }