예제 #1
0
        private async Task HandleInput(GameTime gameTime)
        {
            // get all of our input states
            keyboardState = await _keyboard.GetState();

            // touchState = TouchPanel.GetState();
            // gamePadState = virtualGamePad.GetState(touchState, GamePad.GetState(PlayerIndex.One));
            // accelerometerState = Accelerometer.GetState();

#if !NETFX_CORE
            // Exit the game when back is pressed.
            //if (gamePadState.Buttons.Back == ButtonState.Pressed)
            //    Exit();
#endif
            bool continuePressed =
                keyboardState.IsKeyDown(Keys.Space); // ||
                                                     //gamePadState.IsButtonDown(Buttons.A) ||
                                                     //touchState.AnyTouch();

            // Perform the appropriate action to advance the game and
            // to get the player back to playing.
            if (!wasContinuePressed && continuePressed)
            {
                if (!level.Player.IsAlive)
                {
                    level.StartNewLife();
                }
                else if (level.TimeRemaining == TimeSpan.Zero)
                {
                    if (level.ReachedExit)
                    {
                        await LoadNextLevel();
                    }
                    else
                    {
                        await ReloadCurrentLevel();
                    }
                }
            }

            wasContinuePressed = continuePressed;

            virtualGamePad.Update(gameTime);
        }