示例#1
0
        private void HandleInventoryKeys(ResultSet resultSet)
        {
            if (RB.ButtonPressed(RB.BTN_SYSTEM))
            {
                resultSet.AddExit();
                return;
            }

            for (char i = 'a'; i <= 'z'; i++)
            {
                if (RB.KeyPressed((KeyCode)i))
                {
                    int index = (int)(i - 'a');
                    if (!mPlayer.isEmpty && mPlayer.e.inventory.items.Length > index && !mPlayer.e.inventory.items[index].isEmpty)
                    {
                        resultSet.AddInventoryIndex(mPlayer, index);
                        RB.SoundPlay(C.SOUND_SELECT_OPTION, 1, RandomUtils.RandomPitch(0.1f));
                        return;
                    }
                }
            }

            // Check if pointer clicked on any of the items
            if (RB.ButtonReleased(RB.BTN_POINTER_A))
            {
                int index = mMenuInventory.pointerIndex;
                if (index >= 0 && !mPlayer.isEmpty && mPlayer.e.inventory.items.Length > index && !mPlayer.e.inventory.items[index].isEmpty)
                {
                    resultSet.AddInventoryIndex(mPlayer, index);
                    RB.SoundPlay(C.SOUND_SELECT_OPTION, 1, RandomUtils.RandomPitch(0.1f));
                    return;
                }
            }
        }
示例#2
0
        private void HandleMenuKeys(ResultSet resultSet)
        {
            if (RB.ButtonPressed(RB.BTN_SYSTEM))
            {
                resultSet.AddExit();
                return;
            }

            // Check keyboard input
            for (char i = 'a'; i < 'a' + mMenuMain.optionCount; i++)
            {
                if (RB.KeyPressed((KeyCode)i))
                {
                    int index = (int)(i - 'a');
                    resultSet.AddMenuIndex(index);
                    RB.SoundPlay(C.SOUND_SELECT_OPTION, 1, RandomUtils.RandomPitch(0.1f));
                }
            }

            // Check mouse input
            if (RB.ButtonReleased(RB.BTN_POINTER_A))
            {
                int index = mMenuMain.pointerIndex;
                if (index >= 0)
                {
                    resultSet.AddMenuIndex(index);
                    RB.SoundPlay(C.SOUND_SELECT_OPTION, 1, RandomUtils.RandomPitch(0.1f));
                }
            }
        }
示例#3
0
        private void HandleMenuKeys(ResultSet resultSet)
        {
            var game = (RetroDungeoneerGame)RB.Game;

            if (RB.ButtonPressed(RB.BTN_SYSTEM))
            {
                resultSet.AddExit();
                return;
            }

            // Check keyboard input
            for (char i = 'a'; i < 'a' + mMenuMain.optionCount; i++)
            {
                if (RB.KeyPressed((KeyCode)i))
                {
                    int index = (int)(i - 'a');
                    resultSet.AddMenuIndex(index);
                    RB.SoundPlay(game.assets.soundSelectOption, 1, RandomUtils.RandomPitch(0.1f));
                }
            }

            // Check mouse input
            if (RB.ButtonReleased(RB.BTN_POINTER_A))
            {
                int index = mMenuMain.pointerIndex;
                if (index >= 0)
                {
                    resultSet.AddMenuIndex(index);
                    RB.SoundPlay(game.assets.soundSelectOption, 1, RandomUtils.RandomPitch(0.1f));
                }
            }
        }
示例#4
0
 private void HandleMenuKeys(ResultSet resultSet)
 {
     if (RB.ButtonPressed(RB.BTN_SYSTEM))
     {
         resultSet.AddExit();
         return;
     }
 }
示例#5
0
        private void HandleLevelUpKeys(ResultSet resultSet)
        {
            var game = (RetroDungeoneerGame)RB.Game;

            if (RB.ButtonPressed(RB.BTN_SYSTEM))
            {
                resultSet.AddExit();
                return;
            }

            int index = -1;

            for (char i = 'a'; i <= 'c'; i++)
            {
                if (RB.KeyPressed((KeyCode)i))
                {
                    index = (int)(i - 'a');
                    break;
                }
            }

            // Check if pointer clicked on any of the items
            if (RB.ButtonReleased(RB.BTN_POINTER_A))
            {
                if (mMenuInventory.pointerIndex >= 0 && mMenuInventory.pointerIndex <= 2)
                {
                    index = mMenuInventory.pointerIndex;
                }
            }

            LevelUp levelUp = LevelUp.None;

            if (index >= 0 && index <= 2)
            {
                switch (index)
                {
                case 0:
                    levelUp = LevelUp.Hp;
                    break;

                case 1:
                    levelUp = LevelUp.Str;
                    break;

                case 2:
                    levelUp = LevelUp.Def;
                    break;
                }

                resultSet.AddLevelUp(levelUp);

                RB.SoundPlay(game.assets.soundSelectOption, 1, RandomUtils.RandomPitch(0.1f));
            }
        }
示例#6
0
        private void HandlePlayerDeadKeys(ResultSet resultSet)
        {
            if (RB.ButtonPressed(RB.BTN_SYSTEM))
            {
                resultSet.AddExit();
                return;
            }

            if (RB.KeyPressed(KeyCode.P))
            {
                resultSet.AddShowCharacterScreen();
            }
        }
示例#7
0
        private void HandleTargetingKeys(ResultSet resultSet)
        {
            if (RB.ButtonPressed(RB.BTN_SYSTEM))
            {
                resultSet.AddExit();
                return;
            }

            if (RB.KeyPressed(KeyCode.F))
            {
                var ranged = mPlayer.e.equipment.equipment[(int)EquipmentSlot.Ranged];

                if (mGameState == GameState.TARGETING && mTargetingItem == ranged)
                {
                    // Already targeting, do a quick shot by injecting an invalid position which will make
                    // ShootBow() look for nearest enemy
                    resultSet.AddLeftClick(new Vector2i(-1, -1));
                }
            }
        }
        private void HandleMenuKeys(ResultSet resultSet)
        {
            if (!mShowingMessageBox)
            {
                return;
            }

            if (RB.ButtonPressed(RB.BTN_SYSTEM))
            {
                resultSet.AddExit();
                return;
            }

            // Check keyboard input
            for (char i = 'a'; i < 'a' + mMenuMessageBox.optionCount; i++)
            {
                if (RB.KeyPressed((KeyCode)i))
                {
                    int index = (int)(i - 'a');
                    if (mHandlers[index] != null)
                    {
                        mHandlers[index]();
                    }
                }
            }

            // Check mouse input
            if (RB.ButtonReleased(RB.BTN_POINTER_A))
            {
                int index = mMenuMessageBox.pointerIndex;
                if (index >= 0)
                {
                    if (mHandlers[index] != null)
                    {
                        mHandlers[index]();
                    }
                }
            }
        }
示例#9
0
        private void HandlePlayerTurnKeys(ResultSet resultSet)
        {
            // Check if we should block all player input until all keys are up
            // This is useful to block player input when exiting menus
            if (mBlockMoveUntilKeyUp)
            {
                if (!AnyPlayerKeyDown())
                {
                    mBlockMoveUntilKeyUp = false;
                }
                else
                {
                    return;
                }
            }

            if (RB.ButtonPressed(RB.BTN_SYSTEM))
            {
                resultSet.AddExit();
                return;
            }

            if (RB.KeyPressed(KeyCode.I))
            {
                resultSet.AddShowInventory();
            }

            if (RB.KeyPressed(KeyCode.O))
            {
                resultSet.AddDropInventory();
            }

            if (RB.KeyPressed(KeyCode.P))
            {
                resultSet.AddShowCharacterScreen();
            }

            if (RB.KeyPressed(KeyCode.Return) || RB.KeyPressed(KeyCode.KeypadEnter))
            {
                resultSet.AddTakeStairs();
            }

            if (RB.KeyPressed(KeyCode.H))
            {
                resultSet.AddShowHelp();
            }

            Vector2i delta = Vector2i.zero;

            if (RB.KeyDown(KeyCode.W) || RB.KeyDown(KeyCode.Keypad8))
            {
                delta.y--;
            }
            else if (RB.KeyDown(KeyCode.S) || RB.KeyDown(KeyCode.Keypad2))
            {
                delta.y++;
            }
            else if (RB.KeyDown(KeyCode.A) || RB.KeyDown(KeyCode.Keypad4))
            {
                delta.x--;
            }
            else if (RB.KeyDown(KeyCode.D) || RB.KeyDown(KeyCode.Keypad6))
            {
                delta.x++;
            }
            else if (RB.KeyDown(KeyCode.Q) || RB.KeyDown(KeyCode.Keypad7))
            {
                delta.x--;
                delta.y--;
            }
            else if (RB.KeyDown(KeyCode.E) || RB.KeyDown(KeyCode.Keypad9))
            {
                delta.x++;
                delta.y--;
            }
            else if (RB.KeyDown(KeyCode.Z) || RB.KeyDown(KeyCode.Keypad1))
            {
                delta.x--;
                delta.y++;
            }
            else if (RB.KeyDown(KeyCode.C) || RB.KeyDown(KeyCode.Keypad3))
            {
                delta.x++;
                delta.y++;
            }

            if (delta.x > 1)
            {
                delta.x = 1;
            }
            else if (delta.x < -1)
            {
                delta.x = -1;
            }

            if (delta.y > 1)
            {
                delta.y = 1;
            }
            else if (delta.y < -1)
            {
                delta.y = -1;
            }

            if (delta.x == 0 && delta.y == 0)
            {
                mKeyRepeatStage = 0;
            }
            else
            {
                var ticksDelta = RB.Ticks - mLastMoveTimestamp;

                if (mKeyRepeatStage == 0 || (mKeyRepeatStage == 1 && ticksDelta > C.KEY_REPEAT_SPEED_STAGE1) || (mKeyRepeatStage > 1 && ticksDelta > C.KEY_REPEAT_SPEED_STAGE2))
                {
                    if (delta.x != 0 || delta.y != 0)
                    {
                        mKeyRepeatStage++;
                        mLastMoveTimestamp = RB.Ticks;
                        resultSet.AddMove(delta);
                    }
                }
            }

            // Wait
            if (RB.KeyPressed(KeyCode.X) || RB.KeyPressed(KeyCode.Keypad5))
            {
                resultSet.AddMove(Vector2i.zero);
            }

            if (RB.KeyPressed(KeyCode.G) || RB.KeyPressed(KeyCode.Keypad0))
            {
                resultSet.AddPickup(mPlayer);
            }

            if (RB.KeyPressed(KeyCode.F))
            {
                var ranged = mPlayer.e.equipment.equipment[(int)EquipmentSlot.Ranged];
                var arrow  = mPlayer.e.inventory.GetArrow();
                if (!ranged.isEmpty && !arrow.isEmpty)
                {
                    resultSet.AddTargeting(ranged);
                }
                else
                {
                    if (ranged.isEmpty)
                    {
                        resultSet.AddMessage(C.FSTR.Set("You do not have a ranged weapon equipped."));
                    }
                    else if (arrow.isEmpty)
                    {
                        resultSet.AddMessage(C.FSTR.Set("You do not have an arrow to shoot."));
                    }
                }
            }
        }