Пример #1
0
        /// <summary>
        /// Evaluates the action against a given InputState.
        /// </summary>
        /// <param name="state">The InputState to test for the action.</param>
        /// <param name="controllingPlayer">The player to test, or null to allow any player.</param>
        /// <param name="player">If controllingPlayer is null, this is the player that performed the action.</param>
        /// <returns>True if the action occured, false otherwise.</returns>
        public bool Evaluate(InputState state, PlayerIndex? controllingPlayer, out PlayerIndex player)
        {
            // Figure out which delgate methods to map from the state which takes
            // care of our "newPressOnly" logic
            ButtonPress buttonTest;
            KeyPress keyTest;
            if (newPressOnly)
            {
                buttonTest = state.IsButtonPressed;
                keyTest = state.IsKeyPressed;
            }
            else
            {
                buttonTest = state.IsButtonDown;
                keyTest = state.IsKeyDown;
            }

            // Now we simply need to invoke the appropriate methods for each button
            // and key in our collections
            foreach (Buttons button in buttons)
            {
                if (buttonTest(button, controllingPlayer, out player))
                    return true;
            }
            foreach (Keys key in keys)
            {
                if (keyTest(key, controllingPlayer, out player))
                    return true;
            }

            // If we got here, the action is not matched
            player = PlayerIndex.One;
            return false;
        }
        public override void HandleInput(GameTime gameTime, InputState input)
        {
            base.HandleInput(gameTime, input);

            PlayerIndex idx;
            if (input.IsButtonPressed(Microsoft.Xna.Framework.Input.Buttons.Start, ControllingPlayer, out idx))
            {
                OnCancel(idx);
            }
        }
        public override void HandleInput(Microsoft.Xna.Framework.GameTime gameTime, InputState input)
        {
            base.HandleInput(gameTime, input);

            PlayerIndex indx;
            if (exit.Evaluate(input, ControllingPlayer, out indx))
            {
                ExitScreen();
                SoundManager.Play("MenuCancel");
            }
        }
        public override void HandleInput(GameTime gameTime, InputState input)
        {
            base.HandleInput(gameTime, input);

            foreach (MenuEntry entry in initials)
            {
                if (input.MouseHoverIn(entry.ClickRectangle))
                {
                    selectedChar = Array.IndexOf(initials, entry);

                    char ch = entry.Text.ToCharArray()[0];
                    ch = (char)((int)ch + input.RelativeScrollValue);
                    entry.Text = ch.ToString();
                }
            }

            PlayerIndex index;

            if (up.Evaluate(input, ControllingPlayer, out index))
            {
                char ch = initials[selectedChar].Text.ToCharArray()[0];
                ch += (char)1;
                initials[selectedChar].Text = ch.ToString();
            }

            if (down.Evaluate(input, ControllingPlayer, out index))
            {
                char ch = initials[selectedChar].Text.ToCharArray()[0];
                ch -= (char)1;
                initials[selectedChar].Text = ch.ToString();
            }

            char c = initials[selectedChar].Text.ToCharArray()[0];

            int num = (int)c;

            if (num < 65)
                num = 90;

            if (num > 90)
                num = 65;

            c = (char)num;

            initials[selectedChar].Text = c.ToString();

            if (right.Evaluate(input, ControllingPlayer, out index))
            {
                selectedChar++;
            }

            if (left.Evaluate(input, ControllingPlayer, out index))
            {
                selectedChar--;
            }

            selectedChar = (int)MathHelper.Clamp((float)selectedChar, 0f, 2f);

            if (!expired && accept.Evaluate(input, ControllingPlayer, out index))
            {
                parent.Initials.Add(Initials);
                SetInitialsOf((PlayerIndex)ControllingPlayer, Initials);
                ExitScreen();
                expired = true;
            }
        }
        public override void HandleInput(GameTime gameTime, InputState input)
        {
            base.HandleInput(gameTime, input);

            PlayerIndex idx;
            if (cancelAction.Evaluate(input, null, out idx))
            {
                SoundManager.Play("MenuCancel");
                if (entered[(int)idx])
                {
                    indices.Remove(idx);
                    entered[(int)idx] = false;
                }
                else
                {
                    ExitScreen();
                    Manager.AddScreen(new MainMenuScreen("Space Hordes", false), null);
                }
            }

            if (Keyboard.GetState().IsKeyDown(Keys.Space))
            {
                Enter();
                return;
            }

            for (int x = 0; x < 4; ++x)
            {
                PlayerIndex indexx;
                idx = (PlayerIndex)x;
                if (entryAction.Evaluate(input, idx, out indexx))
                {
                    SoundManager.Play("Selection");
                    if (entered[x])
                    {
                        Enter();
                        return;
                    }
                    entered[x] = true;
                    indices.Add(idx);
                }
            }
        }
        public override void HandleInput(GameTime gameTime, InputState input)
        {
            PlayerIndex index;

            if (menuCancel.Evaluate(input, ControllingPlayer, out index))
            {
                ExitScreen();
                SoundManager.Play("MenuCancel");
            }

            if (left.Evaluate(input, ControllingPlayer, out index))
            {
                SoundManager.Play("SelectChanged");
                selectedScore = -1;
                Players--;
            }

            if (right.Evaluate(input, ControllingPlayer, out index))
            {
                SoundManager.Play("SelectChanged");
                selectedScore = -1;
                ++Players;
            }
        }
Пример #7
0
 /// <summary>
 /// Allows the screen to handle user input. Only called when
 /// this screen is active.
 /// </summary>
 /// <param name="gameTime"></param>
 /// <param name="input"></param>
 public virtual void HandleInput(GameTime gameTime, InputState input)
 {
 }
Пример #8
0
        public override void HandleInput(GameTime gameTime, InputState input)
        {
            base.HandleInput(gameTime, input);

            PlayerIndex idx;

            if (menuCancel.Evaluate(input, null, out idx))
            {
                ExitScreen();
                CallExit();

                if (!string.IsNullOrEmpty(cancelSound))
                {
                    SoundManager.Play(cancelSound);
                }
            }
        }
Пример #9
0
        /// <summary>
        /// Responds to user input, changing the selected entry and accepting or cancelling
        /// the menu.
        /// </summary>
        public override void HandleInput(GameTime gameTime, InputState input)
        {
            #if WINDOWS

            foreach (MenuEntry entry in MenuEntries)
            {
                if (input.MouseHoverIn(entry.ClickRectangle) && selectedEntry != MenuEntries.IndexOf(entry))
                {
                    selectedEntry = MenuEntries.IndexOf(entry);
                    if (!string.IsNullOrEmpty(selectionChangeSound))
                        SoundManager.Play(selectionChangeSound);
                }
                if (input.LeftButtonDownIn(entry.ClickRectangle) && prevMouseCheck())
                {
                    OnSelectEntry(selectedEntry, PlayerIndex.One);
                }
            }

            lastState = input.CurrentMouseState;
            #endif

            #if XBOX || WINDOWS

            PlayerIndex playerIndex;

            //Move to the previous menu entry?
            if (menuUp.Evaluate(input, ControllingPlayer, out playerIndex))
            {
                selectedEntry--;

                if (!string.IsNullOrEmpty(selectionChangeSound))
                    SoundManager.Play(selectionChangeSound);

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

            //Move to the next menu entry?
            if (menuDown.Evaluate(input, ControllingPlayer, out playerIndex))
            {
                selectedEntry++;

                if (!string.IsNullOrEmpty(selectionChangeSound))
                    SoundManager.Play(selectionChangeSound);

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

            if (menuSelect.Evaluate(input, ControllingPlayer, out playerIndex))
            {
                OnSelectEntry(selectedEntry, playerIndex);

                if (!string.IsNullOrEmpty(selectionSound))
                {
                    SoundManager.Play(selectionSound);
                }
            }

            else if (menuCancel.Evaluate(input, ControllingPlayer, out playerIndex))
            {
                OnCancel(playerIndex);

                if (!string.IsNullOrEmpty(cancelSound))
                {
                    SoundManager.Play(cancelSound);
                }
            }

            #endif
        }
Пример #10
0
        public override void HandleInput(GameTime gameTime, InputState input)
        {
            if (ScreenState == ScreenState.TransitionOff || ScreenState == ScreenState.TransitionOn)
                return;

            PlayerIndex indx;

            if (cancel.Evaluate(input, ControllingPlayer, out indx))
            {
                ExitScreen();
                CallExit();
                SoundManager.Play("MenuCancel");
            }
        }
Пример #11
0
        public override void HandleInput(GameTime gameTime, InputState input)
        {
            if (ScreenState == ScreenState.TransitionOff || ScreenState == ScreenState.TransitionOn)
                return;

            PlayerIndex indx;

            if (next.Evaluate(input, ControllingPlayer, out indx))
            {
                if (index != bosses.Count() - 1)
                {
                    SoundManager.Play("SelectChanged");
                    string key = bosses[index + 1].SpriteKey;
                    ExitScreen();
                    BossScreen newS = new BossScreen(spriteSheet);
                    newS.index = index + 1;
                    nextIndex = index + 1;
                    newS.lastIndex = index;
                    newS.currentKey = key;
                    newS.OnExit += MainMenuScreen.BossScreenExited;

#if XBOX
                    if (!StorageHelper.CheckStorage())
                    {
                        CallExit();
                        return;
                    }
#endif

                    Manager.AddScreen(newS, ControllingPlayer);
                }
            }

            if (previous.Evaluate(input, ControllingPlayer, out indx))
            {
                if (index != 0)
                {
                    SoundManager.Play("SelectChanged");
                    string key = bosses[index - 1].SpriteKey;
                    ExitScreen();
                    BossScreen newS = new BossScreen(spriteSheet);
                    newS.index = index - 1;
                    nextIndex = index - 1;
                    newS.lastIndex = index;
                    newS.currentKey = key;
                    newS.OnExit += MainMenuScreen.BossScreenExited;

#if XBOX
                    if (!StorageHelper.CheckStorage())
                    {
                        CallExit();
                        return;
                    }
#endif

                    Manager.AddScreen(newS, ControllingPlayer);
                }
            }

            if (cancel.Evaluate(input, ControllingPlayer, out indx))
            {
                ExitScreen();
                nextIndex = -1;
                CallExit();
                SoundManager.Play("MenuCancel");
            }
        }