Ejemplo n.º 1
0
        /// <summary>
        /// Handles input for quitting or changing the bloom settings.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            lastKeyboardState = currentKeyboardState;
            lastGamePadState = currentGamePadState;

            var playerIndex = (int) ControllingPlayer.Value;

            currentKeyboardState = input.CurrentKeyboardStates[playerIndex];
            currentGamePadState = input.CurrentGamePadStates[playerIndex];

            // Check for exit.
            if (input.IsPauseGame(ControllingPlayer))
            {
                this.setBloomPreset("Default");
                ScreenManager.AddScreen(new QuitMenuScreen(true), ControllingPlayer);
                return;
            }

            PlayerOne.HandleInput(lastKeyboardState, lastGamePadState, currentKeyboardState, currentGamePadState);
            ai.HandleInput(lastKeyboardState, lastGamePadState, currentKeyboardState, currentGamePadState);

            //foreach (Entity entity in entites)
            //    entity.HandleInput(lastKeyboardState, lastGamePadState, currentKeyboardState, currentGamePadState);

            // Switch to the next bloom settings preset?
            /*if ((currentGamePadState.Buttons.A == ButtonState.Pressed &&
                 lastGamePadState.Buttons.A != ButtonState.Pressed) ||
                (currentKeyboardState.IsKeyDown(Keys.V) &&
                 lastKeyboardState.IsKeyUp(Keys.V))) {
                bloomSettingsIndex = (bloomSettingsIndex + 1) %
                                     BloomSettings.PresetSettings.Length;

                bloom.Settings = BloomSettings.PresetSettings[bloomSettingsIndex];
                bloom.Visible = true;
            }

            // Toggle bloom on or off?
            if ((currentKeyboardState.IsKeyDown(Keys.B) &&
                 lastKeyboardState.IsKeyUp(Keys.B))) {
                bloom.Visible = !bloom.Visible;
            }*/

             //Toggle fullscreen
            if ((currentKeyboardState.IsKeyDown(Keys.F) &&
                 lastKeyboardState.IsKeyUp(Keys.F)))
            {
                graphics.ToggleFullScreen();
            }

            // Toggle fpsCamera on or off?
            if ((currentGamePadState.Buttons.B == ButtonState.Pressed &&
                 lastGamePadState.Buttons.B != ButtonState.Pressed) ||
                (currentKeyboardState.IsKeyDown(Keys.C) &&
                 lastKeyboardState.IsKeyUp(Keys.C)))
            {
                _fpsCamera = !_fpsCamera;
            }

            // Toggle light rotation on or off?
            /*if ((currentKeyboardState.IsKeyDown(Keys.L) &&
                 lastKeyboardState.IsKeyUp(Keys.L))) {
                rotateLight = !rotateLight;
            }*/
        }
Ejemplo n.º 2
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();
            }
        }
Ejemplo n.º 3
0
        public override void HandleInput(InputState input)
        {
            PlayerIndex playerIndex = PlayerIndex.One;

            if (true)
            {
                if (SelectedEntry == 0 && input.IsNewKeyPress(Keys.Enter, ControllingPlayer, out playerIndex))
                {
                    ExitScreen();
                    return;
                }

                if (SelectedEntry == 1 && input.IsNewKeyPress(Keys.Enter, ControllingPlayer, out playerIndex))
                {
                    LoadingScreen.Load(ScreenManager, true, playerIndex,
                                       new GameplayScreen(GameMode.SinglePlayer, _playerOneName, _playerTwoName));
                    return;
                }

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

                    if (SelectedEntry < -1)
                        SelectedEntry = 1;

                    if (SelectedEntry == -1)
                    {
                        _textInput = _playerOneName;
                    }

                    /*if (SelectedEntry == -1)
                    {
                        _textInput = _playerTwoName;
                    }*/
                }

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

                    if (SelectedEntry > 1)
                        SelectedEntry = -1;

                    if (SelectedEntry == -1)
                    {
                        _textInput = _playerOneName;
                    }

                    /*if (SelectedEntry == -1)
                    {
                        _textInput = _playerTwoName;
                    }*/
                }

                /*if (textInput.Length > 9) {
                    return;
                }*/

                var i = (int) playerIndex;
                bool selected = false;
                string pressed = string.Empty;
                foreach (Keys key in input.CurrentKeyboardStates[i].GetPressedKeys())
                {
                    if (input.LastKeyboardStates[i].IsKeyUp(key) && !selected)
                    {
                        var keyNum = (int) key;
                        if (key == Keys.Back && _textInput.Length > 0)
                        {
                            _textInput = _textInput.Substring(0, _textInput.Length - 1);
                            return;
                        }
                        if (keyNum >= (int) Keys.A && keyNum <= (int) Keys.Z)
                        {
                            selected = true;
                            pressed = key.ToString();
                        }
                        else if (keyNum >= (int) Keys.D0 && keyNum <= (int) Keys.D9)
                        {
                            selected = true;
                            pressed = key.ToString().Substring(1, 1);
                        }
                    }
                    if ((key == Keys.RightShift || key == Keys.LeftShift))
                    {
                        _shiftKey = true;
                    }
                    else
                    {
                        _shiftKey = false;
                    }
                }

                if (!string.IsNullOrEmpty(pressed))
                {
                    if (!_shiftKey)
                    {
                        _textInput += pressed.ToLower();
                    }
                    else
                    {
                        _textInput += pressed.ToUpper();
                    }
                }

                if (SelectedEntry == -1)
                {
                    _playerOneName = _textInput;
                }

                /*if (SelectedEntry == -1)
                {
                    _playerTwoName = _textInput;
                }*/
            }
            /*else if (input.IsMenuCancel(ControllingPlayer, out playerIndex))
            {
                return;
            }
            else
            {
                base.HandleInput(input);
            }*/
        }
Ejemplo n.º 4
0
        public override void HandleInput(InputState input)
        {
            // ReSharper disable TooWideLocalVariableScope
            PlayerIndex playerIndex = PlayerIndex.One;
            // ReSharper restore TooWideLocalVariableScope
            if (true)
            {
                if (waiting)
                {
                    foreach (Keys key in input.CurrentKeyboardStates[0].GetPressedKeys())
                    {
                        if (input.LastKeyboardStates[0].IsKeyUp(key))
                        {
                            switch (SelectedEntry)
                            {
                                case -5:
                                    pm.PlayerOne.Forward = key;
                                    break;
                               /* case -9:
                                    pm.PlayerTwo.Forward = key;
                                    break;*/
                                case -4:
                                    pm.PlayerOne.Backward = key;
                                    break;
                               /* case -7:
                                    pm.PlayerTwo.Backward = key;
                                    break;*/
                                case -3:
                                    pm.PlayerOne.Left = key;
                                    break;
                              /*  case -5:
                                    pm.PlayerTwo.Left = key;
                                    break;*/

                                case -2:
                                    pm.PlayerOne.Right = key;
                                    break;

                              /*  case -3:
                                    pm.PlayerTwo.Right = key;
                                    break;*/

                                case -1:
                                    pm.PlayerOne.Shoot = key;
                                    break;

                              /*  case -1:
                                    pm.PlayerTwo.Shoot = key;
                                    break;*/

                                default:
                                    break;
                            }

                            waiting = false;
                            return;
                        }
                    }
                }

                if (SelectedEntry == 0 && input.IsNewKeyPress(Keys.Enter, ControllingPlayer, out playerIndex))
                {
                    ExitScreen();
                    ((MainGame) ScreenManager.Game).PreferenceManager = previousPm;
                    return;
                }

                if (SelectedEntry == 1 && input.IsNewKeyPress(Keys.Enter, ControllingPlayer, out playerIndex))
                {
                    ExitScreen();
                    ((MainGame) ScreenManager.Game).PreferenceManager = pm;
                    return;
                }

                if (SelectedEntry >= -5 && SelectedEntry < 0 &&
                    input.IsNewKeyPress(Keys.Enter, ControllingPlayer, out playerIndex))
                {
                    switch (SelectedEntry)
                    {
                        case -5:
                            if (!waiting)
                            {
                                pm.PlayerOne.Forward = Keys.None;
                                waiting = true;
                            }
                            break;
                        /*case -9:
                            if (!waiting)
                            {
                                pm.PlayerTwo.Forward = Keys.None;
                                waiting = true;
                            }
                            break;*/
                        case -4:
                            if (!waiting)
                            {
                                pm.PlayerOne.Backward = Keys.None;
                                waiting = true;
                            }
                            break;
                        /*case -7:
                            if (!waiting)
                            {
                                pm.PlayerTwo.Backward = Keys.None;
                                waiting = true;
                            }
                            break;*/
                        case -3:
                            if (!waiting)
                            {
                                pm.PlayerOne.Left = Keys.None;
                                waiting = true;
                            }
                            break;
                        /*case -5:
                            if (!waiting)
                            {
                                pm.PlayerTwo.Left = Keys.None;
                                waiting = true;
                            }
                            break;*/

                        case -2:
                            if (!waiting)
                            {
                                pm.PlayerOne.Right = Keys.None;
                                waiting = true;
                            }
                            break;

                        /*case -3:
                            if (!waiting)
                            {
                                pm.PlayerTwo.Right = Keys.None;
                                waiting = true;
                            }
                            break;*/

                        case -1:
                            if (!waiting)
                            {
                                pm.PlayerOne.Shoot = Keys.None;
                                waiting = true;
                            }
                            break;

                        /*case -1:
                            if (!waiting)
                            {
                                pm.PlayerTwo.Shoot = Keys.None;
                                waiting = true;
                            }
                            break;*/

                        default:
                            break;
                    }
                    return;
                }

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

                    if (SelectedEntry < -5)
                        SelectedEntry = 1;
                }

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

                    if (SelectedEntry > 1)
                        SelectedEntry = -5;
                }
            }

            if (SelectedEntry == -2)
            {
                //  playerOneName = textInput;
            }

            if (SelectedEntry == -1)
            {
                //   playerTwoName = textInput;
            }
        }
Ejemplo n.º 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(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);
            }
        }
Ejemplo n.º 6
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)
 {
 }