示例#1
0
        //-------------------------------------------------
        public void CancelTeleportHint()
        {
            if (hintCoroutine != null)
            {
                foreach (Hand hand in player.hands)
                {
                    ControllerButtonHints.HideTextHint(hand, EVRButtonId.k_EButton_SteamVR_Touchpad);
                }

                StopCoroutine(hintCoroutine);
                hintCoroutine = null;
            }

            CancelInvoke("ShowTeleportHint");
        }
示例#2
0
        // Token: 0x0600220A RID: 8714 RVA: 0x000A92F3 File Offset: 0x000A74F3
        private IEnumerator TeleportHintCoroutine()
        {
            float prevBreakTime       = Time.time;
            float prevHapticPulseTime = Time.time;

            for (;;)
            {
                bool pulsed = false;
                foreach (Hand hand in this.player.hands)
                {
                    bool flag  = this.IsEligibleForTeleport(hand);
                    bool flag2 = !string.IsNullOrEmpty(ControllerButtonHints.GetActiveHintText(hand, EVRButtonId.k_EButton_Axis0));
                    if (flag)
                    {
                        if (!flag2)
                        {
                            ControllerButtonHints.ShowTextHint(hand, EVRButtonId.k_EButton_Axis0, "Teleport", true);
                            prevBreakTime       = Time.time;
                            prevHapticPulseTime = Time.time;
                        }
                        if (Time.time > prevHapticPulseTime + 0.05f)
                        {
                            pulsed = true;
                            hand.controller.TriggerHapticPulse(500, EVRButtonId.k_EButton_Axis0);
                        }
                    }
                    else if (!flag && flag2)
                    {
                        ControllerButtonHints.HideTextHint(hand, EVRButtonId.k_EButton_Axis0);
                    }
                }
                if (Time.time > prevBreakTime + 3f)
                {
                    yield return(new WaitForSeconds(3f));

                    prevBreakTime = Time.time;
                }
                if (pulsed)
                {
                    prevHapticPulseTime = Time.time;
                }
                yield return(null);
            }
            yield break;
        }
示例#3
0
 // Token: 0x060020B8 RID: 8376 RVA: 0x000A167C File Offset: 0x0009F87C
 private void SpawnAndAttachObject(Hand hand)
 {
     if (hand.otherHand != null && this.GetAttachedItemPackage(hand.otherHand) == this.itemPackage)
     {
         this.TakeBackItem(hand.otherHand);
     }
     if (this.showTriggerHint)
     {
         ControllerButtonHints.HideTextHint(hand, EVRButtonId.k_EButton_Axis1);
     }
     if (this.itemPackage.otherHandItemPrefab != null && hand.otherHand.hoverLocked)
     {
         return;
     }
     if (this.itemPackage.packageType == ItemPackage.ItemPackageType.OneHanded)
     {
         this.RemoveMatchingItemTypesFromHand(ItemPackage.ItemPackageType.OneHanded, hand);
         this.RemoveMatchingItemTypesFromHand(ItemPackage.ItemPackageType.TwoHanded, hand);
         this.RemoveMatchingItemTypesFromHand(ItemPackage.ItemPackageType.TwoHanded, hand.otherHand);
     }
     if (this.itemPackage.packageType == ItemPackage.ItemPackageType.TwoHanded)
     {
         this.RemoveMatchingItemTypesFromHand(ItemPackage.ItemPackageType.OneHanded, hand);
         this.RemoveMatchingItemTypesFromHand(ItemPackage.ItemPackageType.OneHanded, hand.otherHand);
         this.RemoveMatchingItemTypesFromHand(ItemPackage.ItemPackageType.TwoHanded, hand);
         this.RemoveMatchingItemTypesFromHand(ItemPackage.ItemPackageType.TwoHanded, hand.otherHand);
     }
     this.spawnedItem = Object.Instantiate <GameObject>(this.itemPackage.itemPrefab);
     this.spawnedItem.SetActive(true);
     hand.AttachObject(this.spawnedItem, this.attachmentFlags, this.attachmentPoint);
     if (this.itemPackage.otherHandItemPrefab != null && hand.otherHand.controller != null)
     {
         GameObject gameObject = Object.Instantiate <GameObject>(this.itemPackage.otherHandItemPrefab);
         gameObject.SetActive(true);
         hand.otherHand.AttachObject(gameObject, this.attachmentFlags, "");
     }
     this.itemIsSpawned    = true;
     this.justPickedUpItem = true;
     if (this.takeBackItem)
     {
         this.useFadedPreview = true;
         this.pickupEvent.Invoke();
         this.CreatePreviewObject();
     }
 }
示例#4
0
        //-------------------------------------------------
        public void CancelTeleportHint()
        {
            if (hintCoroutine != null)
            {
                Hand hand = player.rightHand;
                //foreach ( Hand hand in player.hands )
                //{
                ControllerButtonHints.HideTextHint(hand, EVRButtonId.k_EButton_SteamVR_Touchpad);
                // ControllerButtonHints.HideTextHint(hand, EVRButtonId.k_EButton_ApplicationMenu);

                //}

                StopCoroutine(hintCoroutine);
                hintCoroutine = null;
            }

            CancelInvoke("ShowTeleportHint");
        }
        //-------------------------------------------------
        private void SpawnAndAttachObject(Hand hand)
        {
            if (hand.otherHand != null)
            {
                //If the other hand has this item package, take it back from the other hand
                ItemPackage otherHandItemPackage = GetAttachedItemPackage(hand.otherHand);
                if (otherHandItemPackage == itemPackage)
                {
                    TakeBackItem(hand.otherHand);
                }
            }

            if (showTriggerHint)
            {
                ControllerButtonHints.HideTextHint(hand, EVRButtonId.k_EButton_SteamVR_Trigger);
            }

            if (itemPackage.otherHandItemPrefab != null)
            {
                if (hand.otherHand.hoverLocked)
                {
                    //Debug.Log( "Not attaching objects because other hand is hoverlocked and we can't deliver both items." );
                    return;
                }
            }

            // if we're trying to spawn a one-handed item, remove one and two-handed items from this hand and two-handed items from both hands
            if (itemPackage.packageType == ItemPackage.ItemPackageType.OneHanded)
            {
                RemoveMatchingItemTypesFromHand(ItemPackage.ItemPackageType.OneHanded, hand);
                RemoveMatchingItemTypesFromHand(ItemPackage.ItemPackageType.TwoHanded, hand);
                RemoveMatchingItemTypesFromHand(ItemPackage.ItemPackageType.TwoHanded, hand.otherHand);
            }

            // if we're trying to spawn a two-handed item, remove one and two-handed items from both hands
            if (itemPackage.packageType == ItemPackage.ItemPackageType.TwoHanded)
            {
                RemoveMatchingItemTypesFromHand(ItemPackage.ItemPackageType.OneHanded, hand);
                RemoveMatchingItemTypesFromHand(ItemPackage.ItemPackageType.OneHanded, hand.otherHand);
                RemoveMatchingItemTypesFromHand(ItemPackage.ItemPackageType.TwoHanded, hand);
                RemoveMatchingItemTypesFromHand(ItemPackage.ItemPackageType.TwoHanded, hand.otherHand);
            }

            spawnedItem = Instantiate(itemPackage.itemPrefab);
            spawnedItem.SetActive(true);
            hand.AttachObject(spawnedItem, attachmentFlags, attachmentPoint);

            if ((itemPackage.otherHandItemPrefab != null) && (hand.otherHand.controller != null))
            {
                GameObject otherHandObjectToAttach = Instantiate(itemPackage.otherHandItemPrefab);
                otherHandObjectToAttach.SetActive(true);
                hand.otherHand.AttachObject(otherHandObjectToAttach, attachmentFlags);
            }

            itemIsSpawned = true;

            justPickedUpItem = true;

            if (takeBackItem)
            {
                useFadedPreview = true;
                pickupEvent.Invoke();
                CreatePreviewObject();
            }
        }
示例#6
0
        //-------------------------------------------------
        private IEnumerator TeleportHintCoroutine()
        {
            float prevBreakTime       = Time.time;
            float prevHapticPulseTime = Time.time;

            while (true)
            {
                bool pulsed = false;

                //Show the hint on each eligible hand
                foreach (Hand hand in player.hands)
                {
                    if (uic.GetCurrentHand() == hand)
                    {
                        continue;
                    }
                    bool showHint          = IsEligibleForTeleport(hand);
                    bool isShowingHint     = !string.IsNullOrEmpty(ControllerButtonHints.GetActiveHintText(hand, EVRButtonId.k_EButton_SteamVR_Touchpad));
                    bool isShowingHintMenu = !string.IsNullOrEmpty(ControllerButtonHints.GetActiveHintText(hand, EVRButtonId.k_EButton_ApplicationMenu));
                    if (showHint)
                    {
                        if (!isShowingHint)
                        {
                            if (!uic.IsShowing())
                            {
                                ControllerButtonHints.ShowTextHint(hand, EVRButtonId.k_EButton_ApplicationMenu, "Menu");
                            }
                            ControllerButtonHints.ShowTextHint(hand, EVRButtonId.k_EButton_SteamVR_Touchpad, "Teleport");
                            prevBreakTime       = Time.time;
                            prevHapticPulseTime = Time.time;
                        }

                        if (Time.time > prevHapticPulseTime + 0.05f)
                        {
                            //Haptic pulse for a few seconds
                            pulsed = true;

                            // hand.controller.TriggerHapticPulse( 500 );
                        }
                    }
                    else if (!showHint && isShowingHint)
                    {
                        if (isShowingHintMenu)
                        {
                            ControllerButtonHints.HideTextHint(hand, EVRButtonId.k_EButton_ApplicationMenu);
                        }
                        ControllerButtonHints.HideTextHint(hand, EVRButtonId.k_EButton_SteamVR_Touchpad);
                    }
                }

                if (Time.time > prevBreakTime + 3.0f)
                {
                    //Take a break for a few seconds
                    yield return(new WaitForSeconds(3.0f));

                    prevBreakTime = Time.time;
                }

                if (pulsed)
                {
                    prevHapticPulseTime = Time.time;
                }

                yield return(null);
            }
        }
        //-------------------------------------------------
        private IEnumerator TeleportHintCoroutine()
        {
            float prevBreakTime       = Time.time;
            float prevHapticPulseTime = Time.time;

            while (true)
            {
                bool pulsed = false;
                foreach (Hand hand in player.hands)
                {
                    if (hand == player.hands[0])
                    {
                        bool showHint      = IsEligibleForTeleport(player.hands[0]);
                        bool isShowingHint = !string.IsNullOrEmpty(ControllerButtonHints.GetActiveHintText(player.hands[0], EVRButtonId.k_EButton_SteamVR_Touchpad));
                        if (showHint)
                        {
                            if (!isShowingHint)
                            {
                                ControllerButtonHints.ShowTextHint(player.hands[0], EVRButtonId.k_EButton_SteamVR_Touchpad, "Teleport");
                                prevBreakTime       = Time.time;
                                prevHapticPulseTime = Time.time;
                            }

                            if (Time.time > prevHapticPulseTime + 0.05f)
                            {
                                //Haptic pulse for a few seconds
                                pulsed = true;
                                player.hands[0].controller.TriggerHapticPulse(500);
                            }
                        }
                        else if (!showHint && isShowingHint)
                        {
                            ControllerButtonHints.HideTextHint(player.hands[0], EVRButtonId.k_EButton_SteamVR_Touchpad);
                        }
                    }
                    if (hand == player.hands[1])
                    {
                        bool showHint      = true;
                        bool isShowingHint = !string.IsNullOrEmpty(ControllerButtonHints.GetActiveHintText(player.hands[1], EVRButtonId.k_EButton_SteamVR_Touchpad));
                        if (showHint)
                        {
                            if (!isShowingHint)
                            {
                                ControllerButtonHints.ShowTextHint(player.hands[1], EVRButtonId.k_EButton_SteamVR_Touchpad, "Play/Pause\nReverse      Forward\nReset");
                                prevBreakTime       = Time.time;
                                prevHapticPulseTime = Time.time;
                            }

                            if (Time.time > prevHapticPulseTime + 0.05f)
                            {
                                //Haptic pulse for a few seconds
                                pulsed = true;
                                player.hands[1].controller.TriggerHapticPulse(500);
                            }
                        }
                        else if (!showHint && isShowingHint)
                        {
                            ControllerButtonHints.HideTextHint(player.hands[1], EVRButtonId.k_EButton_SteamVR_Touchpad);
                        }
                    }
                }
                if (Time.time > prevBreakTime + 3.0f)
                {
                    //Take a break for a few seconds
                    yield return(new WaitForSeconds(3.0f));

                    prevBreakTime = Time.time;
                }

                if (pulsed)
                {
                    prevHapticPulseTime = Time.time;
                }

                yield return(null);
            }
        }