//-------------------------------------------------
        private void HighlightSelected(TeleportMarkerBase hitTeleportMarker)
        {
            if (pointedAtTeleportMarker != hitTeleportMarker)               //Pointing at a new teleport marker
            {
                if (pointedAtTeleportMarker != null)
                {
                    pointedAtTeleportMarker.Highlight(false);
                }

                if (hitTeleportMarker != null)
                {
                    hitTeleportMarker.Highlight(true);

                    prevPointedAtPosition = pointedAtPosition;
                    PlayPointerHaptic(!hitTeleportMarker.locked);

                    PlayAudioClip(reticleAudioSource, goodHighlightSound);

                    loopingAudioSource.volume = loopingAudioMaxVolume;
                }
                else if (pointedAtTeleportMarker != null)
                {
                    PlayAudioClip(reticleAudioSource, badHighlightSound);

                    loopingAudioSource.volume = 0.0f;
                }
            }
            else if (hitTeleportMarker != null)               //Pointing at the same teleport marker
            {
                if (Vector3.Distance(prevPointedAtPosition, pointedAtPosition) > 1.0f)
                {
                    prevPointedAtPosition = pointedAtPosition;
                    PlayPointerHaptic(!hitTeleportMarker.locked);
                }
            }
        }
Esempio n. 2
0
        public void TryTeleportPlayerToGodPosition()
        {
            //if (visible && !teleporting)
            //{

            //Pointing at an unlocked teleport marker
            teleportingToMarker     = godPosition;
            pointedAtTeleportMarker = godPosition;
            pointedAtPosition       = godPosition.transform.position;
            globalScaleOnTeleport   = globalScaleOnTeleportToMeta;

            lhand.Deactivate_sword();
            rhand.Deactivate_sword();
            rhand.DetachObject(rhand.currentAttachedObject);
            lhand.DetachObject(lhand.currentAttachedObject);

            if (godPosition.facingDirection != null)
            {
                player.trackingOriginTransform.rotation = godPosition.facingDirection.rotation;
            }

            InitiateTeleportFade();
            CancelTeleportHint();
        }
        //-------------------------------------------------
        private void ShowPointer(Hand newPointerHand, Hand oldPointerHand)
        {
            if (!visible)
            {
                pointedAtTeleportMarker = null;
                pointerShowStartTime    = Time.time;
                visible    = true;
                meshFading = true;

                teleportPointerObject.SetActive(false);
                teleportArc.Show();

                foreach (TeleportMarkerBase teleportMarker in teleportMarkers)
                {
                    if (teleportMarker.markerActive && teleportMarker.ShouldActivate(player.feetPositionGuess))
                    {
                        teleportMarker.gameObject.SetActive(true);
                        teleportMarker.Highlight(false);
                    }
                }

                startingFeetOffset = player.trackingOriginTransform.position - player.feetPositionGuess;
                movedFeetFarEnough = false;

                if (onDeactivateObjectTransform.gameObject.activeSelf)
                {
                    onDeactivateObjectTransform.gameObject.SetActive(false);
                }
                onActivateObjectTransform.gameObject.SetActive(true);

                loopingAudioSource.clip = pointerLoopSound;
                loopingAudioSource.loop = true;
                loopingAudioSource.Play();
                loopingAudioSource.volume = 0.0f;
            }


            if (oldPointerHand)
            {
                if (ShouldOverrideHoverLock())
                {
                    //Restore the original hovering interactable on the hand
                    if (originalHoverLockState == true)
                    {
                        oldPointerHand.HoverLock(originalHoveringInteractable);
                    }
                    else
                    {
                        oldPointerHand.HoverUnlock(null);
                    }
                }
            }

            pointerHand = newPointerHand;

            if (visible && oldPointerHand != pointerHand)
            {
                PlayAudioClip(pointerAudioSource, pointerStartSound);
            }

            if (pointerHand)
            {
                pointerStartTransform = GetPointerStartTransform(pointerHand);

                if (pointerHand.currentAttachedObject != null)
                {
                    allowTeleportWhileAttached = pointerHand.currentAttachedObject.GetComponent <AllowTeleportWhileAttachedToHand>();
                }

                //Keep track of any existing hovering interactable on the hand
                originalHoverLockState       = pointerHand.hoverLocked;
                originalHoveringInteractable = pointerHand.hoveringInteractable;

                if (ShouldOverrideHoverLock())
                {
                    pointerHand.HoverLock(null);
                }

                pointerAudioSource.transform.SetParent(pointerStartTransform);
                pointerAudioSource.transform.localPosition = Vector3.zero;

                loopingAudioSource.transform.SetParent(pointerStartTransform);
                loopingAudioSource.transform.localPosition = Vector3.zero;
            }
        }
        //-------------------------------------------------
        private void UpdatePointer()
        {
            Vector3 pointerStart = pointerStartTransform.position;
            Vector3 pointerEnd;
            Vector3 pointerDir          = pointerStartTransform.forward;
            bool    hitSomething        = false;
            bool    showPlayAreaPreview = false;
            Vector3 playerFeetOffset    = player.trackingOriginTransform.position - player.feetPositionGuess;

            Vector3 arcVelocity = pointerDir * arcDistance;

            TeleportMarkerBase hitTeleportMarker = null;

            //Check pointer angle
            float dotUp             = Vector3.Dot(pointerDir, Vector3.up);
            float dotForward        = Vector3.Dot(pointerDir, player.hmdTransform.forward);
            bool  pointerAtBadAngle = false;

            if ((dotForward > 0 && dotUp > 0.75f) || (dotForward < 0.0f && dotUp > 0.5f))
            {
                pointerAtBadAngle = true;
            }

            //Trace to see if the pointer hit anything
            RaycastHit hitInfo;

            teleportArc.SetArcData(pointerStart, arcVelocity, true, pointerAtBadAngle);
            if (teleportArc.DrawArc(out hitInfo))
            {
                hitSomething      = true;
                hitTeleportMarker = hitInfo.collider.GetComponentInParent <TeleportMarkerBase>();
            }

            if (pointerAtBadAngle)
            {
                hitTeleportMarker = null;
            }

            HighlightSelected(hitTeleportMarker);

            if (hitTeleportMarker != null)               //Hit a teleport marker
            {
                if (hitTeleportMarker.locked)
                {
                    teleportArc.SetColor(pointerLockedColor);
#if (UNITY_5_4)
                    pointerLineRenderer.SetColors(pointerLockedColor, pointerLockedColor);
#else
                    pointerLineRenderer.startColor = pointerLockedColor;
                    pointerLineRenderer.endColor   = pointerLockedColor;
#endif
                    destinationReticleTransform.gameObject.SetActive(false);
                }
                else
                {
                    teleportArc.SetColor(pointerValidColor);
#if (UNITY_5_4)
                    pointerLineRenderer.SetColors(pointerValidColor, pointerValidColor);
#else
                    pointerLineRenderer.startColor = pointerValidColor;
                    pointerLineRenderer.endColor   = pointerValidColor;
#endif
                    destinationReticleTransform.gameObject.SetActive(hitTeleportMarker.showReticle);
                }

                offsetReticleTransform.gameObject.SetActive(true);

                invalidReticleTransform.gameObject.SetActive(false);

                pointedAtTeleportMarker = hitTeleportMarker;
                pointedAtPosition       = hitInfo.point;

                if (showPlayAreaMarker)
                {
                    //Show the play area marker if this is a teleport area
                    TeleportArea teleportArea = pointedAtTeleportMarker as TeleportArea;
                    if (teleportArea != null && !teleportArea.locked && playAreaPreviewTransform != null)
                    {
                        Vector3 offsetToUse = playerFeetOffset;

                        //Adjust the actual offset to prevent the play area marker from moving too much
                        if (!movedFeetFarEnough)
                        {
                            float distanceFromStartingOffset = Vector3.Distance(playerFeetOffset, startingFeetOffset);
                            if (distanceFromStartingOffset < 0.1f)
                            {
                                offsetToUse = startingFeetOffset;
                            }
                            else if (distanceFromStartingOffset < 0.4f)
                            {
                                offsetToUse = Vector3.Lerp(startingFeetOffset, playerFeetOffset, (distanceFromStartingOffset - 0.1f) / 0.3f);
                            }
                            else
                            {
                                movedFeetFarEnough = true;
                            }
                        }

                        playAreaPreviewTransform.position = pointedAtPosition + offsetToUse;

                        showPlayAreaPreview = true;
                    }
                }

                pointerEnd = hitInfo.point;
            }
            else             //Hit neither
            {
                destinationReticleTransform.gameObject.SetActive(false);
                offsetReticleTransform.gameObject.SetActive(false);

                teleportArc.SetColor(pointerInvalidColor);
#if (UNITY_5_4)
                pointerLineRenderer.SetColors(pointerInvalidColor, pointerInvalidColor);
#else
                pointerLineRenderer.startColor = pointerInvalidColor;
                pointerLineRenderer.endColor   = pointerInvalidColor;
#endif
                invalidReticleTransform.gameObject.SetActive(!pointerAtBadAngle);

                //Orient the invalid reticle to the normal of the trace hit point
                Vector3 normalToUse = hitInfo.normal;
                float   angle       = Vector3.Angle(hitInfo.normal, Vector3.up);
                if (angle < 15.0f)
                {
                    normalToUse = Vector3.up;
                }
                invalidReticleTargetRotation     = Quaternion.FromToRotation(Vector3.up, normalToUse);
                invalidReticleTransform.rotation = Quaternion.Slerp(invalidReticleTransform.rotation, invalidReticleTargetRotation, 0.1f);

                //Scale the invalid reticle based on the distance from the player
                float distanceFromPlayer         = Vector3.Distance(hitInfo.point, player.hmdTransform.position);
                float invalidReticleCurrentScale = Util.RemapNumberClamped(distanceFromPlayer, invalidReticleMinScaleDistance, invalidReticleMaxScaleDistance, invalidReticleMinScale, invalidReticleMaxScale);
                invalidReticleScale.x = invalidReticleCurrentScale;
                invalidReticleScale.y = invalidReticleCurrentScale;
                invalidReticleScale.z = invalidReticleCurrentScale;
                invalidReticleTransform.transform.localScale = invalidReticleScale;

                pointedAtTeleportMarker = null;

                if (hitSomething)
                {
                    pointerEnd = hitInfo.point;
                }
                else
                {
                    pointerEnd = teleportArc.GetArcPositionAtTime(teleportArc.arcDuration);
                }

                //Debug floor
                if (debugFloor)
                {
                    floorDebugSphere.gameObject.SetActive(false);
                    floorDebugLine.gameObject.SetActive(false);
                }
            }

            if (playAreaPreviewTransform != null)
            {
                playAreaPreviewTransform.gameObject.SetActive(showPlayAreaPreview);
            }

            if (!showOffsetReticle)
            {
                offsetReticleTransform.gameObject.SetActive(false);
            }

            destinationReticleTransform.position = pointedAtPosition;
            invalidReticleTransform.position     = pointerEnd;
            onActivateObjectTransform.position   = pointerEnd;
            onDeactivateObjectTransform.position = pointerEnd;
            offsetReticleTransform.position      = pointerEnd - playerFeetOffset;

            reticleAudioSource.transform.position = pointedAtPosition;

            pointerLineRenderer.SetPosition(0, pointerStart);
            pointerLineRenderer.SetPosition(1, pointerEnd);
        }
Esempio n. 5
0
        void UpdatePointer()
        {
            Vector3 pointerStart = player.rightHand.transform.position;
            Vector3 pointerDir   = player.rightHand.transform.forward;

            Vector3 playerFeetOffset = player.transform.position - player.feetPositionGuess;

            bool hitSomething = false;

            Vector3 arcVelocity = pointerDir * arcDistance;

            TeleportMarkerBase hitTeleportMarker = null;

            bool pointerAtBadAngle = PointerAtBadAngle(pointerDir);

            //Trace to see if the pointer hit anything
            teleportArc.SetArcData(pointerStart, arcVelocity, true, pointerAtBadAngle);

            RaycastHit hit;
            Vector3    hit_point = Vector3.zero;

            if (teleportArc.DrawArc(out hit, traceLayerMask))
            {
                hitSomething      = true;
                hitTeleportMarker = hit.collider.GetComponentInParent <TeleportMarkerBase>();
            }

            HighlightSelected(pointerAtBadAngle ? null : hitTeleportMarker);

            if (pointerAtBadAngle)
            {
                teleportArc.SetColor(pointerInvalidColor);
            }
            else
            {
                if (hitTeleportMarker != null)
                {
                    if (hitTeleportMarker.locked)
                    {
                        SetArcColor(pointerLockedColor);
                    }
                    else
                    {
                        SetArcColor(pointerValidColor);
                    }
                }
                else
                {
                    //check validity of position
                    SetArcColor(pointerValidColor);
                }
            }

            if (hitTeleportMarker != null)               //Hit a teleport marker
            {
                potential_teleport_point = hitTeleportMarker.transform.position;
                potential_teleport_valid = !pointerAtBadAngle && !hitTeleportMarker.locked;
            }
            else             //Hit neither
            {
                potential_teleport_point = hitSomething ? hit.point : teleportArc.GetArcPositionAtTime(teleportArc.arcDuration);
                potential_teleport_valid = !pointerAtBadAngle;
            }

            SetReticleActive(pointerAtBadAngle, potential_teleport_point, hitTeleportMarker != null);

            pointerLineRenderer.SetPosition(0, pointerStart);
            pointerLineRenderer.SetPosition(1, potential_teleport_point);
        }
Esempio n. 6
0
        // Token: 0x060021FC RID: 8700 RVA: 0x000A7F0C File Offset: 0x000A610C
        private void UpdatePointer()
        {
            Vector3            position           = this.pointerStartTransform.position;
            Vector3            forward            = this.pointerStartTransform.forward;
            bool               flag               = false;
            bool               active             = false;
            Vector3            vector             = this.player.trackingOriginTransform.position - this.player.feetPositionGuess;
            Vector3            velocity           = forward * this.arcDistance;
            TeleportMarkerBase teleportMarkerBase = null;
            float              num   = Vector3.Dot(forward, Vector3.up);
            float              num2  = Vector3.Dot(forward, this.player.hmdTransform.forward);
            bool               flag2 = false;

            if ((num2 > 0f && num > 0.75f) || (num2 < 0f && num > 0.5f))
            {
                flag2 = true;
            }
            this.teleportArc.SetArcData(position, velocity, true, flag2);
            RaycastHit raycastHit;

            if (this.teleportArc.DrawArc(out raycastHit))
            {
                flag = true;
                teleportMarkerBase = raycastHit.collider.GetComponentInParent <TeleportMarkerBase>();
            }
            if (flag2)
            {
                teleportMarkerBase = null;
            }
            this.HighlightSelected(teleportMarkerBase);
            Vector3 vector2;

            if (teleportMarkerBase != null)
            {
                if (teleportMarkerBase.locked)
                {
                    this.teleportArc.SetColor(this.pointerLockedColor);
                    this.pointerLineRenderer.startColor = this.pointerLockedColor;
                    this.pointerLineRenderer.endColor   = this.pointerLockedColor;
                    this.destinationReticleTransform.gameObject.SetActive(false);
                }
                else
                {
                    this.teleportArc.SetColor(this.pointerValidColor);
                    this.pointerLineRenderer.startColor = this.pointerValidColor;
                    this.pointerLineRenderer.endColor   = this.pointerValidColor;
                    this.destinationReticleTransform.gameObject.SetActive(teleportMarkerBase.showReticle);
                }
                this.offsetReticleTransform.gameObject.SetActive(true);
                this.invalidReticleTransform.gameObject.SetActive(false);
                this.pointedAtTeleportMarker = teleportMarkerBase;
                this.pointedAtPosition       = raycastHit.point;
                if (this.showPlayAreaMarker)
                {
                    TeleportArea teleportArea = this.pointedAtTeleportMarker as TeleportArea;
                    if (teleportArea != null && !teleportArea.locked && this.playAreaPreviewTransform != null)
                    {
                        Vector3 b = vector;
                        if (!this.movedFeetFarEnough)
                        {
                            float num3 = Vector3.Distance(vector, this.startingFeetOffset);
                            if (num3 < 0.1f)
                            {
                                b = this.startingFeetOffset;
                            }
                            else if (num3 < 0.4f)
                            {
                                b = Vector3.Lerp(this.startingFeetOffset, vector, (num3 - 0.1f) / 0.3f);
                            }
                            else
                            {
                                this.movedFeetFarEnough = true;
                            }
                        }
                        this.playAreaPreviewTransform.position = this.pointedAtPosition + b;
                        active = true;
                    }
                }
                vector2 = raycastHit.point;
            }
            else
            {
                this.destinationReticleTransform.gameObject.SetActive(false);
                this.offsetReticleTransform.gameObject.SetActive(false);
                this.teleportArc.SetColor(this.pointerInvalidColor);
                this.pointerLineRenderer.startColor = this.pointerInvalidColor;
                this.pointerLineRenderer.endColor   = this.pointerInvalidColor;
                this.invalidReticleTransform.gameObject.SetActive(!flag2);
                Vector3 toDirection = raycastHit.normal;
                if (Vector3.Angle(raycastHit.normal, Vector3.up) < 15f)
                {
                    toDirection = Vector3.up;
                }
                this.invalidReticleTargetRotation     = Quaternion.FromToRotation(Vector3.up, toDirection);
                this.invalidReticleTransform.rotation = Quaternion.Slerp(this.invalidReticleTransform.rotation, this.invalidReticleTargetRotation, 0.1f);
                float num4 = Util.RemapNumberClamped(Vector3.Distance(raycastHit.point, this.player.hmdTransform.position), this.invalidReticleMinScaleDistance, this.invalidReticleMaxScaleDistance, this.invalidReticleMinScale, this.invalidReticleMaxScale);
                this.invalidReticleScale.x = num4;
                this.invalidReticleScale.y = num4;
                this.invalidReticleScale.z = num4;
                this.invalidReticleTransform.transform.localScale = this.invalidReticleScale;
                this.pointedAtTeleportMarker = null;
                if (flag)
                {
                    vector2 = raycastHit.point;
                }
                else
                {
                    vector2 = this.teleportArc.GetArcPositionAtTime(this.teleportArc.arcDuration);
                }
                if (this.debugFloor)
                {
                    this.floorDebugSphere.gameObject.SetActive(false);
                    this.floorDebugLine.gameObject.SetActive(false);
                }
            }
            if (this.playAreaPreviewTransform != null)
            {
                this.playAreaPreviewTransform.gameObject.SetActive(active);
            }
            if (!this.showOffsetReticle)
            {
                this.offsetReticleTransform.gameObject.SetActive(false);
            }
            this.destinationReticleTransform.position  = this.pointedAtPosition;
            this.invalidReticleTransform.position      = vector2;
            this.onActivateObjectTransform.position    = vector2;
            this.onDeactivateObjectTransform.position  = vector2;
            this.offsetReticleTransform.position       = vector2 - vector;
            this.reticleAudioSource.transform.position = this.pointedAtPosition;
            this.pointerLineRenderer.SetPosition(0, position);
            this.pointerLineRenderer.SetPosition(1, vector2);
        }
Esempio n. 7
0
        }                                        // 0x0000000180EF04F0-0x0000000180EF0B00

        private void HighlightSelected(TeleportMarkerBase hitTeleportMarker)
        {
        }                                                                               // 0x0000000180EEDAC0-0x0000000180EEDE00
Esempio n. 8
0
        //-------------------------------------------------
        private void ShowPointer(Hand newPointerHand, Hand oldPointerHand)
        {
            if (!visible)
            {
                pointedAtTeleportMarker = null;
                pointerShowStartTime    = Time.time;
                visible    = true;
                meshFading = true;

                teleportPointerObject.SetActive(false);
                teleportArc.Show();

                //MJ20170525 Never disabling teleportPoints for them to be able to detect collision with vision
                foreach (TeleportMarkerBase teleportMarker in teleportMarkers)
                {
                    if (teleportMarker.markerActive && teleportMarker.ShouldActivate(player.feetPositionGuess))
                    {
                        //teleportMarker.gameObject.SetActive( true );
                        teleportMarker.Highlight(false);
//						//MJ20170526 Necessary not to have alpha back to maximum temporarily ---------------
//						individualFullTintAlpha = teleportMarker.gameObject.transform.Find ("teleport_marker_mesh").GetComponent<TeleportVisionController> ().fullTintAlpha;
//						individualMeshAlphaPercent = teleportMarker.gameObject.transform.Find ("teleport_marker_mesh").GetComponent<TeleportVisionController> ().meshAlphaPercent;
//						teleportMarker.SetAlpha( individualFullTintAlpha * individualMeshAlphaPercent, individualMeshAlphaPercent );
                    }
                }

                startingFeetOffset = player.trackingOriginTransform.position - player.feetPositionGuess;
                movedFeetFarEnough = false;

                if (onDeactivateObjectTransform.gameObject.activeSelf)
                {
                    onDeactivateObjectTransform.gameObject.SetActive(false);
                }
                onActivateObjectTransform.gameObject.SetActive(true);

                loopingAudioSource.clip = pointerLoopSound;
                loopingAudioSource.loop = true;
                loopingAudioSource.Play();
                loopingAudioSource.volume = 0.0f;
            }


            if (oldPointerHand)
            {
                if (ShouldOverrideHoverLock())
                {
                    //Restore the original hovering interactable on the hand
                    if (originalHoverLockState == true)
                    {
                        oldPointerHand.HoverLock(originalHoveringInteractable);
                    }
                    else
                    {
                        oldPointerHand.HoverUnlock(null);
                    }
                }
            }

            pointerHand = newPointerHand;

            if (visible && oldPointerHand != pointerHand)
            {
                PlayAudioClip(pointerAudioSource, pointerStartSound);
            }

            if (pointerHand)
            {
                pointerStartTransform = GetPointerStartTransform(pointerHand);

                if (pointerHand.currentAttachedObject != null)
                {
                    allowTeleportWhileAttached = pointerHand.currentAttachedObject.GetComponent <AllowTeleportWhileAttachedToHand>();
                }

                //Keep track of any existing hovering interactable on the hand
                originalHoverLockState       = pointerHand.hoverLocked;
                originalHoveringInteractable = pointerHand.hoveringInteractable;

                if (ShouldOverrideHoverLock())
                {
                    pointerHand.HoverLock(null);
                }

                pointerAudioSource.transform.SetParent(pointerStartTransform);
                pointerAudioSource.transform.localPosition = Vector3.zero;

                loopingAudioSource.transform.SetParent(pointerStartTransform);
                loopingAudioSource.transform.localPosition = Vector3.zero;
            }
        }