Ejemplo n.º 1
0
        private void HandleInput()
        {
            // get all of our input states
            keyboardState      = Keyboard.GetState();
            gamePadState       = GamePad.GetState(PlayerIndex.One);
            touchState         = TouchPanel.GetState();
            accelerometerState = Accelerometer.GetState();

            //// Exit the game when back is pressed.
            //if (gamePadState.Buttons.Back == ButtonState.Pressed)
            //    Exit();

            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)
                    {
                        LoadNextLevel();
                    }
                    else
                    {
                        ReloadCurrentLevel();
                    }
                }
            }

            wasContinuePressed = continuePressed;
        }