Esempio n. 1
0
    /// <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.SetWorldPostion(currentStartTile.transform.position + Vector3.up * 0.8f * transform.localScale.y);
                    VRRoomControl.Instance.DisableControls();
                }
                else
                {
                    transform.localScale = startScale;
                    warper.ResetRotation();
                    warper.SetWorldPostion(transform.position + transform.forward * -2.5f + Vector3.up * 0.25f);
                    VRRoomControl.Instance.EnableControls();
                }

                // and configure the remote players avatars as well.
                ConfigureAvatarsForPathState();
            }, null);
        }
    }
Esempio n. 2
0
        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.SetWorldPostion(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);
                }
            }
        }
Esempio n. 3
0
        void PathIndexChanged(int update)
        {
            Debug.LogFormat("{0}: Path index updated {1} => {2}", PlayerName, PathIndex, update);
            PathIndex = update;

            if (isLocalPlayer)
            {
                levelState.SetPathIndex(PathIndex);
                if (PathIndex == -1 && UnityEngine.XR.WSA.HolographicSettings.IsDisplayOpaque)
                {
                    Debug.Log("Getting in line");
                    WaitingForFreePath = true;
                    if (fadeControl != null && fadeControl.Busy == false)
                    {
                        fadeControl.DoFade(0.5f, 0.5f,
                                           () =>
                        {
                            MixedRealityTeleport warper = MixedRealityTeleport.Instance;
                            if (warper != null)
                            {
                                warper.ResetRotation();
                                warper.SetWorldPostion(levelState.transform.position + levelState.transform.forward * -2.5f + Vector3.up * 0.25f + levelState.transform.transform.right * Random.Range(-2f, 2.0f));
                            }
                        }, null);
                    }
                }
                else
                {
                    WaitingForFreePath = false;
                }
            }
            else
            {
                levelState.OnPathMessage(PathIndex, PlayerName);
            }
        }