Example #1
0
        /// <summary>
        /// Update
        /// </summary>
        public override void Update()
        {
            base.Update();

            float c0 = Mathf.Sin(Time.time * 2) + 1.0f;

            c0 /= 2.0f;
            c0  = (c0 * (255 - 125)) + 125;

            if (!TransitionDone())
            {
                return;
            }

            if (RB.ButtonPressed(RB.BTN_ABXY, RB.PLAYER_ANY) || RB.ButtonPressed(RB.BTN_POINTER_ANY, RB.PLAYER_ANY))
            {
                SceneGame scene = new SceneGame();
                scene.Initialize();
                SuperFlagRun game = (SuperFlagRun)RB.Game;
                game.SwitchScene(scene);

                RB.SoundPlay(SuperFlagRun.SOUND_START_GAME);
            }

            mFlagOne.Update();
            mFlagTwo.Update();
        }
Example #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));
                }
            }
        }
Example #3
0
        /// <summary>
        /// Update
        /// </summary>
        public override void Update()
        {
            if (RB.ButtonPressed(RB.BTN_SYSTEM))
            {
                Application.Quit();
            }

            if (RB.ButtonPressed(RB.BTN_UP, RB.PLAYER_ANY))
            {
                StressUp();
            }
            else if (RB.ButtonPressed(RB.BTN_DOWN, RB.PLAYER_ANY))
            {
                StressDown();
            }

            var demo = (StressTest)RB.Game;

            if (RB.ButtonPressed(RB.BTN_LEFT, RB.PLAYER_ANY))
            {
                demo.PreviousScene();
            }
            else if (RB.ButtonPressed(RB.BTN_RIGHT, RB.PLAYER_ANY))
            {
                demo.NextScene();
            }

            for (int i = 0; i < mButtons.Count; i++)
            {
                mButtons[i].Update();
            }
        }
Example #4
0
 /**
  * Checks System Key Press
  */
 internal static void checkSystemInput()
 {
     if (RB.ButtonPressed(RB.BTN_SYSTEM))
     {
         Application.Quit();
     }
 }
Example #5
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));
                }
            }
        }
Example #6
0
        /// <summary>
        /// Update
        /// </summary>
        public override void Update()
        {
            DemoReel demo = (DemoReel)RB.Game;

            mShiftPressed = false;
            if (RB.KeyDown(KeyCode.LeftShift) || RB.KeyDown(KeyCode.RightShift) || mKeys["LeftShift"].WasPointerPressed || mKeys["RightShift"].WasPointerPressed)
            {
                mShiftPressed = true;
            }

            mNextButton.Update();
            mPrevButton.Update();

            ProcessStringInput(RB.InputString());

            int color = 1;

            if ((RB.Ticks % 200 > 170 && RB.Ticks % 200 < 180) || (RB.Ticks % 200) > 190)
            {
                color = 5;
            }

            mNextButton.LabelColor = color;
            mPrevButton.LabelColor = color;

            mScrollDelta = RB.PointerScrollDelta();

            mScrollDeltaAnim = Mathf.Lerp(mScrollDeltaAnim, mScrollDelta, 0.25f);

            if (RB.ButtonPressed(RB.BTN_SYSTEM))
            {
                Application.Quit();
            }
        }
Example #7
0
    public void Update()
    {
        mousePos = RB.PointerPos();
        if (currentScreen != null)
        {
            currentScreen.Update(message.Length == 0);
        }
        if (message.Length > 0)
        {
            if (RB.ButtonPressed(RB.BTN_POINTER_A))
            {
                message = "";
                if (onClickMessage != null)
                {
                    onClickMessage.Invoke();
                    onClickMessage = null;
                }
            }
        }
        HashSet <int> soundSet = new HashSet <int>();

        while (soundQueue.Count > 0)
        {
            soundSet.Add(soundQueue.Dequeue());
        }
        foreach (int sound in soundSet)
        {
            RB.SoundPlay(sound, volume);
        }
    }
Example #8
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;
                }
            }
        }
Example #9
0
        /// <summary>
        /// Update
        /// </summary>
        public void Update()
        {
            if (MUSIC_SYNC_ENABLED)
            {
                if (mCurrentTimeIndex == -1)
                {
                    mStartTime        = Time.time + 0.08f; // + scene flips later, - sooner
                    mNextTimeStop     = mNextSceneTime[0];
                    mCurrentTimeIndex = 0;
                }

                if (mCurrentTimeIndex < mNextSceneTime.Length)
                {
                    double curTime = Time.time - mStartTime;
                    if (curTime >= mNextTimeStop)
                    {
                        mCurrentTimeIndex++;
                        mNextTimeStop += mNextSceneTime[mCurrentTimeIndex];
                        NextScene();
                    }
                }
            }

            if (RB.ButtonPressed(RB.BTN_SYSTEM))
            {
                Application.Quit();
            }

            mScenes[mCurrentScene].Update();
        }
Example #10
0
 /// <summary>
 /// Update
 /// </summary>
 public void Update()
 {
     if (RB.ButtonPressed(RB.BTN_SYSTEM))
     {
         Application.Quit();
     }
 }
Example #11
0
 private void HandleMenuKeys(ResultSet resultSet)
 {
     if (RB.ButtonPressed(RB.BTN_SYSTEM))
     {
         resultSet.AddExit();
         return;
     }
 }
Example #12
0
        /// <summary>
        /// Update
        /// </summary>
        public void Update()
        {
            if (RB.ButtonPressed(RB.BTN_SYSTEM))
            {
                Application.Quit();
            }

            mScenes[mCurrentScene].Update();
        }
Example #13
0
        /// <summary>
        /// Update
        /// </summary>
        public override void Update()
        {
            var demo = (DemoReel)RB.Game;

            for (int i = mFadeSounds.Count - 1; i >= 0; i--)
            {
                var soundRef = mFadeSounds[i];
                RB.SoundVolumeSet(soundRef, RB.SoundVolumeGet(soundRef) * 0.75f);

                if (RB.SoundVolumeGet(soundRef) < 0.01f)
                {
                    mFadeSounds.RemoveAt(i);
                }
            }

            if (!demo.MusicPlaying())
            {
                mMusicTurnSpeed--;
                if (mMusicTurnSpeed < 0)
                {
                    mMusicTurnSpeed = 0;
                }
            }

            mMusicTicks += mMusicTurnSpeed;

            for (int i = 0; i < mPianoButtons.Length; i++)
            {
                mPianoButtons[i].Update();
            }

            for (int i = 0; i < mEffectButtons.Length; i++)
            {
                mEffectButtons[i].Update();
            }

            mMusicPlayButton.Update();

            mNextButton.Update();
            mPrevButton.Update();

            int color = 1;

            if ((RB.Ticks % 200 > 170 && RB.Ticks % 200 < 180) || (RB.Ticks % 200) > 190)
            {
                color = 5;
            }

            mNextButton.LabelColor = color;
            mPrevButton.LabelColor = color;

            if (RB.ButtonPressed(RB.BTN_SYSTEM))
            {
                Application.Quit();
            }
        }
Example #14
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));
            }
        }
Example #15
0
        /// <summary>
        /// Update
        /// </summary>
        public void Update()
        {
            if (RB.ButtonPressed(RB.BTN_POINTER_A))
            {
                var game = (BrickBustGame)RB.Game;
                game.ChangeState(BrickBustGame.GameState.LEVEL);
            }

            for (int i = 0; i < mBlobs.Count; i++)
            {
                mBlobs[i].Update();
            }
        }
Example #16
0
        private void HandlePlayerDeadKeys(ResultSet resultSet)
        {
            if (RB.ButtonPressed(RB.BTN_SYSTEM))
            {
                resultSet.AddExit();
                return;
            }

            if (RB.KeyPressed(KeyCode.P))
            {
                resultSet.AddShowCharacterScreen();
            }
        }
Example #17
0
        private void HandleMouse(ResultSet resultSet)
        {
            Vector2i tilePos = GetMouseTilePos();

            if (tilePos.x == -1)
            {
                return;
            }

            if (RB.ButtonPressed(RB.BTN_POINTER_A))
            {
                resultSet.AddLeftClick(tilePos);
            }
            else if (RB.ButtonPressed(RB.BTN_POINTER_B))
            {
                resultSet.AddRightClick(tilePos);
            }
        }
Example #18
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));
                }
            }
        }
Example #19
0
        /// <summary>
        /// Update, your game logic should live here. Update is called at a fixed interval of 60 times per second.
        /// </summary>
        public void Update()
        {
            if (RB.ButtonPressed(RB.BTN_SYSTEM))
            {
                Application.Quit();
            }

            if (mState == GameState.MAIN_MENU)
            {
                mMainMenu.Update();
            }
            else if (mState == GameState.LEVEL)
            {
                mLevel.Update();
            }

            RB.EffectSet(RB.Effect.Shake, mShake);
            mShake *= 0.85f;

            AnimateStateChange();
        }
        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]();
                    }
                }
            }
        }
        /// <summary>
        /// Update
        /// </summary>
        public void Update()
        {
            if (RB.ButtonPressed(RB.BTN_SYSTEM))
            {
                Application.Quit();
            }

            if (mCurrentScene != null)
            {
                mCurrentScene.Update();
            }

            if (mNextScene != null)
            {
                if (mCurrentScene.TransitionDone())
                {
                    mCurrentScene = mNextScene;
                    mCurrentScene.Enter();
                    mNextScene = null;
                }
            }
        }
Example #22
0
        /// <summary>
        /// Update
        /// </summary>
        public void Update()
        {
            bool doubleTapped = false;

            if (RB.ButtonPressed(RB.BTN_POINTER_A))
            {
                if (UnityEngine.Time.time - mLastTapTime < 0.5f)
                {
                    doubleTapped = true;
                }

                mLastTapTime = UnityEngine.Time.time;
            }

            if (!mShowHelp && !mShowGameOver && !mShowWin)
            {
                mInfoFade = Math.Max(0, mInfoFade - 8);
            }
            else if (mShowGameOver)
            {
                mInfoFade = Math.Min(255, mInfoFade + 8);

                if (doubleTapped)
                {
                    var game = (BrickBustGame)RB.Game;
                    game.ChangeState(BrickBustGame.GameState.MAIN_MENU);
                }
            }
            else if (mShowWin)
            {
                mInfoFade = Math.Min(255, mInfoFade + 8);

                if (doubleTapped)
                {
                    var game = (BrickBustGame)RB.Game;
                    game.ChangeState(BrickBustGame.GameState.LEVEL);
                }
            }
        }
Example #23
0
 public override void Update(bool hasFocus = true)
 {
     if (renderTargeting)
     {
         Rect2i   onRect     = new Rect2i(0, 0, 0, 0);
         UIObj    on         = null;
         Pawn     pawnTarget = null;
         Vector2i mouse      = RB.PointerPos();
         if ((mouse - lastMousePos).SqrMagnitude() > 2)
         {
             pawnSelectedByKey = -1;
         }
         for (int i = 0; i <= battle.allies.Length; i++)
         {
             if (RB.KeyPressed(KeyCode.Alpha1 + i))
             {
                 lastMousePos      = mouse;
                 pawnSelectedByKey = i;
             }
         }
         if (RB.KeyPressed(KeyCode.Escape) || RB.KeyPressed(KeyCode.Backspace))
         {
             pawnSelectedByKey = -1;
         }
         if (pawnSelectedByKey >= 0)
         {
             Pawn  p    = battle.GetPawn(pawnSelectedByKey);
             UIObj card = pawnCards[p];
             mouse      = card.pos + card.size / 2;
             on         = card;
             pawnTarget = p;
             onRect     = new Rect2i(on.pos, on.size);
         }
         foreach (KeyValuePair <Pawn, UIObj> cardPair in pawnCards)
         {
             onRect = new Rect2i(cardPair.Value.pos, cardPair.Value.size);
             if (onRect.Contains(mouse))
             {
                 on         = cardPair.Value;
                 pawnTarget = cardPair.Key;
                 break;
             }
         }
         if (on != null && pawnTarget != null)
         {
             if (pawnTarget != targetPawn)
             {
                 SetTooltip(targetSpell.GetShortDescription(battle.BuildContext(pawnTarget.GetId())));
             }
             targetPawn  = pawnTarget;
             targetPoint = new Vector2i(onRect.x + onRect.width, onRect.y + onRect.height / 2);
             targetRect  = new Rect2i(onRect.x - 1, onRect.y - 1, onRect.width + 1, onRect.height + 1);
             if (RB.ButtonPressed(RB.BTN_POINTER_A) || RB.KeyPressed(KeyCode.Return))
             {
                 Game.client.Send(GameMsg.CastSpell, new GameMsg.MsgCastSpell()
                 {
                     spellId = targetSpell.GetId(), targetId = targetPawn.GetId()
                 });
                 renderTargeting = false;
                 targetSpell     = null;
                 targetPawn      = null;
                 SetTooltip("");
             }
         }
         else
         {
             targetPawn = null;
             SetTooltip(targetSpell.GetShortDescription(battle.BuildContext(-1)));
             targetPoint = mouse;
             if (RB.ButtonPressed(RB.BTN_POINTER_ANY))
             {
                 renderTargeting = false;
                 targetSpell     = null;
             }
         }
     }
     else
     {
         base.Update(hasFocus);
     }
 }
Example #24
0
        /// <summary>
        /// Update
        /// </summary>
        public override void Update()
        {
            var demo = (DemoReel)RB.Game;

            for (int i = mFadeSounds.Count - 1; i >= 0; i--)
            {
                var soundRef = mFadeSounds[i];
                RB.SoundVolumeSet(soundRef, RB.SoundVolumeGet(soundRef) * 0.75f);

                if (RB.SoundVolumeGet(soundRef) < 0.01f)
                {
                    mFadeSounds.RemoveAt(i);
                }
            }

            if (!RB.MusicIsPlaying())
            {
                mMusicTurnSpeed--;
                if (mMusicTurnSpeed < 0)
                {
                    mMusicTurnSpeed = 0;
                }
            }

            mMusicTicks += mMusicTurnSpeed;

            for (int i = 0; i < mPianoButtons.Length; i++)
            {
                mPianoButtons[i].Update();
                if (mPianoButtons[i].Pressed)
                {
                    break;
                }
            }

            for (int i = 0; i < mEffectButtons.Length; i++)
            {
                mEffectButtons[i].Update();
                if (mEffectButtons[i].Pressed)
                {
                    break;
                }
            }

            mMusicPlayButton.Update();
            mPositionalButton.Update();

            mNextButton.Update();
            mPrevButton.Update();

            int color = 1;

            if ((RB.Ticks % 200 > 170 && RB.Ticks % 200 < 180) || (RB.Ticks % 200) > 190)
            {
                color = 5;
            }

            mNextButton.LabelColor = color;
            mPrevButton.LabelColor = color;

            if (RB.ButtonPressed(RB.BTN_SYSTEM))
            {
                Application.Quit();
            }

            mListenerPos = new Vector2i(330 + (Mathf.Sin(mPositionalTicks / 50.0f) * 100), (RB.DisplaySize.height / 2) + 32);

            if (mPositionalPlaying)
            {
                mSoundPos = RB.PointerPos();
                RB.SoundPosSet(mPosSoundRef, mSoundPos);
            }

            RB.SoundListenerPosSet(mListenerPos);

            var positionalVol = RB.SoundVolumeGet(mPosSoundRef);

            // Change music volume to inverse of waterfall volume
            if (demo.IsMusicPlaying())
            {
                RB.MusicVolumeSet((1.0f - positionalVol) * demo.MusicVolume());
            }

            if (mPositionalPlaying)
            {
                mPositionalTicks++;

                positionalVol += 0.05f;
                if (positionalVol > 1)
                {
                    positionalVol = 1;
                }

                RB.SoundVolumeSet(mPosSoundRef, positionalVol);
            }
            else
            {
                positionalVol -= 0.05f;
                if (positionalVol < 0)
                {
                    positionalVol = 0;
                }

                RB.SoundVolumeSet(mPosSoundRef, positionalVol);
            }

            UpdateMusicButtonLabel();
            UpdatePositionalButtonLabel();
        }
Example #25
0
    public virtual void Update(bool hasFocus = true)
    {
        Vector2i     mousePos = RB.PointerPos() + new Vector2i(0, 1);     // + 0, 1 is workaround for weird hovering behaviour?!
        UIObj        on       = null;
        List <UIObj> objsNoLongerUnderMouse = new List <UIObj>();

        foreach (UIObj obj in objUnderMouse)
        {
            if (!obj.IsInBounds(mousePos) || !obj.isVisible)
            {
                if (objUnderMouse.Contains(obj))
                {
                    objsNoLongerUnderMouse.Add(obj);
                    obj.OnMouseExit();
                    EventBus.UIMouseExit.Invoke(obj);
                }
            }
        }
        objUnderMouse.RemoveWhere((obj) => objsNoLongerUnderMouse.Contains(obj));
        List <UIObj> uiObjsToUpdate = uiObjs;

        if (currentMsgBox != null)
        {
            uiObjsToUpdate = currentMsgBox.GetUIObjs();
        }
        foreach (UIObj obj in uiObjsToUpdate)
        {
            if (obj.HasKeybind() && RB.KeyPressed(obj.GetKeybind()))
            {
                if (obj.IsInteractable)
                {
                    EventBus.UIClick.Invoke(obj);
                    obj.OnClick();
                }
            }
            if (obj.IsInBounds(mousePos) && obj.isVisible)
            {
                if (!objUnderMouse.Contains(obj))
                {
                    objUnderMouse.Add(obj);
                    obj.OnMouseEnter();
                    EventBus.UIMouseEnter.Invoke(obj);
                }
            }
            if (obj.IsInBounds(mousePos) && obj.IsInteractable)             // && hasFocus) {
            {
                if (obj.currentState != UIObj.State.Hovered)
                {
                    EventBus.UIHoverStart.Invoke(obj);
                }
                obj.currentState = UIObj.State.Hovered;
                on = obj;
            }
            else
            if (obj.currentState != UIObj.State.Disabled)
            {
                if (obj.currentState == UIObj.State.Hovered)
                {
                    EventBus.UIHoverEnd.Invoke(obj);
                }
                obj.currentState = UIObj.State.Enabled;
            }

            obj.Update();
        }
        if (RB.ButtonPressed(RB.BTN_POINTER_A) && hasFocus)
        {
            if (on != null)
            {
                on.currentState = UIObj.State.Pressed;
                mousePressedOn  = on;
                SetFocus(on);
            }
            else
            {
                SetFocus(null);
            }
        }
        else
        if (RB.ButtonReleased(RB.BTN_POINTER_A))
        {
            if (on == mousePressedOn && on != null)
            {
                if (on.currentState == UIObj.State.Hovered)
                {
                    EventBus.UIClick.Invoke(on);
                }
                mousePressedOn.OnClick();
            }
            mousePressedOn = null;
        }
        else
        if (RB.ButtonDown(RB.BTN_POINTER_A) && hasFocus)
        {
            if (mousePressedOn != null && on == mousePressedOn)
            {
                mousePressedOn.currentState = UIObj.State.Pressed;
            }
            else
            if (on != null)
            {
                on.currentState = UIObj.State.Enabled;
            }
        }
    }
Example #26
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."));
                    }
                }
            }
        }
Example #27
0
        /// <summary>
        /// Update
        /// </summary>
        public override void Update()
        {
            base.Update();

            if (RB.ButtonDown(RB.BTN_POINTER_A))
            {
                if (mDragging)
                {
                    int dragDelta = RB.PointerPos().x - mPrevPointerPos.x;
                    mPos.x += dragDelta;

                    Rect.x = mPos.x - (Rect.width / 2);

                    int minMargin = RB.SpriteSize(0).width / 2;
                    if (Rect.x < minMargin)
                    {
                        Rect.x = minMargin;
                    }
                    else if (Rect.x + Rect.width > RB.DisplaySize.width - minMargin)
                    {
                        Rect.x = RB.DisplaySize.width - minMargin - Rect.width;
                    }
                }

                mPrevPointerPos = RB.PointerPos();
                mDragging       = true;
            }
            else
            {
                mDragging = false;
            }

            if (mExtended)
            {
                if (Rect.width < mExtendedRect.width)
                {
                    Rect.x--;
                    Rect.width += 2;
                }
            }
            else
            {
                if (Rect.width > mBaseRect.width)
                {
                    Rect.x++;
                    Rect.width -= 2;
                }
            }

            if (mLaser)
            {
                mLaserOffset -= 0.1f;
                if (mLaserOffset < 0)
                {
                    mLaserOffset = 0;
                }

                if (RB.ButtonPressed(RB.BTN_POINTER_A))
                {
                    Shoot();
                }
            }
            else
            {
                mLaserOffset += 0.1f;
                if (mLaserOffset > 1)
                {
                    mLaserOffset = 1;
                }
            }

            // Rest mPos after collision rect corrections
            mPos = new Vector2i((int)Rect.center.x, (int)Rect.center.y);
        }
Example #28
0
        /// <summary>
        /// Update
        /// </summary>
        public override void Update()
        {
            base.Update();

            // Animate fade-in
            mAlpha = Math.Min(255, mAlpha + 10);

            bool doubleTap = false;

            if (RB.ButtonPressed(RB.BTN_POINTER_A))
            {
                if (Time.time - mLastTapTime < 0.5f)
                {
                    doubleTap = true;
                }

                mLastTapTime = Time.time;
            }

            // If the ball is stuck to the paddle then snap its position to the middle of the paddle
            if (StuckToPaddle)
            {
                var game       = (BrickBustGame)RB.Game;
                var paddleRect = game.Level.Paddle.Rect;

                Rect.x = (int)paddleRect.center.x - (Rect.width / 2);
                Rect.y = paddleRect.y - (Global.BALL_HEIGHT / 2);
                mPos.x = Rect.x;
                mPos.y = Rect.y;

                // Release the paddle on double tap
                if (doubleTap)
                {
                    StuckToPaddle = false;
                    game.Level.Hud.HideHelp();
                }
            }
            else
            {
                // Break up the velocity into increments that are at maximum quarter the size of the ball, this will prevent the ball from
                // jumping entirely across bricks/paddle if it's moving fast. If there is a collision then break out out of the loop.
                float distanceLeft = mCurrentSpeed;
                float increment    = Math.Min(Global.BALL_HEIGHT / 4.0f, Global.BALL_WIDTH / 4.0f);

                while (distanceLeft > 0)
                {
                    mPos  += mDir * Math.Min(increment, distanceLeft);
                    Rect.x = (int)mPos.x;
                    Rect.y = (int)mPos.y;

                    if (DoPhysics())
                    {
                        break;
                    }

                    distanceLeft -= increment;
                }

                CheckDeath();
            }

            // Animate ball speed
            if (mCurrentSpeed < mSpeed)
            {
                mCurrentSpeed += 0.1f;
                if (mCurrentSpeed > mSpeed)
                {
                    mCurrentSpeed = mSpeed;
                }
            }
            else if (mCurrentSpeed > mSpeed)
            {
                mCurrentSpeed -= 0.1f;
                if (mCurrentSpeed < mSpeed)
                {
                    mCurrentSpeed = mSpeed;
                }
            }
        }
Example #29
0
        /// <summary>
        /// Update, handles switching to next scene, and quitting the demo
        /// </summary>
        public virtual void Update()
        {
            var demo = (StressTest)RB.Game;

            if (RB.KeyPressed(KeyCode.Return) || (UnityEngine.Input.mousePresent && RB.ButtonPressed(RB.BTN_POINTER_A)) || RB.ButtonPressed(RB.BTN_A))
            {
                demo.NextScene();
            }

            if ((UnityEngine.Input.mousePresent && RB.ButtonPressed(RB.BTN_POINTER_B)) || RB.ButtonPressed(RB.BTN_X))
            {
                demo.PreviousScene();
            }

            if (RB.ButtonPressed(RB.BTN_SYSTEM))
            {
                Application.Quit();
            }

            if (!UnityEngine.Input.mousePresent)
            {
                if (RB.ButtonReleased(RB.BTN_POINTER_A, RB.PLAYER_ANY))
                {
                    mTouchTimestamp[0] = (long)RB.Ticks;
                }

                if (RB.ButtonReleased(RB.BTN_POINTER_B, RB.PLAYER_ANY))
                {
                    mTouchTimestamp[1] = (long)RB.Ticks;
                }

                if (RB.ButtonReleased(RB.BTN_POINTER_C, RB.PLAYER_ANY))
                {
                    mTouchTimestamp[2] = (long)RB.Ticks;
                }

                if (RB.ButtonReleased(RB.BTN_POINTER_D, RB.PLAYER_ANY))
                {
                    mTouchTimestamp[3] = (long)RB.Ticks;
                }

                // If all fingers are up then check how many fingers have close timestamps
                if (!RB.ButtonDown(RB.BTN_POINTER_A, RB.PLAYER_ANY) &&
                    !RB.ButtonDown(RB.BTN_POINTER_B, RB.PLAYER_ANY) &&
                    !RB.ButtonDown(RB.BTN_POINTER_C, RB.PLAYER_ANY) &&
                    !RB.ButtonDown(RB.BTN_POINTER_D, RB.PLAYER_ANY))
                {
                    int fingerCount = 0;
                    for (int i = 0; i < 4; i++)
                    {
                        long delta = (long)RB.Ticks - (long)mTouchTimestamp[i];
                        if (delta >= 0 && delta < 5)
                        {
                            fingerCount++;
                        }
                    }

                    if (fingerCount == 1)
                    {
                        for (int i = 0; i < 4; i++)
                        {
                            mTouchTimestamp[i] = long.MaxValue;
                        }

                        demo.NextScene();
                    }
                    else if (fingerCount > 1)
                    {
                        for (int i = 0; i < 4; i++)
                        {
                            mTouchTimestamp[i] = long.MaxValue;
                        }

                        demo.PreviousScene();
                    }
                }
            }
        }