Ejemplo n.º 1
0
        public override void HandleInput(InputState input)
        {
            if (input == null)
                throw new ArgumentNullException("input");

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

            base.HandleInput(input);
        }
Ejemplo n.º 2
0
        public override void HandleInput(InputState input)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

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

            base.HandleInput(input);
        }
Ejemplo n.º 3
0
        /// <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(new HighScoreScreen(ScreenManager.Game));
            }

            return(true);
        }
        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;
        }
Ejemplo n.º 6
0
        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);
        }