private void HandleTeleport()
        {
            if (EnableTeleport)
            {
                if (teleporting)
                {
                    if (Input.GetButtonUp(TeleportButtonName))
                    {
                        teleporting = false;
                        if (teleportValid)
                        {
                            positionBeforeJump = transform.position;
                            float      verticalOffset;
                            RaycastHit hitInfo;
                            if (Physics.Raycast(Camera.main.transform.position, Vector3.down, out hitInfo, 5.0f))
                            {
                                verticalOffset = hitInfo.distance;
                            }
                            else
                            {
                                verticalOffset = 2.6f;
                            }

                            Vector3 hitPos = teleportMarker.transform.position + Vector3.up * verticalOffset;

                            fadeControl.DoFade(0.25f, 0.5f, () =>
                            {
                                SetWorldPosition(hitPos);
                            }, null);
                        }

                        DisableMarker();
                    }
                    else
                    {
                        PositionMarker();
                    }
                }
                else
                {
                    if (fadeControl.Busy == false && Input.GetButtonDown(TeleportButtonName))
                    {
                        teleporting = true;
                        EnableMarker();
                        PositionMarker();
                    }
                }
            }
        }
Esempio n. 2
0
    void Update()
    {
        // for HoloLens we don't allow manual camera control.
        if (UnityEngine.XR.WSA.HolographicSettings.IsDisplayOpaque == false)
        {
            return;
        }

        // Check bumpers for coarse rotation
        float bumperRot = 0;

        if (Input.GetButtonUp("LeftBumper"))
        {
            bumperRot = -BumperRotationSize;
        }

        if (Input.GetButtonUp("RightBumper"))
        {
            bumperRot = BumperRotationSize;
        }

        if (bumperRot != 0)
        {
            fadeControl.DoFade(
                0.25f, // Fade out time
                0.25f, // Fade in time
                () =>  // Action after fade out
            {
                transform.RotateAround(Camera.main.transform.position, Vector3.up, bumperRot);
            },
                null // Action after fade in
                );
        }
    }
    void Update()
    {
        // Check bumpers for coarse rotation
        float bumperRot = 0;

        if (Input.GetButtonUp("LeftBumper"))
        {
            bumperRot = -BumperRotationSize;
        }

        if (Input.GetButtonUp("RightBumper"))
        {
            bumperRot = BumperRotationSize;
        }

        if (bumperRot != 0)
        {
            fadeControl.DoFade(
                0.25f, // Fade out time
                0.25f, // Fade in time
                () =>  // Action after fade out
            {
                transform.RotateAround(Camera.main.transform.position, Vector3.up, bumperRot);
            },
                null // Action after fade in
                );
        }
    }
    /// <summary>
    /// sets the path index for the local player
    /// </summary>
    /// <param name="pathIndex">The path index to set</param>
    public void SetPathIndex(int pathIndex)
    {
        if (UnityEngine.XR.WSA.HolographicSettings.IsDisplayOpaque && warper != null && fadeScript != null && !fadeScript.Busy && pathIndex != onPathIndex)
        {
            fadeScript.DoFade(1, 1,
                              () =>
            {
                SetGoalLights();
                sentPuzzleComplete = false;
                sentGoalComplete   = false;
                Immersed           = (pathIndex >= 0);
                onPathIndex        = pathIndex;

                UAudioManager.Instance.PlayEvent("Teleport");

                //  warper.AllowTeleport = Immersed;
                //  warper.ResetRotation();
                SafetyColliders.SetActive(Immersed);
                // setup the scene state based on if we are immersed or not.
                if (Immersed)
                {
                    transform.localScale = startScale * ImmersiveScale;
                    warper.SetWorldPosition(currentStartTile.transform.position + Vector3.up * 0.8f * transform.localScale.y);
                    VRRoomControl.Instance.DisableControls();
                }
                else
                {
                    transform.localScale = startScale;
                    //   warper.ResetRotation();
                    warper.SetWorldPosition(transform.position + transform.forward * -2.5f + Vector3.up * 0.25f);
                    VRRoomControl.Instance.EnableControls();
                }

                // and configure the remote players avatars as well.
                ConfigureAvatarsForPathState();
            }, null);
        }
        else if (fadeScript != null && fadeScript.Busy)
        {
            DeferredPathIndex = pathIndex;
            Debug.Log("Warping later");
            Invoke("DeferredPosition", 1.0f);
        }
    }
        private void FinishTeleport()
        {
            if (currentPointingSource != null)
            {
                currentPointingSource = null;

                if (isTeleportValid)
                {
                    RaycastHit hitInfo;
                    Vector3    hitPos = teleportMarker.transform.position + Vector3.up * (Physics.Raycast(Camera.main.transform.position, Vector3.down, out hitInfo, 5.0f) ? hitInfo.distance : 2.6f);

                    fadeControl.DoFade(0.25f, 0.5f, () =>
                    {
                        SetWorldPosition(hitPos);
                    }, null);
                }

                DisableMarker();
            }
        }
        private void FinishTeleport()
        {
            if (currentPointingSource != null)
            {
                currentPointingSource = null;

                if (isTeleportValid)
                {
                    isTeleportValid = false;

                    Vector3 hitPos = teleportMarker.transform.position + Vector3.up * 2.6f;

                    fadeControl.DoFade(0.25f, 0.5f, () =>
                    {
                        SetWorldPosition(hitPos);
                    }, null);
                }

                DisableMarker();
            }
        }
        private void InitializeLocalPlayer()
        {
            if (isLocalPlayer)
            {
                Debug.Log("Setting instance for local player ");
                _Instance = this;
                Debug.LogFormat("Set local player name {0} ip {1}", networkDiscovery.broadcastData, networkDiscovery.LocalIp);
                CmdSetPlayerName(networkDiscovery.broadcastData);
                CmdSetPlayerIp(networkDiscovery.LocalIp);
                bool opaqueDisplay = UnityEngine.XR.WSA.HolographicSettings.IsDisplayOpaque;
                Debug.LogFormat("local player {0} share anchors ", (opaqueDisplay ? "does not" : "does"));
                CmdSetCanShareAnchors(!opaqueDisplay);

                if (opaqueDisplay && levelState != null && levelState.isActiveAndEnabled)
                {
                    Debug.Log("Requesting immersive path");
                    WaitingForFreePath = true;
                    CmdRequestPathIndex();
                }
                else
                {
                    Debug.Log("Defaulting to bird's eye view");
                    CmdSendPathIndex(-1);
                    if (opaqueDisplay && fadeControl != null && fadeControl.Busy == false)
                    {
                        fadeControl.DoFade(0.5f, 0.5f,
                                           () =>
                        {
                            MixedRealityTeleport warper = MixedRealityTeleport.Instance;
                            if (warper != null)
                            {
                                //warper.ResetRotation();
                                warper.SetWorldPosition(levelState.transform.position + levelState.transform.forward * -2.5f + Vector3.up * 0.25f + levelState.transform.transform.right * Random.Range(-2f, 2.0f));
                            }
                        }, null);
                    }
                }

                if (!opaqueDisplay && anchorManager.AnchorOwnerIP == "")
                {
                    Invoke("DeferredAnchorOwnerCheck", 2.0f);
                }

                if (UnityEngine.XR.WSA.HolographicSettings.IsDisplayOpaque)
                {
                    InteractionManager.InteractionSourceUpdated += InteractionManager_InteractionSourceUpdated;
                }
            }
        }
    // Update is called once per frame
    void Update()
    {
        if (warping)
        {
            if (Input.GetButtonUp("Jump"))
            {
                warping = false;
                if (warpCancelled == false)
                {
                    Vector3 hitPos = ActiveMarker.transform.position + Vector3.up * 2.6f;
                    Vector3 goal   = hitPos;
                    fadeControl.DoFade(0.25f, 0.5f, () =>
                    {
                        warper.SetWorldPosition(goal);
                        Debug.DrawLine(hitPos, goal);
                    }, null);
                }

                warpCancelled = false;
                DisableMarker();
            }
            else
            {
                PositionMarker();
            }
        }
        else
        {
            if (fadeControl.Busy == false && Input.GetButtonDown("Jump"))
            {
                warping = true;
                EnableMarker();
                PositionMarker();
            }
        }
    }