Exemplo n.º 1
0
        private void TeleportPlayer()
        {
            this.teleporting = false;
            Teleport.PlayerPre.Send(this.pointedAtTeleportMarker);
            SteamVR_Fade.Start(Color.clear, this.currentFadeTime, false);
            TeleportPoint teleportPoint = this.teleportingToMarker as TeleportPoint;
            Vector3       a             = this.pointedAtPosition;

            if (teleportPoint != null)
            {
                a = teleportPoint.transform.position;
                if (teleportPoint.teleportType == TeleportPoint.TeleportPointType.SwitchToNewScene)
                {
                    teleportPoint.TeleportToScene();
                    return;
                }
            }
            TeleportArea x = this.teleportingToMarker as TeleportArea;
            RaycastHit   raycastHit;

            if (x != null && this.floorFixupMaximumTraceDistance > 0f && Physics.Raycast(a + 0.05f * Vector3.down, Vector3.down, out raycastHit, this.floorFixupMaximumTraceDistance, this.floorFixupTraceLayerMask))
            {
                a = raycastHit.point;
            }
            if (this.teleportingToMarker.ShouldMovePlayer())
            {
                Vector3 b = this.player.trackingOriginTransform.position - this.player.feetPositionGuess;
                this.player.trackingOriginTransform.position = a + b;
            }
            else
            {
                this.teleportingToMarker.TeleportPlayer(this.pointedAtPosition);
            }
            Teleport.Player.Send(this.pointedAtTeleportMarker);
        }
Exemplo n.º 2
0
        //-------------------------------------------------
        private void TeleportPlayer()
        {
            teleporting = false;

            Teleport.PlayerPre.Send(pointedAtTeleportMarker);

            SteamVR_Fade.Start(Color.clear, currentFadeTime);

            TeleportPoint teleportPoint    = teleportingToMarker as TeleportPoint;
            Vector3       teleportPosition = pointedAtPosition;

            if (teleportPoint != null)
            {
                teleportPoint.OnClickEvent.Invoke();
                teleportPosition = teleportPoint.transform.position;

                //Teleport to a new scene
                if (teleportPoint.teleportType == TeleportPoint.TeleportPointType.SwitchToNewScene)
                {
                    teleportPoint.TeleportToScene();
                    return;
                }
            }

            // Find the actual floor position below the navigation mesh
            TeleportArea teleportArea = teleportingToMarker as TeleportArea;

            if (teleportArea != null)
            {
                if (floorFixupMaximumTraceDistance > 0.0f)
                {
                    RaycastHit raycastHit;
                    if (Physics.Raycast(teleportPosition + 0.05f * Vector3.down, Vector3.down, out raycastHit, floorFixupMaximumTraceDistance, floorFixupTraceLayerMask))
                    {
                        teleportPosition = raycastHit.point;
                    }
                }
            }

            if (teleportingToMarker.ShouldMovePlayer())
            {
                Vector3 playerFeetOffset = player.trackingOriginTransform.position - player.feetPositionGuess;
                player.trackingOriginTransform.position = teleportPosition + playerFeetOffset;

                if (player.leftHand.currentAttachedObjectInfo.HasValue)
                {
                    player.leftHand.ResetAttachedTransform(player.leftHand.currentAttachedObjectInfo.Value);
                }
                if (player.rightHand.currentAttachedObjectInfo.HasValue)
                {
                    player.rightHand.ResetAttachedTransform(player.rightHand.currentAttachedObjectInfo.Value);
                }
            }
            else
            {
                teleportingToMarker.TeleportPlayer(pointedAtPosition);
            }

            Teleport.Player.Send(pointedAtTeleportMarker);
        }
Exemplo n.º 3
0
        //-------------------------------------------------
        private void TeleportPlayer()
        {
            teleporting = false;

            Teleport.PlayerPre.Send(pointedAtTeleportMarker);

            SteamVR_Fade.Start(Color.clear, currentFadeTime);

            TeleportPoint teleportPoint    = teleportingToMarker as TeleportPoint;
            Vector3       teleportPosition = pointedAtPosition;

            if (teleportPoint != null)
            {
                teleportPosition = teleportPoint.transform.position;

                //Teleport to a new scene
                if (teleportPoint.teleportType == TeleportPoint.TeleportPointType.SwitchToNewScene)
                {
                    teleportPoint.TeleportToScene();
                    return;
                }
            }

            // Find the actual floor position below the navigation mesh
            TeleportArea teleportArea = teleportingToMarker as TeleportArea;

            if (teleportArea != null)
            {
                if (floorFixupMaximumTraceDistance > 0.0f)
                {
                    RaycastHit raycastHit;
                    if (Physics.Raycast(teleportPosition + 0.05f * Vector3.down, Vector3.down, out raycastHit, floorFixupMaximumTraceDistance, floorFixupTraceLayerMask))
                    {
                        teleportPosition = raycastHit.point;
                    }
                }
            }

            if (teleportingToMarker.ShouldMovePlayer())
            {
                Vector3 playerFeetOffset = player.trackingOriginTransform.position - player.feetPositionGuess;
                player.trackingOriginTransform.position = teleportPosition + playerFeetOffset;
            }
            else
            {
                teleportingToMarker.TeleportPlayer(pointedAtPosition);
            }

            Teleport.Player.Send(pointedAtTeleportMarker);

            // Modified
            if (teleportPoint != null)
            {
                if (teleportPoint.setRoom == true)
                {
                    RoomProperties.instance.SetRoomLocation();
                }
            }
        }
Exemplo n.º 4
0
        //-------------------------------------------------
        private void TeleportPlayer()
        {
            teleporting = false;

            Teleport.PlayerPre.Send(pointedAtTeleportMarker);

            SteamVR_Fade.Start(Color.clear, currentFadeTime);

            TeleportPoint teleportPoint    = teleportingToMarker as TeleportPoint;
            Vector3       teleportPosition = pointedAtPosition;

            if (teleportPoint != null)
            {
                teleportPosition = teleportPoint.transform.position;

                //Teleport to a new scene
                if (teleportPoint.teleportType == TeleportPoint.TeleportPointType.SwitchToNewScene)
                {
                    teleportPoint.TeleportToScene();
                    return;
                }
            }

            // Find the actual floor position below the navigation mesh
            TeleportArea teleportArea = teleportingToMarker as TeleportArea;

            if (teleportArea != null)
            {
                if (floorFixupMaximumTraceDistance > 0.0f)
                {
                    RaycastHit raycastHit;
                    if (Physics.Raycast(teleportPosition + 0.05f * Vector3.down, Vector3.down, out raycastHit, floorFixupMaximumTraceDistance, floorFixupTraceLayerMask))
                    {
                        teleportPosition = raycastHit.point;
                    }
                }
            }

            if (teleportingToMarker.ShouldMovePlayer())
            {
                Vector3 playerFeetOffset = player.trackingOriginTransform.position - player.feetPositionGuess;
                player.trackingOriginTransform.position = teleportPosition + playerFeetOffset;
                teleportPointOpen.Highlight(false);

                HexCell dest = grid.GetCell(player.trackingOriginTransform.position);

                // Enlever les unités de déplacement à l'unité
                currentUnit.Speed    = currentUnit.Speed - dest.Distance;
                currentUnit.Location = dest;
            }
            else
            {
                teleportingToMarker.TeleportPlayer(pointedAtPosition);
            }

            Teleport.Player.Send(pointedAtTeleportMarker);
        }
Exemplo n.º 5
0
        //-------------------------------------------------
        void FixedUpdate()
        {
            //if (timesTeleported >= 3 && !hasAreaTeleported)
            //{
            //    visible = false;
            //}

            if (!visible)
            {
                return;
            }

            if (debugFloor)
            {
                //Debug floor
                TeleportArea teleportArea = pointedAtTeleportMarker as TeleportArea;
                if (teleportArea != null)
                {
                    if (floorFixupMaximumTraceDistance > 0.0f)
                    {
                        floorDebugSphere.gameObject.SetActive(true);
                        floorDebugLine.gameObject.SetActive(true);

                        RaycastHit raycastHit;
                        Vector3    traceDir = Vector3.down;
                        traceDir.x = 0.01f;
                        if (Physics.Raycast(pointedAtPosition + 0.05f * traceDir, traceDir, out raycastHit, floorFixupMaximumTraceDistance, floorFixupTraceLayerMask))
                        {
                            floorDebugSphere.transform.position = raycastHit.point;
                            floorDebugSphere.material.color     = Color.green;
#if (UNITY_5_4)
                            floorDebugLine.SetColors(Color.green, Color.green);
#else
                            floorDebugLine.startColor = Color.green;
                            floorDebugLine.endColor   = Color.green;
#endif
                            floorDebugLine.SetPosition(0, pointedAtPosition);
                            floorDebugLine.SetPosition(1, raycastHit.point);
                        }
                        else
                        {
                            Vector3 rayEnd = pointedAtPosition + (traceDir * floorFixupMaximumTraceDistance);
                            floorDebugSphere.transform.position = rayEnd;
                            floorDebugSphere.material.color     = Color.red;
#if (UNITY_5_4)
                            floorDebugLine.SetColors(Color.red, Color.red);
#else
                            floorDebugLine.startColor = Color.red;
                            floorDebugLine.endColor   = Color.red;
#endif
                            floorDebugLine.SetPosition(0, pointedAtPosition);
                            floorDebugLine.SetPosition(1, rayEnd);
                        }
                    }
                }
            }
        }
Exemplo n.º 6
0
 //-------------------------------------------------
 void OnEnable()
 {
     if (Selection.activeTransform != null)
     {
         TeleportArea teleportArea = Selection.activeTransform.GetComponent <TeleportArea>();
         if (teleportArea != null)
         {
             teleportArea.UpdateVisualsInEditor();
         }
     }
 }
Exemplo n.º 7
0
        //-------------------------------------------------
        private void TeleportPlayer()
        {
            teleporting = false;

            Teleport.PlayerPre.Send(pointedAtTeleportMarker);

            SteamVR_Fade.Start(Color.clear, currentFadeTime);

            TeleportPoint teleportPoint    = teleportingToMarker as TeleportPoint;
            Vector3       teleportPosition = pointedAtPosition;

            if (teleportPoint != null)
            {
                teleportPosition = teleportPoint.transform.position;

                //Teleport to a new scene
                if (teleportPoint.teleportType == TeleportPoint.TeleportPointType.SwitchToNewScene)
                {
                    teleportPoint.TeleportToScene();
                    return;
                }
            }

            // Find the actual floor position below the navigation mesh
            TeleportArea teleportArea = teleportingToMarker as TeleportArea;

            if (teleportArea != null)
            {
                if (floorFixupMaximumTraceDistance > 0.0f)
                {
                    RaycastHit raycastHit;
                    if (Physics.Raycast(teleportPosition + 0.05f * Vector3.down, Vector3.down, out raycastHit, floorFixupMaximumTraceDistance, floorFixupTraceLayerMask))
                    {
                        teleportPosition = raycastHit.point;
                    }
                }
            }

            if (teleportingToMarker.ShouldMovePlayer())
            {
                Vector3 playerFeetOffset = player.trackingOriginTransform.position - player.feetPositionGuess;
                player.trackingOriginTransform.position = teleportPosition + playerFeetOffset;
            }
            else
            {
                teleportingToMarker.TeleportPlayer(pointedAtPosition);
            }

            //MJ20170525 Forcing disabling of highlight of future teleportPoint (necessary when never fully disabling teleport points, only mesh renderer)
            pointedAtTeleportMarker.Highlight(false);

            Teleport.Player.Send(pointedAtTeleportMarker);
        }
Exemplo n.º 8
0
        //-------------------------------------------------
        public override void OnInspectorGUI()
        {
            DrawDefaultInspector();

            if (Selection.activeTransform != null)
            {
                TeleportArea teleportArea = Selection.activeTransform.GetComponent <TeleportArea>();
                if (GUI.changed && teleportArea != null)
                {
                    teleportArea.UpdateVisualsInEditor();
                }
            }
        }
Exemplo n.º 9
0
 private void FixedUpdate()
 {
     if (!this.visible)
     {
         return;
     }
     if (this.debugFloor)
     {
         TeleportArea x = this.pointedAtTeleportMarker as TeleportArea;
         if (x != null && this.floorFixupMaximumTraceDistance > 0f)
         {
             this.floorDebugSphere.gameObject.SetActive(true);
             this.floorDebugLine.gameObject.SetActive(true);
             Vector3 down = Vector3.down;
             down.x = 0.01f;
             RaycastHit raycastHit;
             if (Physics.Raycast(this.pointedAtPosition + 0.05f * down, down, out raycastHit, this.floorFixupMaximumTraceDistance, this.floorFixupTraceLayerMask))
             {
                 this.floorDebugSphere.transform.position = raycastHit.point;
                 this.floorDebugSphere.material.color     = Color.green;
                 this.floorDebugLine.startColor           = Color.green;
                 this.floorDebugLine.endColor             = Color.green;
                 this.floorDebugLine.SetPosition(0, this.pointedAtPosition);
                 this.floorDebugLine.SetPosition(1, raycastHit.point);
             }
             else
             {
                 Vector3 position = this.pointedAtPosition + down * this.floorFixupMaximumTraceDistance;
                 this.floorDebugSphere.transform.position = position;
                 this.floorDebugSphere.material.color     = Color.red;
                 this.floorDebugLine.startColor           = Color.red;
                 this.floorDebugLine.endColor             = Color.red;
                 this.floorDebugLine.SetPosition(0, this.pointedAtPosition);
                 this.floorDebugLine.SetPosition(1, position);
             }
         }
     }
 }
Exemplo n.º 10
0
        //-------------------------------------------------
        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);
        }
Exemplo n.º 11
0
        //-------------------------------------------------
        private void TeleportPlayer()
        {
            teleporting = false;

            Teleport.PlayerPre.Send(pointedAtTeleportMarker);

            SteamVR_Fade.Start(Color.clear, currentFadeTime);

            TeleportPoint teleportPoint    = teleportingToMarker as TeleportPoint;
            Vector3       teleportPosition = pointedAtPosition;

            if (teleportPoint != null)
            {
                Debug.Log("Was a teleport point");
                teleportPosition = teleportPoint.transform.position;

                //Teleport to a new scene
                if (teleportPoint.teleportType == TeleportPoint.TeleportPointType.SwitchToNewScene)
                {
                    teleportPoint.TeleportToScene();
                    return;
                }
            }

            // Find the actual floor position below the navigation mesh
            TeleportArea teleportArea = teleportingToMarker as TeleportArea;
            CubeType     cube         = null;

            if (teleportArea != null)
            {
                Debug.Log("Was a teleport area");
                if (floorFixupMaximumTraceDistance > 0.0f)
                {
                    RaycastHit raycastHit;
                    if (Physics.Raycast(teleportPosition + 0.05f * Vector3.down, Vector3.down, out raycastHit, floorFixupMaximumTraceDistance, floorFixupTraceLayerMask))
                    {
                        teleportPosition = raycastHit.point;
                    }


                    GameObject target = teleportArea.gameObject.transform.parent.gameObject;

                    Debug.Log("teleporting to teleport area: " + target.name);
                    cube = target.GetComponent <CubeType>();
                    Debug.Log("Did it have a float cube? " + cube);
                    foreach (Component obj in target.GetComponents(typeof(Component)))
                    {
                        Debug.Log("Component in " + target + ": " + obj);
                    }
                }
            }

            if (teleportingToMarker.ShouldMovePlayer())
            {
                Debug.Log("if ( teleportingToMarker.ShouldMovePlayer() )");
                Vector3 playerFeetOffset = player.trackingOriginTransform.position - player.feetPositionGuess;
                player.trackingOriginTransform.position = teleportPosition + playerFeetOffset;
                if (platform != null)
                {
                    if (platform.GetComponent <CubeType>() != null)
                    {
                        platform.GetComponent <CubeType>().Detach(GameObject.Find("Player"));
                    }
                    platform = null;
                }
                if (cube != null)
                {
                    Debug.Log("Raycast hit float cube");
                    cube.ApplyCollision(GameObject.Find("Player"));
                    platform = cube.gameObject;
                }

                if (player.leftHand.currentAttachedObjectInfo.HasValue)
                {
                    player.leftHand.ResetAttachedTransform(player.leftHand.currentAttachedObjectInfo.Value);
                }
                if (player.rightHand.currentAttachedObjectInfo.HasValue)
                {
                    player.rightHand.ResetAttachedTransform(player.rightHand.currentAttachedObjectInfo.Value);
                }
            }
            else
            {
                teleportingToMarker.TeleportPlayer(pointedAtPosition);
            }

            Teleport.Player.Send(pointedAtTeleportMarker);
        }
Exemplo n.º 12
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);
        }
Exemplo n.º 13
0
        //-------------------------------------------------
        private void TeleportPlayer()
        {
            teleporting = false;

            Teleport.PlayerPre.Send(pointedAtTeleportMarker);

            SteamVR_Fade.Start(Color.clear, currentFadeTime);

            TeleportPoint teleportPoint    = teleportingToMarker as TeleportPoint;
            Vector3       teleportPosition = pointedAtPosition;

            if (teleportPoint != null)
            {
                teleportPosition = teleportPoint.transform.position;

                if (teleportPoint.CompareTag("WirePoint"))
                {
                    isOnWirePoint = true;
                }

                //Teleport to a new scene
                if (teleportPoint.teleportType == TeleportPoint.TeleportPointType.SwitchToNewScene)
                {
                    teleportPoint.TeleportToScene();
                    return;
                }

                hasAreaTeleported = true;
            }

            // Find the actual floor position below the navigation mesh
            TeleportArea teleportArea = teleportingToMarker as TeleportArea;

            if (teleportArea != null)
            {
                if (floorFixupMaximumTraceDistance > 0.0f)
                {
                    RaycastHit raycastHit;
                    if (Physics.Raycast(teleportPosition + 0.05f * Vector3.down, Vector3.down, out raycastHit, floorFixupMaximumTraceDistance, floorFixupTraceLayerMask))
                    {
                        teleportPosition = raycastHit.point;
                    }
                }
            }

            if (teleportingToMarker.ShouldMovePlayer())
            {
                Vector3 playerFeetOffset = player.trackingOriginTransform.position - player.feetPositionGuess;
                player.trackingOriginTransform.position = teleportPosition + playerFeetOffset;

                if (player.leftHand.currentAttachedObjectInfo.HasValue)
                {
                    player.leftHand.ResetAttachedTransform(player.leftHand.currentAttachedObjectInfo.Value);
                }

                if (player.rightHand.currentAttachedObjectInfo.HasValue)
                {
                    player.rightHand.ResetAttachedTransform(player.rightHand.currentAttachedObjectInfo.Value);
                }
            }
            else
            {
                teleportingToMarker.TeleportPlayer(pointedAtPosition);
            }

            Teleport.Player.Send(pointedAtTeleportMarker);

            timesTeleported++;

            bool[] spawnPortals = new bool[3];

            for (int i = 0; i < spawnPortals.Length; i++)
            {
                int randomNr = Random.Range(0, 100) + 1;
                //Debug.Log(randomNr);
                if (randomNr <= portalSpawnPercentageChance)
                {
                    spawnPortals[i] = true;
                }
            }
            PortalManager._instance.CheckSpawnPortal(spawnPortals);// CheckSpawnPortal(spawnPortals);
        }
Exemplo n.º 14
0
        //-------------------------------------------------
        private void TeleportPlayer()
        {
            teleporting = false;

            Teleport.PlayerPre.Send(pointedAtTeleportMarker);

            SteamVR_Fade.Start(Color.clear, currentFadeTime);

            TeleportPoint teleportPoint    = teleportingToMarker as TeleportPoint;
            Vector3       teleportPosition = pointedAtPosition;

            if (teleportPoint != null)
            {
                teleportPosition = teleportPoint.transform.position;

                //Teleport to a new scene
                if (teleportPoint.teleportType == TeleportPoint.TeleportPointType.SwitchToNewScene)
                {
                    teleportPoint.TeleportToScene();
                    return;
                }
            }

            // Find the actual floor position below the navigation mesh
            TeleportArea teleportArea = teleportingToMarker as TeleportArea;

            if (teleportArea != null)
            {
                if (floorFixupMaximumTraceDistance > 0.0f)
                {
                    RaycastHit raycastHit;
                    if (Physics.Raycast(teleportPosition + 0.05f * Vector3.down, Vector3.down, out raycastHit, floorFixupMaximumTraceDistance, floorFixupTraceLayerMask))
                    {
                        teleportPosition = raycastHit.point;
                    }
                }
            }

            //if ( teleportingToMarker.ShouldMovePlayer() )
            {
                Vector3 playerFeetOffset = player.trackingOriginTransform.position - player.feetPositionGuess;

                RaycastHit hit;
                Physics.Linecast(player.hmdTransform.position, teleportPosition + playerFeetOffset, out hit, 1 << LayerMask.NameToLayer("Checkpoint"));

                if (hit.collider != null)
                {
                    hit.collider.GetComponent <TimedCheckpoint>().CompleteCheckpoint();
                    Debug.Log("Ran into " + hit.collider.name);
                }

                //if (InteractionManager.Instance.moveType == InteractionManager.MovementType.TELEPORT)
                player.trackingOriginTransform.position = teleportPosition + playerFeetOffset;//This is the line that changes the player's position. TODO

                if (Statistics.Instance.allowDataCollection)
                {
                    Statistics.Instance.data.teleportCount++;
                }
                //else
                //    dashTo = teleportPosition + playerFeetOffset;
            }

            /*else
             *          {
             *                  teleportingToMarker.TeleportPlayer( pointedAtPosition );
             *          }*/

            Teleport.Player.Send(pointedAtTeleportMarker);
        }