コード例 #1
0
        public override void HandleInput(InputState input)
        {
            if (input.IsMenuUp(GamerOne.PlayerIndex))
            {
                selectedEntry--;

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

            if (input.IsMenuDown(GamerOne.PlayerIndex))
            {
                selectedEntry++;

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

            PlayerIndex playerIndex;

            if (input.IsMenuSelect(GamerOne.PlayerIndex, out playerIndex))
            {
                OnSelectEntry(selectedEntry, playerIndex);

            }
            else if (input.IsMenuCancel(GamerOne.PlayerIndex, out playerIndex))
            {

                OnCancel(playerIndex);

            }

            SelectedEntry = selectedEntry;
        }
コード例 #2
0
        public override void HandleInput(InputState input)
        {
            PlayerIndex playerIndex;
            if (input.IsMenuSelect(ControllingPlayer, out playerIndex))
            {

                if (Accepted != null)
                    Accepted(this, new PlayerIndexEventArgs(playerIndex));

                ExitScreen();
            }
            else if (input.IsMenuCancel(ControllingPlayer, out playerIndex))
            {
                if (Cancelled != null)
                    Cancelled(this, new PlayerIndexEventArgs(playerIndex));

                ExitScreen();
            }
        }
コード例 #3
0
        public override void HandleInput(InputState input)
        {
            int playerIndex = (int)ControllingPlayer.Value;

            if (input.CurrentGamePadStates[playerIndex].Buttons.A == ButtonState.Pressed && input.PreviousGamePadStates[playerIndex].Buttons.A == ButtonState.Released && scrollScreen)
            {
                scrollScreen = false;
            }
            else if (input.CurrentGamePadStates[playerIndex].Buttons.A == ButtonState.Pressed && input.PreviousGamePadStates[playerIndex].Buttons.A == ButtonState.Released && !scrollScreen)
            {
                scrollScreen = true;
            }
            else if (input.CurrentGamePadStates[playerIndex].Buttons.B == ButtonState.Pressed && input.PreviousGamePadStates[playerIndex].Buttons.B == ButtonState.Released)
            {
                this.ExitScreen();
            }

            base.HandleInput(input);
        }
コード例 #4
0
        public override void HandleInput(InputState input)
        {
            if (!gamerSelected)
            {
                for (int i = 0; i < InputState.MaxInputs; i++)
                {
                    if (input.CurrentGamePadStates[i].IsButtonDown(Buttons.Start) == true && input.PreviousGamePadStates[i].IsButtonUp(Buttons.Start) == true)
                    {
                        gamerOne = Gamer.SignedInGamers[(PlayerIndex)i];

                        gamerSelected = true;

                        if (gamerOne == null)
                        {
                            if (!Guide.IsVisible)
                            {
                                Guide.ShowSignIn(1, false);
                            }
                        }
                    }
                }
            }
        }
コード例 #5
0
        /// <summary>
        /// Check for input
        /// </summary>
        /// <param name="input">grabs the values from InputState</param>
        public override void HandleInput(InputState input)
        {
            if (input == null)
                throw new ArgumentNullException("input");

            //did you disconnect? //Switch this to two players if we want both players to be able to pause
            #region IsPlayerControllerDisconnectedOrOutOfBatteries?

            GamePadState gamePadState = input.CurrentGamePadStates[(int)GamerOne.PlayerIndex];

            bool gamePadDisconnected = !gamePadState.IsConnected &&
                                        input.GamePadWasConnected[(int)GamerOne.PlayerIndex];

            //...if so then pause and wait
            if (input.IsPauseGame(GamerOne.PlayerIndex) || gamePadDisconnected)
            {

                ScreenManager.AddScreen(new PauseMenuScreen(player.score, LevelOn, player.checkPoint, LevelName), GamerOne.PlayerIndex);

            }

            #endregion

            #region Move Left and Right

            player.velocity.X = input.CurrentGamePadStates[(int)GamerOne.PlayerIndex].ThumbSticks.Left.X * movementAcceleration;

            if (player.velocity.X > 0.0f && player.velocity.X < 1.0f)
            {
                player.velocity.X = 1.0f;
            }
            if (player.velocity.X < 0.0f && player.velocity.X > -1.0f)
            {
                player.velocity.X = -1.0f;
            }

            #endregion

            #region Fly/Jump
            //if we press and hold A then velocity is applied, or its just 0
            //if we press and hold A and still flying energy then we fly, or we just float on down due to gravity but the flying energy doesn't replenish unless we've hit something
            if (input.CurrentGamePadStates[(int)GamerOne.PlayerIndex].IsButtonDown(Buttons.A) && flyingAllowed)
            {
                player.velocity.Y = -5;
                flyingBarScale = -5;
                gravityAcceleration = 2;
            }
            else
            {
                player.velocity.Y = 0;
                flyingBarScale = 0;
                gravityAcceleration = 2;
            }

            #endregion

            refInput = input;
        }
コード例 #6
0
 public virtual void HandleInput(InputState input)
 {
 }