コード例 #1
0
ファイル: DebugMenu.cs プロジェクト: radtek/ZeldaOracle
        //=========== UPDATING ===========
        #region Updating

        /** <summary> Updates the debug menu while it's open. </summary> */
        public void Update()
        {
            if (Mouse.IsMouseMoved())
            {
                if (Mouse.GetDistance().Length > 2.0 && mouseHoverItem != null)
                {
                    controlMode = MenuControlMode.Mouse;
                }
            }

            if (Keyboard.IsKeyPressed(Keys.Left) ||
                Keyboard.IsKeyPressed(Keys.Right) ||
                Keyboard.IsKeyPressed(Keys.Up) ||
                Keyboard.IsKeyPressed(Keys.Down) ||
                Keyboard.IsKeyPressed(Keys.X) ||
                Keyboard.IsKeyPressed(Keys.Z) ||
                Keyboard.IsKeyPressed(Keys.Space) ||
                Keyboard.IsKeyPressed(Keys.Enter) ||
                Keyboard.IsKeyPressed(Keys.Escape))
            {
                controlMode = MenuControlMode.Keyboard;
            }
            else if (GamePad.IsButtonPressed(Buttons.DPadLeft) ||
                     GamePad.IsButtonPressed(Buttons.DPadRight) ||
                     GamePad.IsButtonPressed(Buttons.DPadUp) ||
                     GamePad.IsButtonPressed(Buttons.DPadDown) ||
                     GamePad.IsButtonPressed(Buttons.LeftStickLeft) ||
                     GamePad.IsButtonPressed(Buttons.LeftStickRight) ||
                     GamePad.IsButtonPressed(Buttons.LeftStickUp) ||
                     GamePad.IsButtonPressed(Buttons.LeftStickDown) ||
                     GamePad.IsButtonPressed(Buttons.A) ||
                     GamePad.IsButtonPressed(Buttons.B) ||
                     GamePad.IsButtonPressed(Buttons.Start) ||
                     GamePad.IsButtonPressed(Buttons.Back) ||
                     GamePad.IsButtonPressed(Buttons.Y))
            {
                controlMode = MenuControlMode.GamePad;
            }

            if (controlMode == MenuControlMode.Mouse)
            {
                UpdateMouseControls();
            }
            else if (controlMode == MenuControlMode.Keyboard)
            {
                UpdateKeyboardControls();
            }
            else
            {
                UpdateGamePadControls();
            }
        }
コード例 #2
0
ファイル: Button.cs プロジェクト: radtek/ZeldaOracle
 public override bool Pressed()
 {
     return(GamePad.IsButtonPressed(ButtonCode, Player));
 }
コード例 #3
0
ファイル: DebugMenu.cs プロジェクト: radtek/ZeldaOracle
        /** <summary> Updates the debug menu with gamepad controls. </summary> */
        private void UpdateGamePadControls()
        {
            /*Keys keyNextItem = Keys.Down;
            *  Keys keyPrevItem = Keys.Up;
            *  Keys keyStepInto = Keys.Right;
            *  Keys keyStepOut  = Keys.Left;*/

            Buttons buttonNextItem  = Buttons.DPadDown;
            Buttons buttonNextItem2 = Buttons.LeftStickDown;
            Buttons buttonPrevItem  = Buttons.DPadUp;
            Buttons buttonPrevItem2 = Buttons.LeftStickUp;
            Buttons buttonStepInto  = Buttons.DPadRight;
            Buttons buttonStepInto2 = Buttons.LeftStickRight;
            Buttons buttonStepOut   = Buttons.DPadLeft;
            Buttons buttonStepOut2  = Buttons.LeftStickLeft;

            if (currentItem.Root.Root == null)
            {
                /*keyNextItem = Keys.Right;
                 * keyPrevItem = Keys.Left;
                 * keyStepInto = Keys.Down;
                 * keyStepOut  = Keys.Up;*/
                buttonNextItem  = Buttons.DPadRight;
                buttonNextItem2 = Buttons.LeftStickRight;
                buttonPrevItem  = Buttons.DPadLeft;
                buttonPrevItem2 = Buttons.LeftStickLeft;
                buttonStepInto  = Buttons.DPadDown;
                buttonStepInto2 = Buttons.LeftStickDown;
                buttonStepOut   = Buttons.DPadUp;
                buttonStepOut2  = Buttons.LeftStickUp;
            }

            // Select next root menu item.
            if ((GamePad.IsButtonPressed(Buttons.DPadRight) || GamePad.IsButtonPressed(Buttons.LeftStickRight)) && currentItem.Items.Count == 0 && CurrentMenu != menu)
            {
                int index = currentPath[0];
                currentItem = menu.Items[index];
                currentPath.Clear();
                currentPath.Add(index);
                SelectNextItem();
                StepIntoSubMenu();
            }

            // Step into a sub-menu.
            else if (GamePad.IsButtonPressed(buttonStepInto) || GamePad.IsButtonPressed(buttonStepInto2))
            {
                StepIntoSubMenu();
            }

            // Select previous root menu item.
            if ((GamePad.IsButtonPressed(Buttons.DPadLeft) || GamePad.IsButtonPressed(Buttons.LeftStickLeft)) && CurrentMenu.Root == menu)
            {
                currentItem = CurrentMenu;
                currentPath.RemoveAt(currentPath.Count - 1);
                SelectPreviousItem();
                StepIntoSubMenu();
            }
            // Step out of a sub-menu.
            else if (GamePad.IsButtonPressed(buttonStepOut) || GamePad.IsButtonPressed(buttonStepOut2))
            {
                StepOutOfSubMenu();
            }

            // Select next item.
            if (GamePad.IsButtonPressed(buttonNextItem) || GamePad.IsButtonPressed(buttonNextItem2))
            {
                SelectNextItem();
            }

            // Select previous item.
            if (GamePad.IsButtonPressed(buttonPrevItem) || GamePad.IsButtonPressed(buttonPrevItem2))
            {
                SelectPreviousItem();
            }

            // Step out of a sub-menu.
            if (GamePad.IsButtonPressed(Buttons.B) || GamePad.IsButtonPressed(Buttons.Back))
            {
                StepOutOfSubMenu();
            }

            // Press item.
            if (GamePad.IsButtonPressed(Buttons.A) || GamePad.IsButtonPressed(Buttons.Start) || GamePad.IsButtonPressed(Buttons.Y))
            {
                if (currentItem.Items.Count == 0)
                {
                    currentItem.Press();
                    if (!GamePad.IsButtonPressed(Buttons.Y))
                    {
                        Close();
                    }
                }
                else
                {
                    StepIntoSubMenu();
                }
            }
        }
コード例 #4
0
ファイル: GameManager.cs プロジェクト: radtek/ZeldaOracle
        //-----------------------------------------------------------------------------
        // Updating
        //-----------------------------------------------------------------------------

        // Called every step to update the game.
        public void Update(float timeDelta)
        {
            //prop.Update(1.0 / 60.0, new Point2I(ScreenSize.X - Property<int>.Width, ScreenSize.Y / 2));

            //if (Keyboard.IsKeyPressed(Keys.F4))
            //	GameBase.IsFullScreen = !GameBase.IsFullScreen;

            // Update the menu
            Controls.Update();

            // Toggle debug mode
            if (Keyboard.IsKeyPressed(Keys.F2) || (GamePad.IsButtonDown(Buttons.Back) && GamePad.IsButtonPressed(Buttons.RightStickButton)))
            {
                debugMode = !debugMode;
            }

            // Update the game-state stack.
            if (!isGamePaused)
            {
                gameStateStack.Update();
            }

            elapsedTicks++;

            // DEBUG: Update debug keys.
            GameDebug.GameControl = gameControl;
            GameDebug.UpdateRoomDebugKeys();
        }