Esempio n. 1
0
 public void LevelLocalTransformChanging(Vector3 old, Vector3 updated)
 {
     if (warper != null)
     {
         warper.SetWorldPostion(warper.transform.position + (updated - old) + Camera.main.transform.localPosition);
     }
 }
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
    // 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.SetWorldPostion(goal);
                        Debug.DrawLine(hitPos, goal);
                    }, null);
                }

                warpCancelled = false;
                DisableMarker();
            }
            else
            {
                PositionMarker();
            }
        }
        else
        {
            if (fadeControl.Busy == false && Input.GetButtonDown("Jump"))
            {
                warping = true;
                EnableMarker();
                PositionMarker();
            }
        }
    }
Esempio n. 4
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);
            }
        }