Example #1
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 ();
            }
        }