IsMenuSelect() 공개 메소드

Checks for a "menu select" input action. The controllingPlayer parameter specifies which player to read input for. If this is null, it will accept input from any player. When the action is detected, the output playerIndex reports which player pressed it.
public IsMenuSelect ( ) : bool
리턴 bool
        /// <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));
                }

                ExitScreen();
            }
        }
예제 #2
0
        /// <summary>
        /// Responds to user input, changing the selected entry and accepting
        /// or cancelling the menu.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            var touch = input.TouchState;

            var rect = new Rectangle(0, 0, 100, 30);

            if (touch.Count == 1)
            {
                for (int i = 0; i < menuEntries.Count; i++)
                {
                    rect.X        = (int)menuEntries[i].Position.X;
                    rect.Y        = (int)menuEntries[i].Position.Y;
                    selectedEntry = i;
                    if (rect.Contains((int)touch[0].Position.X, (int)touch[0].Position.Y))
                    {
                        OnSelectEntry(selectedEntry, 0);
                        break;
                    }
                }
            }

            // Move to the previous menu entry?
            if (input.IsMenuUp(ControllingPlayer))
            {
                selectedEntry--;

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

            // Move to the next menu entry?
            if (input.IsMenuDown(ControllingPlayer))
            {
                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);
            }
        }
예제 #3
0
 public override void HandleInput(InputState input)
 {
     PlayerIndex player;
     if (input.IsMenuSelect(null, out player))
     {
         exit = true;
         ControllingPlayer = player;
     }
     base.HandleInput(input);
 }
예제 #4
0
        /// <summary>
        /// Responds to user input, accepting or cancelling the message box.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            PlayerIndex playerIndex;
            Viewport    viewport = ScreenManager.Game.GraphicsDevice.Viewport;
            Vector2     halfSize = new Vector2(viewport.Width, viewport.Height) / 2;

            // 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())
            {
                // Raise the accepted event, then exit the message box.
                if (Accepted != null)
                {
                    Accepted(this, new EventArgs());
                }

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

                ExitScreen();
            }

            Point mouseLoc = new Point(input.CurrentMouseState.X, input.CurrentMouseState.Y);

            Rectangle okRect = new Rectangle((int)halfSize.X - 25, (int)halfSize.Y + 25, 50, 50);

            if (input.CurrentMouseState.LeftButton == ButtonState.Pressed && input.LastMouseState.LeftButton == ButtonState.Released)
            {
                if (okRect.Contains(mouseLoc))
                {
                    ExitScreen();
                }
            }
        }
예제 #5
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())
            {
                // Decrement the currently selected entry
                selectedEntry--;

                // If the entry is less than 0, wrap it back around to the last entry
                if (selectedEntry < 0)
                {
                    selectedEntry = menuEntries.Count - 1;
                }
            }

            // Move to the next menu entry
            if (input.IsMenuDown())
            {
                // Increment the currently selected entry
                selectedEntry++;

                // If the entry is the last entry, wrap it back around to first entry
                if (selectedEntry >= menuEntries.Count)
                {
                    selectedEntry = 0;
                }
            }

            // Check to see if a menu was selected
            if (input.IsMenuSelect())
            {
                // Trigger the event for the selected entry
                OnSelectEntry(selectedEntry);
            }

            // Otherwhise, check if the user cancelled the menu
            else if (input.IsMenuCancel())
            {
                // Call the cancel method to take the user out
                OnCancel();
            }
        }
예제 #6
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))
            {
                selectedEntry--;
                menuSFX.Play();

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

            // Move to the next menu entry?
            if (input.IsMenuDown(ControllingPlayer))
            {
                selectedEntry++;
                menuSFX.Play();

                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);
            }
        }
예제 #7
0
        /// <summary>
        /// Responds to user input, changing the selected entry and accepting
        /// or cancelling the menu.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            // we cancel the current menu screen if the user presses the back button
            PlayerIndex player;
            if (input.IsNewButtonPress(Buttons.Back, ControllingPlayer, out player))
            {
                OnCancel(player);
            }

			if (input.IsMenuDown(ControllingPlayer)) {
				if (selectedEntry < menuEntries.Count - 1)
					selectedEntry += 1;
			}

			if (input.IsMenuUp(ControllingPlayer)) {
				if (selectedEntry > 0)
					selectedEntry -= 1;
			}

			if (input.IsMenuSelect(ControllingPlayer, out player)) {
				menuEntries[selectedEntry].OnSelectEntry(player);
			}

			if (input.MouseGesture.HasFlag(MouseGestureType.LeftClick)) {

				Point clickLocation = new Point((int)input.CurrentMousePosition.X, (int)input.CurrentMousePosition.Y);
				// iterate the entries to see if any were tapped
				for (int i = 0; i < menuEntries.Count; i++)
				{
					MenuEntry menuEntry = menuEntries[i];

					if (GetMenuEntryHitBounds(menuEntry).Contains(clickLocation))
					{
						// select the entry. since gestures are only available on Windows Phone,
						// we can safely pass PlayerIndex.One to all entries since there is only
						// one player on Windows Phone.
						OnSelectEntry(i, PlayerIndex.One);
					}
				}
			}

			if (input.MouseGesture.HasFlag(MouseGestureType.Move)) {

				Point clickLocation = new Point((int)input.CurrentMousePosition.X, (int)input.CurrentMousePosition.Y);
				// iterate the entries to see if any were tapped
				for (int i = 0; i < menuEntries.Count; i++)
				{
					MenuEntry menuEntry = menuEntries[i];

					if (GetMenuEntryHitBounds(menuEntry).Contains(clickLocation))
					{
						// select the entry. since gestures are only available on Windows Phone,
						// we can safely pass PlayerIndex.One to all entries since there is only
						// one player on Windows Phone.
						//OnSelectEntry(i, PlayerIndex.One);
						selectedEntry = i;
					}
				}
			}

            // look for any taps that occurred and select any entries that were tapped
            foreach (GestureSample gesture in input.Gestures)
            {
                if (gesture.GestureType == GestureType.Tap)
                {
                    // convert the position to a Point that we can test against a Rectangle
                    Point tapLocation = new Point((int)gesture.Position.X, (int)gesture.Position.Y);

                    // iterate the entries to see if any were tapped
                    for (int i = 0; i < menuEntries.Count; i++)
                    {
                        MenuEntry menuEntry = menuEntries[i];

                        if (GetMenuEntryHitBounds(menuEntry).Contains(tapLocation))
                        {
                            // select the entry. since gestures are only available on Windows Phone,
                            // we can safely pass PlayerIndex.One to all entries since there is only
                            // one player on Windows Phone.
                            OnSelectEntry(i, PlayerIndex.One);
                        }
                    }
                }
            }
        }
예제 #8
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);
                    }
                }
            }
        }
예제 #9
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;
                }
            }
        }
예제 #10
0
		/// <summary>
		/// Handles user input for all the local gamers in the session. Unlike most
		/// screens, which use the InputState class to combine input data from all
		/// gamepads, the lobby needs to individually mark specific players as ready,
		/// so it loops over all the local gamers and reads their inputs individually.
		/// </summary>
		public override void HandleInput (InputState input)
		{
			foreach (LocalNetworkGamer gamer in networkSession.LocalGamers) {
				PlayerIndex playerIndex = gamer.SignedInGamer.PlayerIndex;

				PlayerIndex unwantedOutput;

				if (input.IsMenuSelect (playerIndex, out unwantedOutput)) {
					HandleMenuSelect (gamer);
				} else if (input.IsMenuCancel (playerIndex, out unwantedOutput)) {
					HandleMenuCancel (gamer);
				}
			}
		}
예제 #11
0
        /// <summary>
        /// Responds to user input, changing the selected entry and accepting
        /// or cancelling the menu.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            var touch = input.TouchState;

            var rect = new Rectangle(0,0,100,30);
            if (touch.Count == 1 ) {
                for (int i = 0; i < menuEntries.Count; i++){
                    rect.X = (int)menuEntries[i].Position.X;
                    rect.Y = (int)menuEntries[i].Position.Y;
                    selectedEntry = i;
                    if (rect.Contains((int)touch[0].Position.X, (int)touch[0].Position.Y)){
                        OnSelectEntry(selectedEntry, 0);
                        break;
                    }
                }
            }

            // Move to the previous menu entry?
            if (input.IsMenuUp(ControllingPlayer))
            {
                selectedEntry--;

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

            // Move to the next menu entry?
            if (input.IsMenuDown(ControllingPlayer))
            {
                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);
            }
        }
예제 #12
0
파일: MenuScreen.cs 프로젝트: GarethIW/LD29
        /// <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);
                    }
                }
            }
        }
        /// <summary>
        /// Responds to user input, changing the selected entry and accepting
        /// or cancelling the menu.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            // 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);
                //ExitScreen();
                showControls = !showControls;
            }
            if (input.IsMenuCancel(ControllingPlayer, out playerIndex))
            {
                //OnCancel(playerIndex);
                ExitScreen();
            }
        }
예제 #14
0
        /// <summary>
        /// Responds to user input, accepting or cancelling the message box.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            PlayerIndex playerIndex;
            Viewport viewport = ScreenManager.Game.GraphicsDevice.Viewport;
            Vector2 halfSize = new Vector2(viewport.Width, viewport.Height)/2;
            // 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())
            {
                // Raise the accepted event, then exit the message box.
                if (Accepted != null)
                    Accepted(this, new EventArgs());

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

                ExitScreen();
            }

            Point mouseLoc = new Point(input.CurrentMouseState.X, input.CurrentMouseState.Y);

            Rectangle okRect = new Rectangle((int)halfSize.X - 25, (int)halfSize.Y + 25, 50, 50);
            if (input.CurrentMouseState.LeftButton == ButtonState.Pressed && input.LastMouseState.LeftButton == ButtonState.Released)
            {
                if (okRect.Contains(mouseLoc)) ExitScreen();
            }
        }
예제 #15
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))
            {
                selectedEntry--;

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

            // Move to the next menu entry?
            if (input.IsMenuDown(ControllingPlayer))
            {
                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);
            }
        }
예제 #16
0
        /// <summary>
        /// Responds to user input, changing the selected entry and accepting
        /// or cancelling the menu.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            // we cancel the current menu screen if the user presses the back button
            PlayerIndex player;

            if (input.IsNewButtonPress(Buttons.Back, ControllingPlayer, out player))
            {
                OnCancel(player);
            }

            if (input.IsMenuDown(ControllingPlayer))
            {
                if (selectedEntry < menuEntries.Count - 1)
                {
                    selectedEntry += 1;
                }
            }

            if (input.IsMenuUp(ControllingPlayer))
            {
                if (selectedEntry > 0)
                {
                    selectedEntry -= 1;
                }
            }

            if (input.IsMenuSelect(ControllingPlayer, out player))
            {
                menuEntries[selectedEntry].OnSelectEntry(player);
            }

            if (input.MouseGesture.HasFlag(MouseGestureType.LeftClick))
            {
                Point clickLocation = new Point((int)input.CurrentMousePosition.X, (int)input.CurrentMousePosition.Y);
                // iterate the entries to see if any were tapped
                for (int i = 0; i < menuEntries.Count; i++)
                {
                    MenuEntry menuEntry = menuEntries[i];

                    if (GetMenuEntryHitBounds(menuEntry).Contains(clickLocation))
                    {
                        // select the entry. since gestures are only available on Windows Phone,
                        // we can safely pass PlayerIndex.One to all entries since there is only
                        // one player on Windows Phone.
                        OnSelectEntry(i, PlayerIndex.One);
                    }
                }
            }

            if (input.MouseGesture.HasFlag(MouseGestureType.Move))
            {
                Point clickLocation = new Point((int)input.CurrentMousePosition.X, (int)input.CurrentMousePosition.Y);
                // iterate the entries to see if any were tapped
                for (int i = 0; i < menuEntries.Count; i++)
                {
                    MenuEntry menuEntry = menuEntries[i];

                    if (GetMenuEntryHitBounds(menuEntry).Contains(clickLocation))
                    {
                        // select the entry. since gestures are only available on Windows Phone,
                        // we can safely pass PlayerIndex.One to all entries since there is only
                        // one player on Windows Phone.
                        //OnSelectEntry(i, PlayerIndex.One);
                        selectedEntry = i;
                    }
                }
            }

            // look for any taps that occurred and select any entries that were tapped
            foreach (GestureSample gesture in input.Gestures)
            {
                if (gesture.GestureType == GestureType.Tap)
                {
                    // convert the position to a Point that we can test against a Rectangle
                    Point tapLocation = new Point((int)gesture.Position.X, (int)gesture.Position.Y);

                    // iterate the entries to see if any were tapped
                    for (int i = 0; i < menuEntries.Count; i++)
                    {
                        MenuEntry menuEntry = menuEntries[i];

                        if (GetMenuEntryHitBounds(menuEntry).Contains(tapLocation))
                        {
                            // select the entry. since gestures are only available on Windows Phone,
                            // we can safely pass PlayerIndex.One to all entries since there is only
                            // one player on Windows Phone.
                            OnSelectEntry(i, PlayerIndex.One);
                        }
                    }
                }
            }
        }
예제 #17
0
        /// <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));

                ExitScreen();
            }
        }
예제 #18
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)
        {
            // Check if the user's input is null and throw an exception if it is
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            // Look up inputs for the active player profile
            KeyboardState keyboardState = input.CurrentKeyboardStates;

            // Checks to see if the user hit the pause button (esc)
            if (input.IsPauseGame())
            {
                // Add a new screen on top of our current screen to display the pause menu
                ScreenManager.AddScreen(new PauseMenuScreen());
            }

            // Check to see if our menu selection key was hit (Z)
            if (input.IsMenuSelect())
            {
                // Check to see if the player already has the move they are on in the selection screen equipped
                if (PlayerInfo.Moves.Contains(selectedMove))
                {
                    // Get the index of this move and remove it from the player's currently equipped moves
                    int index = Array.IndexOf(PlayerInfo.Moves, selectedMove);
                    PlayerInfo.Moves[index] = -1;
                }
                // Otherwise, if there is an open slot for equipping a new move
                else if (PlayerInfo.Moves.Contains(-1))
                {
                    // Get the index of the open slot and fill it with the new selected index
                    int index = Array.IndexOf(PlayerInfo.Moves, -1);
                    PlayerInfo.Moves[index] = selectedMove;
                }
            }
            // Check to see if the start button (enter) was pressed and if the player has any moves equipped (I.E anything with an index greater than -1)
            if (input.IsStartButton() && Array.Exists(PlayerInfo.Moves, selectedMove => selectedMove > -1))
            {
                // Load the next match
                LoadingScreen.Load(ScreenManager, false, new MatchupInfoScreen());
            }
            // Check to see if the up arrow key was hit
            if (input.IsMenuUp())
            {
                // Decrement the selected move
                selectedMove--;

                // Wrap the selected move around if the user goes beyond the minimum moves
                if (selectedMove < 0)
                {
                    selectedMove = maxMoves - 1;
                }
            }
            // Check to see if the down arrow key was hit
            if (input.IsMenuDown())
            {
                // Increment the selected move
                selectedMove++;

                // Wrap back around if the player goes beyond the maximum amount of moves
                if (selectedMove >= maxMoves)
                {
                    selectedMove = 0;
                }
            }
        }