コード例 #1
0
        private void ButtonControls(GameTime gameTime)
        {
            if (ControlManager.CheckPress(RebindableKeys.Up))
            {
                buttonIndex--;
                holdTimer = Game.HoldKeyTreshold;

                PlayHoverSound();
            }

            else if (ControlManager.CheckHold(RebindableKeys.Up))
            {
                holdTimer -= gameTime.ElapsedGameTime.Milliseconds;

                if (holdTimer <= 0)
                {
                    buttonIndex--;
                    holdTimer = Game.ScrollSpeedSlow;

                    PlayHoverSound();
                }
            }

            else if (ControlManager.CheckPress(RebindableKeys.Down))
            {
                buttonIndex++;
                holdTimer = Game.HoldKeyTreshold;

                PlayHoverSound();
            }

            else if (ControlManager.CheckHold(RebindableKeys.Down))
            {
                holdTimer -= gameTime.ElapsedGameTime.Milliseconds;

                if (holdTimer <= 0)
                {
                    buttonIndex++;
                    holdTimer = Game.ScrollSpeedSlow;

                    PlayHoverSound();
                }
            }

            if (buttonIndex > buttons.Count - 1)
            {
                if (ControlManager.PreviousKeyUp(RebindableKeys.Down))
                {
                    buttonIndex = 0;
                }
                else
                {
                    buttonIndex = buttons.Count - 1;
                }
            }

            else if (buttonIndex < 0)
            {
                if (ControlManager.PreviousKeyUp(RebindableKeys.Up))
                {
                    buttonIndex = buttons.Count - 1;
                }
                else
                {
                    buttonIndex = 0;
                }
            }

            activeButton = buttons[buttonIndex];

            foreach (MenuDisplayObject button in buttons)
            {
                button.isActive = false;
            }

            activeButton.isActive = true;

            if (ControlManager.CheckPress(RebindableKeys.Action1) ||
                ControlManager.CheckKeyPress(Keys.Enter))
            {
                ButtonActions();
            }

            // TODO: REMOVE FOR RELEASE VERSION
            //if (ControlManager.CheckKeyPress(Keys.M))
            //{
            //    Game.stateManager.ChangeState("LevelTesterState");
            //}

            if (ControlManager.CheckKeyHold(Keys.LeftAlt) &&
                ControlManager.CheckKeyPress(Keys.C))
            {
                Game.stateManager.ChangeState("CampaignState");
            }
        }