void CheckForJump(bool movementEnabled)
 {
     if (moveScript.isGrounded && movementEnabled)
     {
         if (jumpAction.GetStateDown(moveHand))
         {
             Debug.LogError("jumped");
             if (!StandardizedVRInput.ActionOccupied(jumpAction, moveHand))
             {
                 moveScript.Jump();
             }
         }
     }
 }
Пример #2
0
        void Update()
        {
            SmoothTeleport(Time.deltaTime);

            bool teleportNewlyPressed = false;

            if (visible)
            {
                if (teleportAction.GetStateUp(teleportHand))

                {
                    TryTeleportPlayer();
                }
            }

            if (!GameManager.isPaused && teleportationAllowed)
            {
                if (!StandardizedVRInput.ActionOccupied(teleportAction, teleportHand) && teleportAction.GetStateDown(teleportHand))

                {
                    teleportNewlyPressed = true;
                }
            }


            if (!visible && teleportNewlyPressed)

            {
                //Begin showing the pointer
                ShowPointer( );
            }
            else if (visible)
            {
                if (!teleportNewlyPressed && !teleportAction.GetState(teleportHand))
                {
                    //Hide the pointer
                    HidePointer();
                }
            }

            if (visible)
            {
                UpdatePointer();

                if (meshFading)
                {
                    UpdateTeleportColors();
                }
            }
        }
        // set move velocity to zero every frame for instant stop
        // when not moving
        void HandleMoveInput(bool movementEnabled)
        {
            currentMoveVector = Vector2.zero;

            if (!movementEnabled)
            {
                isRunning = false;
                return;
            }
            currentMoveVector = StandardizedVRInput.ActionOccupied(moveAction, moveHand) ? Vector2.zero : moveAction.GetAxis(moveHand);

            if (currentMoveVector != Vector2.zero)
            {
                if (currentMoveVector.sqrMagnitude > 1)
                {
                    currentMoveVector.Normalize();
                }

                if (runMode != RunMode.None)
                {
                    bool runPossible = Vector2.Angle(currentMoveVector, new Vector2(0, 1)) <= runAngleThreshold;
                    if (!runPossible)
                    {
                        // we're used to walking forward, lateral and backwards/up down movement feels wrong
                        // so it's speed needs to be clamped to prevent motion sickness
                        isRunning = false;
                    }
                    else
                    {
                        if (runMode == RunMode.Held)
                        {
                            isRunning = runAction.GetState(moveHand);
                        }
                        else
                        {
                            if (runAction.GetStateDown(moveHand))
                            {
                                isRunning = true;
                            }
                        }
                    }
                }
                currentMoveVector = currentMoveVector * maxSpeed * (isRunning ? runMultiplier : 1);
            }
            // return currentMoveVector;
        }
Пример #4
0
        void OnInventoryUIClose(InventoryUI.UIType type, UIElementHolder uiHolder)
        {
            switch (type)
            {
            // quick inventory
            case InventoryUI.UIType.QuickInventory:
                StandardizedVRInput.MarkActionUnoccupied(QUICK_INVENTORY_CONSUME_ACTION);
                StandardizedVRInput.instance.HideHint(SteamVR_Input_Sources.Any, QUICK_INVENTORY_CONSUME_ACTION);
                break;

            // full inventory
            case InventoryUI.UIType.FullInventory:
                StandardizedVRInput.MarkActionUnoccupied(FULL_INVENTORY_CONSUME_ACTION);
                StandardizedVRInput.MarkActionUnoccupied(FULL_INVENTORY_DROP_ACTION);
                // StandardizedVRInput.MarkActionUnoccupied(FULL_INVENTORY_FAVORITE_ACTION);

                StandardizedVRInput.instance.HideHint(SteamVR_Input_Sources.Any, FULL_INVENTORY_CONSUME_ACTION);
                StandardizedVRInput.instance.HideHint(SteamVR_Input_Sources.Any, FULL_INVENTORY_DROP_ACTION);
                // StandardizedVRInput.instance.ShowHint(SteamVR_Input_Sources.Any, FULL_INVENTORY_FAVORITE_ACTION,);
                break;

            // quick trade
            case InventoryUI.UIType.QuickTrade:
                StandardizedVRInput.MarkActionUnoccupied(QUICK_TRADE_SINGLE_TRADE_ACTION);
                StandardizedVRInput.MarkActionUnoccupied(QUICK_TRADE_TRADE_ALL_ACTION);
                StandardizedVRInput.MarkActionUnoccupied(QUICK_TRADE_SWITCH_TO_FULL_TRADE_ACTION);

                StandardizedVRInput.instance.HideHint(SteamVR_Input_Sources.Any, QUICK_TRADE_SINGLE_TRADE_ACTION);
                StandardizedVRInput.instance.HideHint(SteamVR_Input_Sources.Any, QUICK_TRADE_TRADE_ALL_ACTION);
                StandardizedVRInput.instance.HideHint(SteamVR_Input_Sources.Any, QUICK_TRADE_SWITCH_TO_FULL_TRADE_ACTION);
                break;

            // full trade
            case InventoryUI.UIType.FullTrade:
                StandardizedVRInput.MarkActionUnoccupied(FULL_TRADE_CONSUME_ACTION);
                StandardizedVRInput.MarkActionUnoccupied(FULL_TRADE_TRADE_ALL_ACTION);
                StandardizedVRInput.MarkActionUnoccupied(FULL_TRADE_SINGLE_TRADE_ACTION);

                StandardizedVRInput.instance.HideHint(SteamVR_Input_Sources.Any, FULL_TRADE_CONSUME_ACTION);
                StandardizedVRInput.instance.HideHint(SteamVR_Input_Sources.Any, FULL_TRADE_SINGLE_TRADE_ACTION);
                StandardizedVRInput.instance.HideHint(SteamVR_Input_Sources.Any, FULL_TRADE_TRADE_ALL_ACTION);
                break;
            }
        }
        void CheckCrouched(float deltaTime)
        {
            if (!easyCrouch)
            {
                Player.instance.extraHeightOffset = 0;
                isCrouched = GetManualCrouching();
                return;
            }

            if (!GameManager.isPaused && !StandardizedVRInput.ActionOccupied(crouchAction, moveHand) && !Player.instance.handsTogether)
            {
                if (crouchAction.GetStateDown(moveHand))
                {
                    isCrouched = !isCrouched;
                }
            }

            HandleEasyCrouch(deltaTime);
        }
Пример #6
0
        void UpdateQuickInventory()
        {
            if (GameManager.isPaused)
            {
                return;
            }

            if (inventoryUI.IsOpen(InventoryUI.UIType.FullInventory))
            {
                return;
            }
            if (inventoryUI.IsOpen(InventoryUI.UIType.FullTrade))
            {
                return;
            }
            if (inventoryUI.IsOpen(InventoryUI.UIType.QuickInventory))
            {
                return;
            }



            if (Player.instance.handsTogether)
            {
                StandardizedVRInput.MarkActionOccupied(quickInventoryToggle, SteamVR_Input_Sources.Any);

                if (!CheckHandForWristRadialOpen(SteamVR_Input_Sources.LeftHand))
                {
                    CheckHandForWristRadialOpen(SteamVR_Input_Sources.RightHand);
                }
            }
            else
            {
                StandardizedVRInput.MarkActionUnoccupied(quickInventoryToggle);
            }
        }
Пример #7
0
        void OnInventoryUIOpen(InventoryUI.UIType type, UIElementHolder uiHolder)
        {
            SteamVR_Input_Sources hand;

            switch (type)
            {
            // quick inventory
            case InventoryUI.UIType.QuickInventory:
                hand = VRManager.Int2Hand(inventoryUI.quickInventoryInteractorID);

                StandardizedVRInput.MarkActionOccupied(QUICK_INVENTORY_CONSUME_ACTION, VRUIInput.GetUIHand());
                StandardizedVRInput.instance.ShowHint(hand, QUICK_INVENTORY_CONSUME_ACTION, "Use");

                TransformBehavior.AdjustTransform(uiHolder.baseObject.transform, Player.instance.GetHand(hand).transform, quickInventoryEquip, 0);

                VRUIInput.SetUIHand(hand);
                break;

            // full inventory
            case InventoryUI.UIType.FullInventory:
                StandardizedVRInput.MarkActionOccupied(FULL_INVENTORY_CONSUME_ACTION, SteamVR_Input_Sources.Any);
                StandardizedVRInput.MarkActionOccupied(FULL_INVENTORY_DROP_ACTION, SteamVR_Input_Sources.Any);
                // StandardizedVRInput.MarkActionOccupied(FULL_INVENTORY_FAVORITE_ACTION, SteamVR_Input_Sources.Any);

                StandardizedVRInput.instance.ShowHint(SteamVR_Input_Sources.RightHand, FULL_INVENTORY_CONSUME_ACTION, "Use Right Hand");
                StandardizedVRInput.instance.ShowHint(SteamVR_Input_Sources.LeftHand, FULL_INVENTORY_CONSUME_ACTION, "Use Left Hand");
                StandardizedVRInput.instance.ShowHint(SteamVR_Input_Sources.Any, FULL_INVENTORY_DROP_ACTION, "Drop");
                // StandardizedVRInput.instance.ShowHint(SteamVR_Input_Sources.Any, FULL_INVENTORY_FAVORITE_ACTION, "Favorite");

                VRUIInput.SetUIHand(SteamVR_Input_Sources.Any);
                break;

            // quick trade
            case InventoryUI.UIType.QuickTrade:
                hand = VRManager.Int2Hand(inventoryUI.quickTradeInteractorID);

                StandardizedVRInput.MarkActionOccupied(QUICK_TRADE_SINGLE_TRADE_ACTION, hand);
                StandardizedVRInput.MarkActionOccupied(QUICK_TRADE_TRADE_ALL_ACTION, hand);
                StandardizedVRInput.MarkActionOccupied(QUICK_TRADE_SWITCH_TO_FULL_TRADE_ACTION, hand);

                StandardizedVRInput.instance.ShowHint(hand, QUICK_TRADE_SINGLE_TRADE_ACTION, "Take Item");
                StandardizedVRInput.instance.ShowHint(hand, QUICK_TRADE_TRADE_ALL_ACTION, "Take All");
                StandardizedVRInput.instance.ShowHint(hand, QUICK_TRADE_SWITCH_TO_FULL_TRADE_ACTION, "Open Trade");

                TransformBehavior.AdjustTransform(uiHolder.baseObject.transform, Player.instance.GetHand(hand).transform, quickTradeEquip, 0);

                VRUIInput.SetUIHand(hand);

                break;

            // full trade
            case InventoryUI.UIType.FullTrade:

                StandardizedVRInput.MarkActionOccupied(FULL_TRADE_CONSUME_ACTION, SteamVR_Input_Sources.Any);
                StandardizedVRInput.MarkActionOccupied(FULL_TRADE_TRADE_ALL_ACTION, SteamVR_Input_Sources.Any);
                StandardizedVRInput.MarkActionOccupied(FULL_TRADE_SINGLE_TRADE_ACTION, SteamVR_Input_Sources.Any);

                StandardizedVRInput.instance.ShowHint(SteamVR_Input_Sources.RightHand, FULL_TRADE_CONSUME_ACTION, "Use Right Hand");
                StandardizedVRInput.instance.ShowHint(SteamVR_Input_Sources.LeftHand, FULL_TRADE_CONSUME_ACTION, "Use Left Hand");
                StandardizedVRInput.instance.ShowHint(SteamVR_Input_Sources.Any, FULL_TRADE_SINGLE_TRADE_ACTION, "Trade Item");
                StandardizedVRInput.instance.ShowHint(SteamVR_Input_Sources.Any, FULL_TRADE_TRADE_ALL_ACTION, "Trade All");

                VRUIInput.SetUIHand(SteamVR_Input_Sources.Any);
                break;
            }
        }