Ejemplo n.º 1
0
        /// <summary>
        /// Responds to user input, changing the selected entry and accepting
        /// or cancelling the menu.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            if (startPressed || front == false)            //dont lock controls unless its the main menu (front)
            {
                // Move to the previous menu entry?
                if (input.IsMenuUp(ControllingPlayer))
                {
                    GameStateManagementGame.menuup.Play();

                    selectedEntry--;

                    if (selectedEntry < 0)
                        selectedEntry = menuEntries.Count - 1;
                }

                // Move to the next menu entry?
                if (input.IsMenuDown(ControllingPlayer))
                {
                    GameStateManagementGame.menudown.Play();

                    selectedEntry++;

                    if (selectedEntry >= menuEntries.Count)
                        selectedEntry = 0;
                }

                // Accept or cancel the menu? We pass in our ControllingPlayer, which may
                // either be null (to accept input from any player) or a specific index.
                // If we pass a null controlling player, the InputState helper returns to
                // us which player actually provided the input. We pass that through to
                // OnSelectEntry and OnCancel, so they can tell which player triggered them.
                PlayerIndex playerIndex;

                if (input.IsMenuSelect(ControllingPlayer, out playerIndex))
                {
                    OnSelectEntry(selectedEntry, playerIndex);
                }
                else if (input.IsMenuCancel(ControllingPlayer, out playerIndex))
                {
                    OnCancel(playerIndex);
                }
            }
            else if(front)
            {
                if ((input.CurrentGamePadStates[0].Buttons.Start == ButtonState.Pressed && input.LastGamePadStates[0].Buttons.Start == ButtonState.Released) || (input.CurrentGamePadStates[0].Buttons.A == ButtonState.Pressed && input.LastGamePadStates[0].Buttons.A == ButtonState.Released) || (input.CurrentKeyboardStates[0].IsKeyDown(Keys.Enter) && input.LastKeyboardStates[0].IsKeyUp(Keys.Enter)))
                {
                    GameStateManagementGame.menustart.Play();

                    startPressed = true;
                }
            }
        }
        /// <summary>
        /// Responds to user input, accepting or cancelling the message box.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            PlayerIndex playerIndex;

            // We pass in our ControllingPlayer, which may either be null (to
            // accept input from any player) or a specific index. If we pass a null
            // controlling player, the InputState helper returns to us which player
            // actually provided the input. We pass that through to our Accepted and
            // Cancelled events, so they can tell which player triggered them.
            if (input.IsMenuSelect(ControllingPlayer, out playerIndex))
            {
                // Raise the accepted event, then exit the message box.
                if (Accepted != null)
                    Accepted(this, new PlayerIndexEventArgs(playerIndex));

                ExitScreen();
            }
            else if (input.IsMenuCancel(ControllingPlayer, out playerIndex))
            {
                // Raise the cancelled event, then exit the message box.
                if (Cancelled != null)
                    Cancelled(this, new PlayerIndexEventArgs(playerIndex));

                GameStateManagementGame.menuback.Play();

                ExitScreen();
            }
        }
        /// <summary>
        /// Lets the game respond to player input. Unlike the Update method,
        /// this will only be called when the gameplay screen is active.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            if (input == null)
                throw new ArgumentNullException("input");

            // Look up inputs for the active player profile.
            int playerIndex = (int)ControllingPlayer.Value;

            KeyboardState keyboardState = input.CurrentKeyboardStates[playerIndex];
            GamePadState gamePadState = input.CurrentGamePadStates[playerIndex];

            // The game pauses either if the user presses the pause button, or if they unplug the active gamepad.
            bool gamePadDisconnected = !gamePadState.IsConnected && input.GamePadWasConnected[playerIndex];

            if (input.IsPauseGame(ControllingPlayer) || gamePadDisconnected)
            {
                ScreenManager.AddScreen(new PauseMenuScreen(true), ControllingPlayer);
            }
        }
        /// <summary>
        /// Responds to user input, accepting or cancelling the message box.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            PlayerIndex playerIndex;

            // We pass in our ControllingPlayer, which may either be null (to
            // accept input from any player) or a specific index. If we pass a null
            // controlling player, the InputState helper returns to us which player
            // actually provided the input. We pass that through to our Accepted and
            // Cancelled events, so they can tell which player triggered them.
            if ((input.IsMenuCancel(ControllingPlayer, out playerIndex) || input.IsMenuSelect(ControllingPlayer, out playerIndex)) && preSkipDelay <= 0)
            {
                // Raise the cancelled event, then exit the message box.
                if (Cancelled != null)
                    Cancelled(this, new PlayerIndexEventArgs(playerIndex));

                GameStateManagementGame.menuselect.Play();

                MainMenuScreen.gamePlayScreen.killAllEnemyThreads();

                ExitScreen();

                if (!lastLevel)
                {
                    GameStateManagementGame.level1Time = gameClock;

                    MainMenuScreen.gamePlayScreen2 = new GameplayScreen2();

                    LoadingScreen.Load(ScreenManager, true, 0, MainMenuScreen.gamePlayScreen2);
                }
                else
                {
                    GameStateManagementGame.level2Time = gameClock;

                    GameStateManagementGame.gameSongsCue.Stop(AudioStopOptions.AsAuthored);

                    GameStateManagementGame.music = 0;

                    LoadingScreen.Load(ScreenManager, false, null, new GameCompleteScreen());
                }
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Allows the screen to handle user input. Unlike Update, this method
 /// is only called when the screen is active, and not when some other
 /// screen has taken the focus.
 /// </summary>
 public virtual void HandleInput(InputState input)
 {
 }
        /// <summary>
        /// Responds to user input, accepting or cancelling the message box.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            PlayerIndex playerIndex;

            // We pass in our ControllingPlayer, which may either be null (to
            // accept input from any player) or a specific index. If we pass a null
            // controlling player, the InputState helper returns to us which player
            // actually provided the input. We pass that through to our Accepted and
            // Cancelled events, so they can tell which player triggered them.
            if ((input.IsMenuCancel(ControllingPlayer, out playerIndex) || input.IsMenuSelect(ControllingPlayer, out playerIndex)) && preSwoopDelay <= 0)
            {
                if (skipStage == 0)
                {
                    gradeSlideTransition = 0.0f;
                    gradeBoxPos = finalGradeBoxPos;
                    gradeScale = 1f;
                    commentAlpha = 1f;
                    totalTime += GameStateManagementGame.level1Time + GameStateManagementGame.level2Time;
                    GameStateManagementGame.level1Time = 0;
                    GameStateManagementGame.level2Time = 0;

                    GameStateManagementGame.menuselect.Play();

                    skipStage = 1;
                }
                else if (skipStage == 1)
                {
                    GameStateManagementGame.menuselect.Play();

                    skipStage = 2;
                }
                else if (skipStage == 2)
                {
                    gradeSlideTransition = 1.0f;
                    gradeBoxPos = new Vector2(-550f, 165f);

                    creditsSlideTransition = 0.0f;
                    creditsBoxPos = finalCreditsBoxPos;

                    GameStateManagementGame.menuselect.Play();

                    skipStage = 3;
                }
                else if (skipStage == 3)
                {
                    GameStateManagementGame.gameSongsCue.Stop(AudioStopOptions.AsAuthored);

                    GameStateManagementGame.menuselect.Play();

                    skipStage = 4;
                }
            }
        }