IsMenuRight() public method

Checks for a "menu down" input action. The controllingPlayer parameter specifies which player to read input for. If this is null, it will accept input from any player.
public IsMenuRight ( ) : bool
return bool
Beispiel #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 (input.IsMenuCancel())
            {
                OnCancel(null, null);
            }

            if (input.IsMenuUp())
            {
                selectedEntry--;
                if (selectedEntry < 0)
                {
                    selectedEntry = menuEntries.Count - 1;
                }
                while (!menuEntries[selectedEntry].Enabled)
                {
                    selectedEntry--;
                    if (selectedEntry < 0)
                    {
                        selectedEntry = menuEntries.Count - 1;
                    }
                }
            }
            if (input.IsMenuDown())
            {
                selectedEntry++;
                if (selectedEntry >= menuEntries.Count)
                {
                    selectedEntry = 0;
                }
                while (!menuEntries[selectedEntry].Enabled)
                {
                    selectedEntry++;
                    if (selectedEntry >= menuEntries.Count)
                    {
                        selectedEntry = 0;
                    }
                }
            }
            if (input.IsMenuLeft())
            {
                menuEntries[selectedEntry].Left();
            }
            if (input.IsMenuRight())
            {
                menuEntries[selectedEntry].Right();
            }

            if (input.IsMenuSelect())
            {
                OnSelectEntry(selectedEntry);
            }
            if (selectedEntry < 0)
            {
                selectedEntry = menuEntries.Count - 1;
            }
            if (selectedEntry >= menuEntries.Count)
            {
                selectedEntry = 0;
            }


            Point mouseLocation = ScreenManager.ScaledMousePos;

            for (int i = 0; i < menuEntries.Count; i++)
            {
                MenuEntry menuEntry = menuEntries[i];

                if (GetMenuEntryHitBounds(menuEntry).Contains(mouseLocation))
                {
                    selectedEntry = i;

                    // Mouse left click?
                    if (input.CurrentMouseState.LeftButton == ButtonState.Released && input.LastMouseState.LeftButton == ButtonState.Pressed)
                    {
                        menuEntry.Click(mouseLocation.X, mouseLocation.Y);
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Responds to user input, changing the selected entry and accepting
        /// or cancelling the menu.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            if (input.IsMenuCancel())
            {
                OnCancel(null, null);
            }

            if (input.IsMenuUp())
            {
                selectedEntry--;
                if (selectedEntry < 0) selectedEntry = menuEntries.Count - 1;
                while (!menuEntries[selectedEntry].Enabled)
                {
                    selectedEntry--;
                    if (selectedEntry < 0) selectedEntry = menuEntries.Count - 1;
                }
            }
            if (input.IsMenuDown())
            {
                selectedEntry++;
                if (selectedEntry >= menuEntries.Count) selectedEntry = 0;
                while (!menuEntries[selectedEntry].Enabled)
                {
                    selectedEntry++;
                    if (selectedEntry >= menuEntries.Count) selectedEntry = 0;
                }
            }
            if (input.IsMenuLeft()) menuEntries[selectedEntry].Left();
            if (input.IsMenuRight()) menuEntries[selectedEntry].Right();

            if (input.IsMenuSelect()) OnSelectEntry(selectedEntry);
            if (selectedEntry < 0) selectedEntry = menuEntries.Count - 1;
            if (selectedEntry >= menuEntries.Count) selectedEntry = 0;

            Point mouseLocation = ScreenManager.ScaledMousePos;

            for (int i = 0; i < menuEntries.Count; i++)
            {
                MenuEntry menuEntry = menuEntries[i];

                if (GetMenuEntryHitBounds(menuEntry).Contains(mouseLocation))
                {
                    selectedEntry = i;

                    // Mouse left click?
                    if (input.CurrentMouseState.LeftButton == ButtonState.Released && input.LastMouseState.LeftButton == ButtonState.Pressed)
                    {
                       menuEntry.Click(mouseLocation.X, mouseLocation.Y);
                    }
                }
            }
        }
Beispiel #3
0
        /// <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
            KeyboardState keyboardState = input.CurrentKeyboardStates;

            // Check to see if the game is paused (esc)
            if (input.IsPauseGame())
            {
                // Add the pause screen
                ScreenManager.AddScreen(new PauseMenuScreen());
            }
            // Check to see if a menu element was selected and ensure that the match is not over
            if (input.IsMenuSelect() && !matchOver)
            {
                // Swap the turn state
                playerTurn = !playerTurn;

                // Check if it is the player's turn
                if (playerTurn)
                {
                    // Let the player select a move
                    player.SelectMove(enemy, PlayerInfo.Moves[selectedMove], playerSpriteManager);
                }
                else
                {
                    // Select the move after the player has selected their move (Z pressed a second time)
                    enemy.SelectMove(player, enemySpriteManager);
                }

                // Check to see if the enemy is dead
                if (enemy.CurrentHP <= 0)
                {
                    // Increment the player wins and set the match to over
                    PlayerInfo.Wins += 1;
                    matchOver        = true;

                    // Play the downed animation
                    enemySpriteManager.CurrentAnimation = "Down";
                }
                // Check to see if the player is dead
                else if (player.CurrentHP <= 0)
                {
                    // Increment the palyer losses and set the match to over
                    PlayerInfo.Losses += 1;
                    matchOver          = true;

                    // Play the downed animation
                    playerSpriteManager.CurrentAnimation = "Down";
                    // Load enemy win anim
                }
            }
            // Check to see if the start button was pressed and ensure that the match is over
            if (input.IsStartButton() && matchOver)
            {
                // Load the training screen if there are still enemies to face
                if (PlayerInfo.Wins < 4)
                {
                    LoadingScreen.Load(ScreenManager, false, new TrainingScreen());
                }
                // Otherwise, wipe the save data and go back to the main menu
                else
                {
                    SaveAndLoadGame.WipeSave();
                    LoadingScreen.Load(ScreenManager, false, new MainMenuScreen());
                }
            }

            // Check if the player is navigating the menu to the left
            if (input.IsMenuLeft())
            {
                // Decrement the selected move
                selectedMove--;

                // Wrap the selected move back around to end if it passes behind the start
                if (selectedMove < 0)
                {
                    selectedMove = maxMoves - 1;
                }
            }
            // Check if the player is nagivating the menu to the right
            if (input.IsMenuRight())
            {
                // Increment the selected move
                selectedMove++;

                // Wrap the selected move back to the beginning if it goes beyond the end
                if (selectedMove >= maxMoves)
                {
                    selectedMove = 0;
                }
            }
        }
        /// <summary>
        /// Responds to user input, changing the selected entry and accepting
        /// or cancelling the menu.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            // Move to the previous menu entry?
            if (input.IsMenuUp(ControllingPlayer))
            {

                keyPos.Y--;
                if (keyPos.Y < 0)
                {
                    keyPos.Y = keys.Length - 1;
                }
            }

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

                keyPos.Y++;
                if (keyPos.Y > keys.Length-1)
                {
                    keyPos.Y = 0;
                }
            }

             PlayerIndex playerIndex;

             if (input.IsMenuRight(ControllingPlayer))
             {
                 keyPos.X++;
                 if (keyPos.X > keys[(int)keyPos.Y].Length - 1)
                 {
                     keyPos.X = 0;
                 }
             }

             if (input.IsMenuLeft(ControllingPlayer))
             {
                 keyPos.X--;
                 if (keyPos.X < 0)
                 {
                     keyPos.X = keys[(int)keyPos.Y].Length - 1;
                 }
             }

            // Move to the next menu entry?
               //          public bool IsNewButtonPress(Buttons button, PlayerIndex? controllingPlayer,
             //                                            out PlayerIndex playerIndex)
            if ( input.IsNewButtonPress(Buttons.Y,ControllingPlayer, out playerIndex) )
            {
                playerNameChars[selectedEntry] = ' ';
                selectedEntry = Math.Min(selectedEntry + 1, numNameChars - 1);

                playerNameMenuEntry.Text = (new string(playerNameChars, 0, playerNameChars.Length));
            }

            // 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.

            if (input.IsNewButtonPress(Buttons.A, ControllingPlayer, out playerIndex) )
            {
                OnSelectEntry(selectedEntry, playerIndex);
            }
            else if (input.IsNewButtonPress(Buttons.B, ControllingPlayer, out playerIndex) ||
                input.IsNewButtonPress(Buttons.X, ControllingPlayer, out playerIndex)
                )
            {
                OnCancel(playerIndex);
            }
            else if (input.IsNewButtonPress(Buttons.Start, ControllingPlayer, out playerIndex))
            {
                CompleteEntry();
            }
        }