Пример #1
0
 private void OnTriggerStay(Collider other)
 {
     if (other.gameObject.tag == "VRHands" && OVRInput.GetDown(OVRInput.Button.PrimaryHandTrigger) || OVRInput.GetDown(OVRInput.Button.SecondaryHandTrigger))
     {
         grabbedBy = other.gameObject;
         grabbed   = true;
         NetworkObjectComponent.GetNetworkObjectForObject(transform).SetPlayerInteracting(true);
     }
 }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        if (EndGameCanvas == null)
        {
            if (NetworkingManager.GetLocalPlayer() != null)
            {
                EndGameCanvasScript canvasscript = NetworkingManager.GetLocalPlayer().GetComponentInChildren <EndGameCanvasScript>();
                EndGameCanvas     = canvasscript.gameObject;
                WinObject         = canvasscript.WinObject;
                LooseObject       = canvasscript.LooseObject;
                CenterEyeCamera   = canvasscript.CenterEyeCamera;
                GameOverTitle     = canvasscript.GameOverTitle;
                GameOverClosing   = canvasscript.GameOverClosing;
                ThirtyMinuteTimer = canvasscript.ThirtyMinuteTimer;
                TimeElapsed       = canvasscript.TimeElapsed;
            }
            else
            {
                return;
            }
        }
        if (OtherLever == null)
        {
            if (NetworkingManager.GetLocalPlayer() != null)
            {
                if (left)
                {
                    OtherLever = GameObject.Find("2LeverHandle(Clone)");
                }
                else if (!left)
                {
                    OtherLever = GameObject.Find("1LeverHandle(Clone)");
                }
                if (OtherLever == null)
                {
                    return;
                }
            }
            else
            {
                return;
            }
        }

        if (this.transform.position.y <= MinY)
        {
            //This player is dead
            GameOverClosing.SetActive(true);
            GameOverTitle.SetActive(true);
            WinObject.SetActive(true);
            LooseObject.SetActive(false);
            if (PlayerPrefs.GetInt("ThirtyMinuteTimer") == 1)
            {
                ThirtyMinuteTimer.SetActive(true);
            }
            if (PlayerPrefs.GetInt("TimeElapsed") == 1)
            {
                TimeElapsed.SetActive(true);
            }
            GameOver = true;
            CenterEyeCamera.cullingMask = 1 << 12;
        }

        transform.rotation = LeverRot;
        if (OVRInput.GetUp(OVRInput.Button.PrimaryHandTrigger) || OVRInput.GetUp(OVRInput.Button.SecondaryHandTrigger))
        {
            grabbedBy = null;
            grabbed   = false;
            NetworkObjectComponent.GetNetworkObjectForObject(transform).SetPlayerInteracting(false);
        }
        if (grabbed)
        {
            //LevelPos = this.transform.position;
            this.transform.position = new Vector3(LevelPos.x, grabbedBy.transform.position.y, LevelPos.z);
            if (this.transform.position.y >= MaxY)
            {
                this.transform.position = new Vector3(LevelPos.x, MaxY, LevelPos.z);
            }
            if (this.transform.position.y <= MinY)
            {
                this.transform.position = new Vector3(LevelPos.x, MinY, LevelPos.z);
                leverActivated          = true;
            }
        }
        //If Player 1 Pulls Lever and Wins
        if (leverActivated && !OtherLever.GetComponent <LeverScript>().leverActivated&& !ran)
        {
            GameOverClosing.SetActive(true);
            GameOverTitle.SetActive(true);
            WinObject.SetActive(true);
            LooseObject.SetActive(false);
            if (PlayerPrefs.GetInt("ThirtyMinuteTimer") == 1)
            {
                ThirtyMinuteTimer.SetActive(true);
            }
            if (PlayerPrefs.GetInt("TimeElapsed") == 1)
            {
                TimeElapsed.SetActive(true);
            }
            GameOver = true;
            CenterEyeCamera.cullingMask = 1 << 12;
            ran = true;
        }
        //If Player 2 Pulls Lever, Player 1 Looses
        //else if (!leverActivated && OtherLever.GetComponent<LeverScript>().leverActivated && !ran)
        //{
        //    GameOverClosing.SetActive(true);
        //    GameOverTitle.SetActive(true);
        //    WinObject.SetActive(false);
        //    LooseObject.SetActive(true);
        //    CenterEyeCamera.cullingMask = 1 << 12;
        //}
    }