コード例 #1
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 ();
            }
        }
コード例 #2
0
ファイル: MenuScreen.cs プロジェクト: timrisi/DoubleNegative
        public override void HandleInput(InputState input)
        {
            if (input.IsMenuUp (ControllingPlayer)) {
                selectedEntry--;

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

            if (input.IsMenuDown (ControllingPlayer)) {
                selectedEntry++;

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

            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)
        {
            if (input == null)
                throw new ArgumentNullException ("input");

            // Look up inputs for the active player profile.
            int playerIndex = (int)ControllingPlayer.Value;

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

            // The game pauses either if the user presses the pause button, or if
            // they unplug the active gamepad. This requires us to keep track of
            // whether a gamepad was ever plugged in, because we don't want to pause
            // on PC if they are playing with a keyboard and have no gamepad at all!
            bool gamePadDisconnected = !gamePadState.IsConnected &&
                input.GamePadWasConnected [playerIndex];

            if (input.IsPauseGame (ControllingPlayer) || gamePadDisconnected)
                ScreenManager.AddScreen (new PauseMenuScreen (), ControllingPlayer);
            else {
                PlayerIndex index;
                if (input.IsNewKeyPress (Keys.Tab, null, out index)) {
                    currentTeam [ActiveIndex].IsActive = false;
                    ActiveIndex += 1;
                    currentTeam [ActiveIndex].IsActive = true;
                }

                if (input.IsNewKeyPress (Keys.RightShift, null, out index)) {
                    currentTeam [ActiveIndex].IsActive = false;
                    currentTurn = opponent;
                    ActiveIndex = 0;
                    currentTeam [ActiveIndex].IsActive = true;
                }

                foreach (var character in characters)
                    character.HandleInput (input, levelData);

                deformPosition = new Vector2 (mouseState.X - 50, mouseState.Y - 50);

                if (levelData [(int)(deformPosition.X + 50 + (deformPosition.Y + 50) * 800)] == Color.White)
                    deformColor = Color.Black;
                else
                    deformColor = Color.White;

                if (input.DidLeftMouseClick ())
                    deformLevel ();
            }
        }
コード例 #4
0
ファイル: Character.cs プロジェクト: timrisi/DoubleNegative
        public void HandleInput(InputState input, Color[] levelData)
        {
            PlayerIndex playerIndex;

            if (direction.X != 0)
                lastDirection = direction;
            direction.X = 0;

            if (IsActive) {
                if (state == State.Walking && getColor (leftCorner, levelData) != groundColor &&
                    input.IsKeyPressed (Keys.Left, null, out playerIndex) && leftCorner.X > 0)
                    direction.X = -1;
                else if (state == State.Walking && getColor (rightCorner, levelData) != groundColor &&
                    input.IsKeyPressed (Keys.Right, null, out playerIndex) && rightCorner.X < 799)
                    direction.X = 1;

                if (state == State.Walking &&
                    input.IsNewKeyPress (Keys.Enter, null, out playerIndex))
                    jump ();

                if (input.IsKeyPressed (Keys.Up, null, out playerIndex)) {
                    angle -= Math.PI / 128;
                    if (angle < -Math.PI / 2)
                        angle = -Math.PI / 2;
                }

                if (input.IsKeyPressed (Keys.Down, null, out playerIndex)) {
                    angle += Math.PI / 128;
                    if (angle > Math.PI / 2)
                        angle = Math.PI / 2;
                }

                if (input.IsKeyPressed (Keys.Space, null, out playerIndex) && power < 80) {
                    power += 1;
                    if (power == 80) {
                        fire ();
                        power = 0;
                    }
                }

                if (input.KeyWasReleased (Keys.Space, null, out playerIndex)) {
                    fire ();
                    power = 0;
                }
            }
        }
コード例 #5
0
ファイル: GameScreen.cs プロジェクト: timrisi/DoubleNegative
 public virtual void HandleInput(InputState input)
 {
 }