public override void HandleInput(InputState input)
        {
            if (input == null)
                throw new ArgumentNullException("input");

            if(input.IsNewButtonPress(Buttons.Back))
                ExitScreen();

            base.HandleInput(input);
        }
        /// <summary>
        /// Lets the game respond to player input. Unlike the Update method,
        /// this will only be called when the gameplay screen is active.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            if (input == null)
                throw new ArgumentNullException("input");

            if (ControllingPlayer.HasValue)
            {
                // In single player games, handle input for the controlling player.
                HandlePlayerInput(input, ControllingPlayer.Value);
            }
            /*
            else if (networkSession != null)
            {
            // In network game modes, handle input for all the
            // local players who are participating in the session.
            foreach (LocalNetworkGamer gamer in networkSession.LocalGamers)
            {
                if (!HandlePlayerInput(input, gamer.SignedInGamer.PlayerIndex))
                    break;
            }
            }
             */
        }
        public override void HandleInput(InputState input)
        {
            if (input.IsNewButtonPress(Buttons.DPadUp))
                ExitScreen();

                oldGp = curGp;
                curGp = GamePad.GetState(PlayerIndex.One);
                oldKb = curKb;
                curKb = Keyboard.GetState(PlayerIndex.One);

                //if ((curGp.IsButtonDown(Buttons.A) && !oldGp.IsButtonDown(Buttons.A))
                //  || (curKb.IsKeyDown(Keys.A) && !oldKb.IsKeyDown(Keys.A)))
                if (input.IsNewButtonPress(Buttons.A))
                {
                    /* A adds highscore for currently signed in gamer.
                     */
                    // click.Play();
                    AddHighscore(SignedInGamer.SignedInGamers[PlayerIndex.One]);
                }
                //if ((curGp.IsButtonDown(Buttons.B) && !oldGp.IsButtonDown(Buttons.B))
                //  || (curKb.IsKeyDown(Keys.B) && !oldKb.IsKeyDown(Keys.B)))
                if (input.IsNewButtonPress(Buttons.B))
                {
                    /* B adds a random highscore
                     */
                    // click.Play();
                    AddHighscore();
                }
                //if ((curGp.IsButtonDown(Buttons.X) && !oldGp.IsButtonDown(Buttons.X))
                //  || (curKb.IsKeyDown(Keys.X) && !oldKb.IsKeyDown(Keys.X)))
                if (input.IsNewButtonPress(Buttons.X))
                {
                    /* X toggles display of main menu or highscores.
                     */
                    // click.Play();
                    ToggleHighscores();
                }
                //if ((curGp.IsButtonDown(Buttons.Y) && !oldGp.IsButtonDown(Buttons.Y))
                //  || (curKb.IsKeyDown(Keys.Y) && !oldKb.IsKeyDown(Keys.Y)))
                if (input.IsNewButtonPress(Buttons.Y))
                {
                    /* Y attempts to save scores to disk, and re-selects storage if
                     * there's no currently active storage.
                     */
                    // click.Play();
                    if (!Storage.Instance.StartSaving())
                    {
                        Storage.Instance.ReselectStorage();
                    }
                }
                //if ((curGp.IsButtonDown(Buttons.Start) && !oldGp.IsButtonDown(Buttons.Start))
                //  || (curKb.IsKeyDown(Keys.Enter) && !oldKb.IsKeyDown(Keys.Enter)))
                if (input.IsNewButtonPress(Buttons.Start) || input.IsNewKeyPress(Keys.Enter))
                {
                    /* Clear anything having to do with higscores. If the user had previously
                     * refused storage, start asking for new storage.
                     */
                    // click.Play();
                    if (!Storage.Instance.ClearLoaded())
                    {
                        Storage.Instance.ReselectStorage();
                    }
                    /* And update the display of highscores.
                     */
                    if (isHighscores)
                    {
                        BuildHighscoreTexts();
                    }
                }
                //if ((curGp.IsButtonDown(Buttons.LeftShoulder) && !oldGp.IsButtonDown(Buttons.LeftShoulder))
                //  || (curKb.IsKeyDown(Keys.LeftControl) && !oldKb.IsKeyDown(Keys.LeftControl)))
                if (input.IsNewButtonPress(Buttons.LeftShoulder))
                {
                    /* Toggle auto-save on score update. Games that are sensitive to storage latency
                     * may want to have auto-save off. Games that want the utmost of convenience will
                     * want it on. A warning, though: when auto-save is on, it may take a little while
                     * (a few seconds) after a highscore is recorded until it's actually safely saved
                     * on disk.
                     */
                    // click.Play();
                    Storage.Autosave = !Storage.Autosave;
                    autosaveText.Str = "LB) Autosave is " + (Storage.Autosave ? "ON" : "OFF");
                }
                //if ((curGp.IsButtonDown(Buttons.RightShoulder) && !oldGp.IsButtonDown(Buttons.RightShoulder))
                //  || (curKb.IsKeyDown(Keys.RightControl) && !oldKb.IsKeyDown(Keys.RightControl)))
                if (input.IsNewButtonPress(Buttons.RightShoulder))
                {
                    /* Filter highscores. This purges some highscores older than a week, and purges
                     * highscores older than three months more.
                     */
                    // click.Play();
                    Storage.Instance.KeepSomeHighscores(null);
                }
                //if ((curGp.IsButtonDown(Buttons.DPadLeft) && !oldGp.IsButtonDown(Buttons.DPadLeft))
                //  || (curKb.IsKeyDown(Keys.Left) && !oldKb.IsKeyDown(Keys.Left)))
                if (input.IsNewButtonPress(Buttons.DPadLeft))
                {
                    /* Toggle game type leftwards when displaying highscores.
                     */
                    // click.Play();
                    if (isHighscores)
                    {
                        if (gametypeFilter == -1)
                            gametypeFilter = gametypes.Length;
                        --gametypeFilter;
                        BuildHighscoreTexts();
                    }
                }
                //if ((curGp.IsButtonDown(Buttons.DPadRight) && !oldGp.IsButtonDown(Buttons.DPadRight))
                //  || (curKb.IsKeyDown(Keys.Right) && !oldKb.IsKeyDown(Keys.Right)))
                if (input.IsNewButtonPress(Buttons.DPadRight))
                {
                    /* Toggle game type rightwards when displaying highscores.
                     */
                    // click.Play();
                    if (isHighscores)
                    {
                        ++gametypeFilter;
                        if (gametypeFilter == gametypes.Length)
                            gametypeFilter = -1;
                        BuildHighscoreTexts();
                    }
            }
            //if (curGp.IsButtonDown(Buttons.Back) || curKb.IsKeyDown(Keys.Escape))
            //{
            //    /* Back or Excape exits the game. Obviously, no real game would do this.
            //     */
            //    // click.Play();
            //    Exit();
            //}

            base.HandleInput(input);
        }
        /// <summary>
        /// Handles input for the specified player. In local game modes, this is called
        /// just once for the controlling player. In network modes, it can be called
        /// more than once if there are multiple profiles playing on the local machine.
        /// Returns true if we should continue to handle input for subsequent players,
        /// or false if this player has paused the game.
        /// </summary>
        bool HandlePlayerInput(InputState input, PlayerIndex playerIndex)
        {
            // Look up inputs for the specified player profile.
            KeyboardState keyboardState = input.CurrentKeyboardStates[(int)playerIndex];
            GamePadState gamePadState = input.CurrentGamePadStates[(int)playerIndex];

            // 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[(int)playerIndex];

            if (input.IsPauseGame(playerIndex) || gamePadDisconnected)
            {
                // If they pressed pause, bring up the pause menu screen.
                ScreenManager.AddScreen(new PauseMenuScreen());
                return false;
            }
            if (input.SeeStats)
            {
                // If they pressed to see their stats, bring up the stats screen.
                List<int> playerScores = new List<int>();
                for (int i = 0; i < playerManager.playerList.Count; i++)
                    playerScores.Add(playerManager.playerList[i].score);

                ScreenManager.AddScreen(new StatsScreen(playerScores));
            }

            // Pressing DPad-Up enables the High Score Screen
            if (input.IsNewButtonPress(Buttons.DPadUp))
                ScreenManager.AddScreen(hss);

            return true;
        }
        /// <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.MenuUp)
            {
                selectedEntry--;

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

                //audioManager.PlayCue("menuMove");
            }

            // Move to the next menu entry?
            if (input.MenuDown)
            {
                selectedEntry++;

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

                //audioManager.PlayCue("menuMove");
            }

            // Accept or cancel the menu?
            if (input.MenuSelect)
            {
                OnSelectEntry(selectedEntry);

                //audioManager.PlayCue("menuSelect");
            }
            else if (input.MenuCancel)
            {
                OnCancel();
            }
        }
 /// <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)
 {
 }
示例#7
0
        /// <summary>
        /// Lets the game respond to player input. Unlike the Update method,
        /// this will only be called when the gameplay screen is active.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            if (input == null)
                throw new ArgumentNullException("input");

            KeyboardState keyboardState = input.CurrentKeyboardStates[1];
            if (keyboardState.IsKeyDown(Keys.Escape))
                // If they pressed pause, bring up the pause menu screen.
                ScreenManager.AddScreen(new PauseMenuScreen());
            if (keyboardState.IsKeyDown(Keys.Up))
                joey.position += new Vector2(0,-5);
            if (keyboardState.IsKeyDown(Keys.Down))
                joey.position += new Vector2(0,5);
            if (keyboardState.IsKeyDown(Keys.Space) && !oldState.IsKeyDown(Keys.Space))
                blowKiss();

            //Clamp the positions
            joey.position.X = MathHelper.Clamp(joey.position.X, 0, 600);
            joey.position.Y = MathHelper.Clamp(joey.position.Y, 0 + joey.center.Y, 600 - joey.texture.Height + joey.center.Y);

            oldState = keyboardState;
        }
        /// <summary>
        /// Responds to user input, accepting or cancelling the message box.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            if (input.MenuSelect)
            {
                // Raise the accepted event, then exit the message box.
                if (Accepted != null)
                    Accepted(this, EventArgs.Empty);

                ExitScreen();
            }
            else if (input.MenuCancel)
            {
                // Raise the cancelled event, then exit the message box.
                if (Cancelled != null)
                    Cancelled(this, EventArgs.Empty);

                ExitScreen();
            }
        }