示例#1
0
        protected override void HandHoverUpdate(Hand hand)
        {
            GrabTypes startingGrabType = hand.GetGrabStarting();
            BookIndex Book             = GetComponentInParent <BookIndex>();

            if (startingGrabType == GrabTypes.Grip)
            {
                if (Book.coverMapping.value < Book.lockThreshold || hand == Player.instance.rightHand)
                {
                    hand.AttachObject(gameObject, startingGrabType, attachmentFlags, attachmentOffset);
                    hand.HideGrabHint();
                }
            }
            else if (startingGrabType == GrabTypes.Pinch && hand == Player.instance.leftHand)
            {
                if (hand.LastCollider == Book.lowerBackHandle)
                {
                    hand.LastCollider = Book.backPageHandle.GetComponent <Collider>();
                    if (hand.LastCollider.GetComponent <PageHandle>().IsActive())
                    {
                        hand.LastCollider.GetComponentInParent <PageDrive>().SendMessage("HandHoverUpdate", hand);
                    }
                }
            }
        }
示例#2
0
 //-------------------------------------------------
 void OnDisable()
 {
     if (handHoverLocked)
     {
         handHoverLocked.HideGrabHint();
         handHoverLocked.HoverUnlock(interactable);
         handHoverLocked = null;
     }
 }
        //-------------------------------------------------
        private void OnHandHoverEnd(Hand hand)
        {
            if (!justPickedUpItem && requireGrabActionToTake && showTriggerHint)
            {
                hand.HideGrabHint();
            }

            justPickedUpItem = false;
        }
示例#4
0
        //-------------------------------------------------
        protected virtual void HandHoverUpdate(Hand hand)
        {
            GrabTypes startingGrabType = hand.GetGrabStarting();

            if (startingGrabType != GrabTypes.None && (canPickupWhileSmall || !sizeManager.isPlayerSmall()))
            {
                hand.AttachObject(gameObject, startingGrabType, attachmentFlags, attachmentOffset);
                hand.HideGrabHint();
            }
        }
示例#5
0
        /*
         * public void ManuallyDetatchThisObject(Hand hand ){
         *  lastUsedHand = hand;
         *  ManuallyDetatchThisObject();
         * }*/
/*
 *      void Update(){
 *          rigidbody.isKinematic = true;
 *      }
 */
        //-------------------------------------------------
        protected virtual void OnHandHoverEnd(Hand hand)
        {
            // if(autoLetGoIfAutoGrabbed && autoGrabObject){
            //     ManuallyDetatchThisObject(hand);
            // }
            if (hand != null)
            {
                hand.HideGrabHint();
            }
        }
示例#6
0
        //-------------------------------------------------
        protected virtual void HandHoverUpdate(Hand hand)
        {
            GrabTypes startingGrabType = hand.GetGrabStarting();

            if (startingGrabType != GrabTypes.None)
            {
                hand.AttachObject(gameObject, startingGrabType, attachmentFlags, attachmentOffset);
                hand.HideGrabHint();
            }
        }
示例#7
0
        protected override void HandHoverUpdate(Hand hand)
        {
            GrabTypes startingGrabType = hand.GetGrabStarting();

            if (startingGrabType != GrabTypes.None && !WasUsed)
            {
                hand.AttachObject(gameObject, startingGrabType, attachmentFlags, attachmentOffset);
                hand.HideGrabHint();
                WasUsed = true;
                GetComponent <Interactable>().highlightOnHover = false;
            }
        }
示例#8
0
        //-------------------------------------------------
        private void OnHandHoverEnd(Hand hand)
        {
            hand.HideGrabHint();

            if (driving && hand)
            {
                //hand.TriggerHapticPulse() //todo: fix
                StartCoroutine(HapticPulses(hand, 1.0f, 10));
            }
            driving         = false;
            handHoverLocked = null;
        }
示例#9
0
        //-------------------------------------------------
        protected virtual void HandHoverUpdate(Hand hand)
        {
            GrabTypes startingGrabType = GrabTypes.None;

            startingGrabType = hand.GetGrabStarting(GrabTypes.Grip);

            if (startingGrabType != GrabTypes.None && PlayerToolkit.selectedTool == SoundStone_ToolTypes.Handtool)
            {
                hand.AttachObject(gameObject, startingGrabType, attachmentFlags, attachmentOffset);
                hand.HideGrabHint();
            }
        }
        //-------------------------------------------------
        private void HandHoverUpdate(Hand hand)
        {
            GrabTypes startingGrabType = hand.GetGrabStarting();
            bool      isGrabEnding     = hand.IsGrabbingWithType(grabbedWithType) == false;

            if (grabbedWithType == GrabTypes.None && startingGrabType != GrabTypes.None)
            {
                grabbedWithType = startingGrabType;
                // Trigger was just pressed
                lastHandProjected = ComputeToTransformProjected(hand.hoverSphereTransform);

                if (hoverLock)
                {
                    hand.HoverLock(interactable);
                    handHoverLocked = hand;
                }

                driving = true;

                DriveBegin?.Invoke();

                ComputeAngle(hand);
                UpdateAll();

                hand.HideGrabHint();
            }
            else if (grabbedWithType != GrabTypes.None && isGrabEnding)
            {
                // Trigger was just released
                if (hoverLock)
                {
                    hand.HoverUnlock(interactable);
                    handHoverLocked = null;
                }

                driving = false;

                DriveEnd?.Invoke();

                grabbedWithType = GrabTypes.None;
            }

            if (driving && isGrabEnding == false && hand.hoveringInteractable == this.interactable)
            {
                ComputeAngle(hand);
                UpdateAll();
            }
        }
示例#11
0
        /** STEAMVR SYSTEM ROUTINES **/
        protected virtual void HandHoverUpdate(Hand hand)
        {
            // We want to handle potentially picking up a tower that has been placed at this node
            // Capture current grab information from the hand
            GrabTypes startingGrabType = hand.GetGrabStarting();

            // If the hand is grabbing and there is a tower here to be grabbed
            if (attachedTower != null && startingGrabType != GrabTypes.None && !da.isDived())
            {
                // Remove the tower and attach it to the hand
                TowerObject temp = attachedTower;
                RemoveTower();
                hand.AttachObject(temp.gameObject, startingGrabType, temp.attachmentFlags, temp.attachentOffset);
                hand.HideGrabHint();
            }
        }
示例#12
0
        //-------------------------------------------------
        protected virtual void HandHoverUpdate(Hand hand)
        {
            GrabTypes startingGrabType = hand.GetGrabStarting();

            if (startingGrabType != GrabTypes.None)
            {
                if (hand.handType == SteamVR_Input_Sources.RightHand)
                {
                    hand.AttachObject(gameObject, startingGrabType, attachmentFlags, attachmentOffset);
                }
                else
                {
                    hand.AttachObject(gameObject, startingGrabType, attachmentFlags, attachmentOffset2);
                }
                hand.HideGrabHint();
            }
        }
示例#13
0
        protected virtual void HandHoverUpdate(Hand hand)
        {
            // Capture current grab information from the hand
            GrabTypes startingGrabType = hand.GetGrabStarting();

            // Check if we are not currently attached and are being grabbed
            if (interactable.attachedToHand == null && startingGrabType != GrabTypes.None)
            {
                // Attach to the hand
                hand.AttachObject(gameObject, startingGrabType, attachmentFlags, attachentOffset);
                hand.HideGrabHint();
                if (crtRespawn != null)
                {
                    StopCoroutine(crtRespawn);
                }
            }
        }
        //-------------------------------------------------
        private void HandHoverUpdate(Hand hand)
        {
            GrabTypes startingGrabType = hand.GetGrabStarting();

            if (interactable.attachedToHand == null && startingGrabType != GrabTypes.None)
            {
                // Trigger was just pressed
                lastHandProjected = ComputeToTransformProjected(hand.hoverSphereTransform);

                if (hoverLock)
                {
                    hand.HoverLock(interactable);
                    handHoverLocked = hand;
                }

                driving = true;

                hand.AttachObject(gameObject, startingGrabType, attachmentFlags);
                hand.HideGrabHint();
            }
        }
示例#15
0
        //-------------------------------------------------
        private void HandHoverUpdate(Hand hand)
        {
            GrabTypes startingGrabType = hand.GetGrabStarting();
            bool      isGrabEnding     = hand.IsGrabEnding(this.gameObject);

            if (startingGrabType != GrabTypes.None)
            {
                // Trigger was just pressed
                lastHandProjected = ComputeToTransformProjected(hand.hoverSphereTransform);

                if (hoverLock)
                {
                    hand.HoverLock(interactable);
                    handHoverLocked = hand;
                }

                driving = true;

                ComputeAngle(hand);
                UpdateAll();

                hand.HideGrabHint();
            }

            if (isGrabEnding)
            {
                // Trigger was just released
                if (hoverLock)
                {
                    hand.HoverUnlock(interactable);
                    handHoverLocked = null;
                }
            }
            else if (driving && isGrabEnding == false && hand.hoveringInteractable == this.interactable)
            {
                ComputeAngle(hand);
                UpdateAll();
            }
        }
        protected override void HandHoverUpdate(Hand hand)
        {
            GrabTypes startingGrabType = hand.GetGrabStarting();

            if (startingGrabType != GrabTypes.None)
            {
                if (startingGrabType == GrabTypes.Pinch)
                {
                    hand.AttachObject(gameObject, startingGrabType, attachmentFlags, pinchOffset);
                }
                else if (startingGrabType == GrabTypes.Grip)
                {
                    hand.AttachObject(gameObject, startingGrabType, attachmentFlags, gripOffset);
                }
                else
                {
                    hand.AttachObject(gameObject, startingGrabType, attachmentFlags, attachmentOffset);
                }

                hand.HideGrabHint();
            }
        }
        protected override void HandHoverUpdate(Hand hand)
        {
            GameObject flashlight       = GameObject.Find("Light_flashlight");
            GrabTypes  startingGrabType = hand.GetGrabStarting();

            if (startingGrabType != GrabTypes.None)
            {
                if (startingGrabType == GrabTypes.Pinch)
                {
                    flashlight.GetComponent <Light>().enabled = true;
                    hand.AttachObject(gameObject, startingGrabType, attachmentFlags, pinchOffset);
                }
                //else if (startingGrabType == GrabTypes.Grip)
                //{
                //   hand.AttachObject(gameObject, startingGrabType, attachmentFlags, gripOffset);
                //}
                // else
                //{
                //    hand.AttachObject(gameObject, startingGrabType, attachmentFlags, attachmentOffset);
                // }
                hand.HideGrabHint();
            }
        }
示例#18
0
        //-------------------------------------------------
        private void HandHoverUpdate(Hand hand)
        {
            // ebaender
            worldPlaneNormal = new Vector3(0f, 0f, 0f);
            worldPlaneNormal[(int)axisOfRotation] = 1.0f;

            // ebaender
            if (transform.parent)
            {
                worldPlaneNormal = transform.parent.localToWorldMatrix.MultiplyVector(worldPlaneNormal).normalized;
            }

            GrabTypes startingGrabType = hand.GetGrabStarting();
            bool      isGrabEnding     = hand.IsGrabbingWithType(grabbedWithType) == false;

            currentCoverLimit = Book.coverMapping.value * Book.hingeMaxLimit;

            if (grabbedWithType == GrabTypes.None)
            {
                if (startingGrabType == GrabTypes.Pinch && hand == Player.instance.leftHand)
                {
                    grabbedWithType = startingGrabType;
                    // Trigger was just pressed
                    lastHandProjected = ComputeToTransformProjected(hand.hoverSphereTransform);

                    if (hoverLock)
                    {
                        hand.HoverLock(interactable);
                        handHoverLocked = hand;
                    }

                    driving = true;

                    ComputeSimpleAngle(hand);
                    UpdateAll();

                    hand.HideGrabHint();

                    // ebaender - attach hand
                    hand.AttachObject(gameObject, startingGrabType, attachmentFlags);
                }
                else if (startingGrabType == GrabTypes.Grip)
                {
                    if (hand == Player.instance.rightHand && hand.LastCollider.GetComponent <PageHandle>().handleType == PageHandle.Type.Back)
                    {
                        hand.LastCollider = Book.lowerBackHandle.GetComponent <Collider>();
                        hand.LastCollider.GetComponentInParent <BookThrowable>().SendMessage("HandHoverUpdate", hand);
                    }
                    else if (hand == Player.instance.leftHand && hand.LastCollider.GetComponent <PageHandle>().handleType == PageHandle.Type.Cover)
                    {
                        if (Book.pagePhysicsController.AttachedToBack)
                        {
                            hand.LastCollider = Book.lowerCoverHandle.GetComponent <Collider>();
                            hand.LastCollider.GetComponentInParent <CoverDrive>().SendMessage("HandHoverUpdate", hand);
                        }
                    }
                }
            }
            else if (grabbedWithType != GrabTypes.None && isGrabEnding)
            {
                // Trigger was just released
                if (hoverLock)
                {
                    hand.HoverUnlock(interactable);
                    handHoverLocked = null;
                }

                driving         = false;
                grabbedWithType = GrabTypes.None;

                // ebaender - detach hand
                hand.DetachObject(gameObject);
            }

            if (driving && isGrabEnding == false && hand.hoveringInteractable == this.interactable)
            {
                ComputeSimpleAngle(hand);
                UpdateAll();
            }
        }
示例#19
0
 //-------------------------------------------------
 protected virtual void OnHandHoverEnd(Hand hand)
 {
     hand.HideGrabHint();
 }
        //-------------------------------------------------
        private void SpawnAndAttachObject(Hand hand, GrabTypes grabType)
        {
            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)
            {
                hand.HideGrabHint();
            }

            if (itemPackage.otherHandItemPrefab != null)
            {
                if (hand.otherHand.hoverLocked)
                {
                    Debug.Log("<b>[SteamVR Interaction]</b> 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 = GameObject.Instantiate(itemPackage.itemPrefab);
            spawnedItem.SetActive(true);
            hand.AttachObject(spawnedItem, grabType, attachmentFlags);

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

            itemIsSpawned = true;

            justPickedUpItem = true;

            if (takeBackItem)
            {
                useFadedPreview = true;
                pickupEvent.Invoke();
                CreatePreviewObject();
            }
        }