public override void HandleInput(InputState input)
        {
            int playerIndex = (int)ControllingPlayer.Value;

            if (input.CurrentGamePadStates[playerIndex].Buttons.RightShoulder == ButtonState.Pressed && input.PreviousGamePadStates[playerIndex].Buttons.RightShoulder == ButtonState.Released)
            {
                playerTriggerSensitivity += 0.33f;
                if (playerTriggerSensitivity > 1.0f)
                    playerTriggerSensitivity = 0.99f;
            }
            if (input.CurrentGamePadStates[playerIndex].Buttons.LeftShoulder == ButtonState.Pressed && input.PreviousGamePadStates[playerIndex].Buttons.LeftShoulder == ButtonState.Released)
            {
                playerTriggerSensitivity -= 0.33f;
                if (playerTriggerSensitivity < 0.0f)
                    playerTriggerSensitivity = 0.0f;
            }
            if (input.CurrentGamePadStates[playerIndex].Buttons.B == ButtonState.Pressed)
            {
                OnCancel();
            }
            TriggerSensitivity = playerTriggerSensitivity;
            UpdateSensitivity();

            base.HandleInput(input);
        }
Exemplo n.º 2
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);
        }
        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();
            }
        }
Exemplo n.º 4
0
 public virtual void HandleInput(InputState input)
 {
 }
Exemplo n.º 5
0
        public override void HandleInput(InputState input)
        {
            //if the game is active right now
            if (active)
            {
                for (int i = 0; i < 4; i++)
                {

                    #region TriggerSensitivities
                    if (input.CurrentGamePadStates[i].Buttons.RightShoulder == ButtonState.Pressed && input.PreviousGamePadStates[i].Buttons.RightShoulder == ButtonState.Released)
                    {
                        playerTriggerSensitivitys[i] += 0.33f;
                        if (playerTriggerSensitivitys[i] > 1.0f)
                            playerTriggerSensitivitys[i] = 0.99f;
                    }
                    if (input.CurrentGamePadStates[i].Buttons.LeftShoulder == ButtonState.Pressed && input.PreviousGamePadStates[i].Buttons.LeftShoulder == ButtonState.Released)
                    {
                        playerTriggerSensitivitys[i] -= 0.33f;
                        if (playerTriggerSensitivitys[i] < 0.0f)
                            playerTriggerSensitivitys[i] = 0.0f;
                    }
                    #endregion

                }

                UpdateInfo(input);

                UpdateSensitivity();
            }

            base.HandleInput(input);
        }
Exemplo n.º 6
0
 private void UpdateInfo(InputState input)
 {
     #region Character && Gun Info Pull Up
     for (int i = 0; i < numberOfPlayersJoined; i++)
     {
         if (input.CurrentGamePadStates[i].Buttons.Y == ButtonState.Pressed && input.PreviousGamePadStates[i].Buttons.Y == ButtonState.Released)
         {
             ControllingPlayer = (PlayerIndex)i;
             active = false;
             ScreenManager.AddScreen(new CharacterInfoScreen(), ControllingPlayer);
         }
         if (input.CurrentGamePadStates[i].Buttons.X == ButtonState.Pressed && input.PreviousGamePadStates[i].Buttons.Y == ButtonState.Released)
         {
             ControllingPlayer = (PlayerIndex)i;
             active = false;
             ScreenManager.AddScreen(new GunInfoScreen(), ControllingPlayer);
         }
     }
     #endregion
 }
        private void UpdateWeapon(InputState input, Character playerCharacter, int playerNumber)
        {
            switch (playerCharacter)
            {
                //seems fine
                #region Sayid Weapon Timer
                case Character.Sayid:
                    //if pressed down
                    if (input.CurrentGamePadStates[playerNumber].Triggers.Right > players[playerNumber].triggerSensitivity)
                    {

                        //if there is allowed for a new timer to be created
                        if (sayidNewTimer && !sayidTimerActive)
                        {

                            TimerCallback tcb = SayidFireWeapon;

                            sayidsPlayer = players[playerNumber];

                            sayidTimer = new Timer(tcb, autoEvent, 0, 330);

                            sayidNewTimer = false;

                            sayidTimerActive = true;
                        }

                    }
                    //if let go
                    if (input.CurrentGamePadStates[playerNumber].Triggers.Right <= players[playerNumber].triggerSensitivity && sayidTimerActive)
                    {
                        if (sayidTimer != null)
                        {
                            sayidTimer.Dispose();
                        }
                        //allow for a new timer to be created
                        sayidNewTimer = true;

                        sayidTimerActive = false;
                    }
                    break;
                #endregion
                //seems fine
                #region Juan Weapon Timer
                case Character.Juan:
                    if (input.CurrentGamePadStates[playerNumber].Triggers.Right > players[playerNumber].triggerSensitivity)
                    {

                        if (juanNewTimer && !juanTimerActive)
                        {

                            TimerCallback tcb = JuanFireWeapon;

                            juansPlayer = players[playerNumber];

                            juanTimer = new Timer(tcb, autoEvent, 0, 1000);

                            juanNewTimer = false;

                        }
                    }
                    if (input.CurrentGamePadStates[playerNumber].Triggers.Right <= players[playerNumber].triggerSensitivity && juanTimerActive)
                    {
                        if (juanTimer != null)
                        {
                            juanTimer.Dispose();
                        }

                        juanNewTimer = true;

                        juanTimerActive = false;

                    }

                    break;
                #endregion
                //seems fine
                #region Sir Edward Weapon Timer
                case Character.Sir_Edward:
                    if (input.CurrentGamePadStates[playerNumber].Triggers.Right > players[playerNumber].triggerSensitivity)
                    {

                        if (sir_EdwardNewTimer && !sir_EdwardTimerActive)
                        {

                            TimerCallback tcb = SirEdwardFireWeapon;

                            sirEdwardsPlayer = players[playerNumber];

                            sir_EdwardTimer = new Timer(tcb, autoEvent, 0, 500);

                            sir_EdwardNewTimer = false;

                        }
                    }
                    if (input.CurrentGamePadStates[playerNumber].Triggers.Right <= players[playerNumber].triggerSensitivity && sir_EdwardTimerActive)
                    {
                        if (sir_EdwardTimer != null)
                        {
                            sir_EdwardTimer.Dispose();
                        }

                        sir_EdwardNewTimer = true;

                        sir_EdwardTimerActive = false;

                    }
                    break;
                #endregion
                //seems fine
                #region Wilhelm Weapon Timer
                case Character.Wilhelm:
                    if (input.CurrentGamePadStates[playerNumber].Triggers.Right > players[playerNumber].triggerSensitivity)
                    {

                        if (wilhelmNewTimer && !wilhelmTimerActive)
                        {

                            TimerCallback tcb = WilhelmFireWeapon;

                            wilhelmsPlayer = players[playerNumber];

                            wilhelmTimer = new Timer(tcb, autoEvent, 0, 500);

                            wilhelmNewTimer = false;

                        }
                    }
                    if (input.CurrentGamePadStates[playerNumber].Triggers.Right <= players[playerNumber].triggerSensitivity && wilhelmTimerActive)
                    {
                        if (wilhelmTimer != null)
                        {
                            wilhelmTimer.Dispose();
                        }

                        wilhelmNewTimer = true;

                        wilhelmTimerActive = false;

                    }
                    break;
                #endregion
            }
        }
        /// <summary>
        /// This is what the player pressed while playing the game and how the game should respond to that action
        /// Controlling shooting, moving, and other player inputs
        /// </summary>
        /// <param name="input">what the player has inputted</param>
        public override void HandleInput(InputState input)
        {
            if (IsPauseMenuDone)
            {
                Active = true;
            }
            if (Active)
            {
                if (input == null)
                    throw new ArgumentNullException("input");

                //did you disconnect?
                #region IsPlayerControllerDisconnectedOrOutOfBatteries?

                int playerIndex = (int)ControllingPlayer.Value;

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

                bool gamePadDisconnected = !gamePadState.IsConnected &&
                                            input.GamePadWasConnected[playerIndex];

                //...if so then pause and wait
                if (input.IsPauseGame(ControllingPlayer) || gamePadDisconnected)
                {
                    #region Bring up Pause Menu

                    for (int i = 0; i < 4; i++)
                    {
                        if (ControllingPlayer == (PlayerIndex)i)
                        {
                            ScreenManager.AddScreen(new PauseMenuScreen(players[i].triggerSensitivity, levelCount), ControllingPlayer);
                        }
                    }

                    #endregion
                    //assign new trigger sensitivites
                    newTriggerSensitivity = true;
                    //...and we are not 'activly playing'
                    Active = false;
                }

                #endregion

                #region New Trigger Sensitivities
                if (newTriggerSensitivity)
                {
                    for (int i = 0; i < 4; i++)
                    {
                        if (ControllingPlayer == (PlayerIndex)i)
                        {
                            players[i].triggerSensitivity = TriggerSensitivity;
                            break;
                        }

                    }

                    //do not assign again
                    newTriggerSensitivity = false;
                }
                #endregion

                int j = GetPlayerValues(playerAlive[0], playerAlive[1], playerAlive[2], playerAlive[3]);
                int k = GetPlayerValues(playerAlive[0], playerAlive[1], playerAlive[2], playerAlive[3]);
                int l = GetPlayerValues(playerAlive[0], playerAlive[1], playerAlive[2], playerAlive[3]);
                int m = GetPlayerValues(playerAlive[0], playerAlive[1], playerAlive[2], playerAlive[3]);

                switch (numberOfPlayersLeft)
                {
                    #region 1
                    case 1:
                        j = GetPlayerValues(playerAlive[0], playerAlive[1], playerAlive[2], playerAlive[3]);
                        //the left stick moves the player's position in the x and y position
                        players[j].position.X += input.CurrentGamePadStates[j].ThumbSticks.Left.X * 5.0f;
                        players[j].position.Y += -input.CurrentGamePadStates[j].ThumbSticks.Left.Y * 5.0f;
                        //the right stick rotates the player in the exact direction of the right stick in referece to the controller
                        //      uses my own TurnAngle method
                        players[j].rotation = TurnAngle(input.CurrentGamePadStates[j].ThumbSticks.Right.X, input.CurrentGamePadStates[j].ThumbSticks.Right.Y, players[j].rotation);
                        UpdateWeapon(input, players[j].playerCharacter ,j);

                        break;
                    #endregion
                    #region 2
                    case 2:
                        j = GetPlayerValues(playerAlive[0], playerAlive[1], playerAlive[2], playerAlive[3]);
                        k = GetPlayerValues(playerAlive[0], playerAlive[1], playerAlive[2], playerAlive[3]);

                        players[j].position.X += input.CurrentGamePadStates[j].ThumbSticks.Left.X * 5.0f;
                        players[j].position.Y += -input.CurrentGamePadStates[j].ThumbSticks.Left.Y * 5.0f;
                        players[j].rotation = TurnAngle(input.CurrentGamePadStates[j].ThumbSticks.Right.X, input.CurrentGamePadStates[j].ThumbSticks.Right.Y, players[j].rotation);
                        players[k].position.X += input.CurrentGamePadStates[k].ThumbSticks.Left.X * 5.0f;
                        players[k].position.Y += -input.CurrentGamePadStates[k].ThumbSticks.Left.Y * 5.0f;
                        players[k].rotation = TurnAngle(input.CurrentGamePadStates[k].ThumbSticks.Right.X, input.CurrentGamePadStates[k].ThumbSticks.Right.Y, players[k].rotation);

                        UpdateWeapon(input, players[j].playerCharacter, j);
                        UpdateWeapon(input, players[k].playerCharacter, k);

                        break;
                    #endregion
                    #region 3
                    case 3:
                        j = GetPlayerValues(playerAlive[0], playerAlive[1], playerAlive[2], playerAlive[3]);
                        k = GetPlayerValues(playerAlive[0], playerAlive[1], playerAlive[2], playerAlive[3]);
                        l = GetPlayerValues(playerAlive[0], playerAlive[1], playerAlive[2], playerAlive[3]);

                        players[j].position.X += input.CurrentGamePadStates[j].ThumbSticks.Left.X * 5.0f;
                        players[j].position.Y += -input.CurrentGamePadStates[j].ThumbSticks.Left.Y * 5.0f;
                        players[j].rotation = TurnAngle(input.CurrentGamePadStates[j].ThumbSticks.Right.X, input.CurrentGamePadStates[j].ThumbSticks.Right.Y, players[j].rotation);
                        players[k].position.X += input.CurrentGamePadStates[k].ThumbSticks.Left.X * 5.0f;
                        players[k].position.Y += -input.CurrentGamePadStates[k].ThumbSticks.Left.Y * 5.0f;
                        players[k].rotation = TurnAngle(input.CurrentGamePadStates[k].ThumbSticks.Right.X, input.CurrentGamePadStates[k].ThumbSticks.Right.Y, players[k].rotation);
                        players[l].position.X += input.CurrentGamePadStates[l].ThumbSticks.Left.X * 5.0f;
                        players[l].position.Y += -input.CurrentGamePadStates[l].ThumbSticks.Left.Y * 5.0f;
                        players[l].rotation = TurnAngle(input.CurrentGamePadStates[l].ThumbSticks.Right.X, input.CurrentGamePadStates[l].ThumbSticks.Right.Y, players[l].rotation);

                        UpdateWeapon(input, players[j].playerCharacter, j);
                        UpdateWeapon(input, players[k].playerCharacter, k);
                        UpdateWeapon(input, players[l].playerCharacter, l);

                        break;
                    #endregion
                    #region 4
                    case 4:
                        j = GetPlayerValues(playerAlive[0], playerAlive[1], playerAlive[2], playerAlive[3]);
                        k = GetPlayerValues(playerAlive[0], playerAlive[1], playerAlive[2], playerAlive[3]);
                        l = GetPlayerValues(playerAlive[0], playerAlive[1], playerAlive[2], playerAlive[3]);
                        m = GetPlayerValues(playerAlive[0], playerAlive[1], playerAlive[2], playerAlive[3]);

                        players[j].position.X += input.CurrentGamePadStates[j].ThumbSticks.Left.X * 5.0f;
                        players[j].position.Y += -input.CurrentGamePadStates[j].ThumbSticks.Left.Y * 5.0f;
                        players[j].rotation = TurnAngle(input.CurrentGamePadStates[j].ThumbSticks.Right.X, input.CurrentGamePadStates[j].ThumbSticks.Right.Y, players[j].rotation);
                        players[k].position.X += input.CurrentGamePadStates[k].ThumbSticks.Left.X * 5.0f;
                        players[k].position.Y += -input.CurrentGamePadStates[k].ThumbSticks.Left.Y * 5.0f;
                        players[k].rotation = TurnAngle(input.CurrentGamePadStates[k].ThumbSticks.Right.X, input.CurrentGamePadStates[k].ThumbSticks.Right.Y, players[k].rotation);
                        players[l].position.X += input.CurrentGamePadStates[l].ThumbSticks.Left.X * 5.0f;
                        players[l].position.Y += -input.CurrentGamePadStates[l].ThumbSticks.Left.Y * 5.0f;
                        players[l].rotation = TurnAngle(input.CurrentGamePadStates[l].ThumbSticks.Right.X, input.CurrentGamePadStates[l].ThumbSticks.Right.Y, players[l].rotation);
                        players[m].position.X += input.CurrentGamePadStates[m].ThumbSticks.Left.X * 5.0f;
                        players[m].position.Y += -input.CurrentGamePadStates[m].ThumbSticks.Left.Y * 5.0f;
                        players[m].rotation = TurnAngle(input.CurrentGamePadStates[m].ThumbSticks.Right.X, input.CurrentGamePadStates[m].ThumbSticks.Right.Y, players[m].rotation);

                        UpdateWeapon(input, players[j].playerCharacter, j);
                        UpdateWeapon(input, players[k].playerCharacter, k);
                        UpdateWeapon(input, players[l].playerCharacter, l);
                        UpdateWeapon(input, players[m].playerCharacter, m);

                        break;
                    #endregion

                }

                UncheckPlayers();

            }
        }
Exemplo n.º 9
0
        public override void HandleInput(InputState input)
        {
            if (OnStartUp)
            {
                if (input.IsMenuUp(ControllingPlayer))
                {
                    startUpSelectedEntry--;

                    if (startUpSelectedEntry < 0)
                        startUpSelectedEntry = startUpMenuEntries.Count - 1;
                }
                if (input.IsMenuDown(ControllingPlayer))
                {
                    startUpSelectedEntry++;

                    if (startUpSelectedEntry >= startUpMenuEntries.Count)
                        startUpSelectedEntry = 0;
                }
            }
            else
            {

                if (input.IsMenuUp(PlayerIndex.One))
                {
                    selectedEntry--;

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

                if (input.IsMenuUp(PlayerIndex.Two))
                {
                    selectedEntry2--;

                    if (selectedEntry2 < 0)
                        selectedEntry2 = menuEntries2.Count - 1;
                }
                if (input.IsMenuUp(PlayerIndex.Three))
                {
                    selectedEntry3--;

                    if (selectedEntry3 < 0)
                        selectedEntry3 = menuEntries3.Count - 1;
                }
                if (input.IsMenuUp(PlayerIndex.Four))
                {
                    selectedEntry4--;

                    if (selectedEntry4 < 0)
                        selectedEntry4 = menuEntries4.Count - 1;
                }

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

                    if (selectedEntry >= menuEntries.Count)
                        selectedEntry = 0;
                }
                if (input.IsMenuDown(PlayerIndex.Two))
                {
                    selectedEntry2++;

                    if (selectedEntry2 >= menuEntries2.Count)
                        selectedEntry2 = 0;
                }
                if (input.IsMenuDown(PlayerIndex.Three))
                {
                    selectedEntry3++;

                    if (selectedEntry3 >= menuEntries3.Count)
                        selectedEntry3 = 0;
                }
                if (input.IsMenuDown(PlayerIndex.Four))
                {
                    selectedEntry4++;

                    if (selectedEntry4 >= menuEntries4.Count)
                        selectedEntry4 = 0;
                }
            }

            PlayerIndex playerIndex;
            if (OnStartUp)
            {
                if (input.IsMenuSelect(ControllingPlayer, out playerIndex))
                {
                    OnSelectEntry(startUpSelectedEntry, playerIndex);
                }
                else if (input.IsMenuCancel(ControllingPlayer, out playerIndex))
                {
                    OnCancel(playerIndex);
                }

            }
            else
            {
                if (input.IsMenuSelect(PlayerIndex.One, out playerIndex))
                {
                    OnSelectEntry(selectedEntry, playerIndex);
                }
                else if (input.IsMenuCancel(PlayerIndex.One, out playerIndex))
                {
                    OnCancel(playerIndex);
                }
                if (input.IsMenuSelect(PlayerIndex.Two, out playerIndex))
                {
                    OnSelectEntry(selectedEntry2, playerIndex);
                }
                else if (input.IsMenuCancel(PlayerIndex.Two, out playerIndex))
                {
                    OnCancel(playerIndex);
                }
                if (input.IsMenuSelect(PlayerIndex.Three, out playerIndex))
                {
                    OnSelectEntry(selectedEntry3, playerIndex);
                }
                else if (input.IsMenuCancel(PlayerIndex.Three, out playerIndex))
                {
                    OnCancel(playerIndex);
                }
                if (input.IsMenuSelect(PlayerIndex.Four, out playerIndex))
                {
                    OnSelectEntry(selectedEntry4, playerIndex);
                }
                else if (input.IsMenuCancel(PlayerIndex.Four, out playerIndex))
                {
                    OnCancel(playerIndex);
                }
            }
        }
Exemplo n.º 10
0
        public override void HandleInput(InputState input)
        {
            PlayerIndex playerIndex;
            if (input.IsMenuSelect(ControllingPlayer, out playerIndex))
            {

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

                if (returning)
                {
                    LoadingScreen.Load(ScreenManager, true, playerIndex, false, new BackgroundScreen(),
                                                                                new MainMenuScreen());
                }
                else if (exiting)
                {
                    ScreenManager.Game.Exit();
                }

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

                ExitScreen();
            }
        }
Exemplo n.º 11
0
        public override void HandleInput(InputState input)
        {
            if (readyToLoad)
            {
                int playerIndex = (int)ControllingPlayer.Value;
                if (input.CurrentGamePadStates[playerIndex].Buttons.A == ButtonState.Pressed && input.PreviousGamePadStates[playerIndex].Buttons.A == ButtonState.Released)
                {
                    ScreenManager.RemoveScreen(this);

                    foreach (GameScreen screen in screensToLoad)
                    {
                        if (screen != null)
                        {
                            ScreenManager.AddScreen(screen, ControllingPlayer);
                        }
                    }

                    ScreenManager.Game.ResetElapsedTime();

                }
            }

            base.HandleInput(input);
        }