예제 #1
0
    void Update()
    {
        if (controller == null)
        {
            Debug.LogError("there is no dominant hand Daydream controller connected");
            return;
        }

        if (controller.GetButtonDown(GvrControllerButton.App))
        {
            if (paused)
            {
                if (hidePopupDuringPause)
                {
                    popup.gameObject.SetActive(true);
                }
                ResumeGame();
            }
            else
            {
                PauseGame();
            }
        }

        if (currentState != null && !paused)
        {
            currentState.OnUpdate(this);
        }
    }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        if (controller.GetButtonDown(GvrControllerButton.App))
        {
            timer = 0;
        }

        else if (controller.GetButton(GvrControllerButton.App))
        {
            timer += Time.deltaTime;
            if (timer >= APP_LONG_PRESS_DURATION && !actionComplete)
            {
                // Do "long press" actions here
                menuActive = !menuActive;
                menu.transform.position = camera.transform.position + camera.transform.forward * 0.75f;
                menu.transform.rotation = camera.transform.rotation;
                menu.SetActive(menuActive);
                actionComplete = true;
            }
        }

        else if (controller.GetButtonUp(GvrControllerButton.App))
        {
            actionComplete = false;
        }
    }
예제 #3
0
        // Runtime switching enabled only in-editor.
        private void Update()
        {
            UpdateStatusMessage();

            // Scan all devices' buttons for button down, and switch the singleton pointer
            // to the controller the user last clicked.
            int newPointer = activeControllerPointer;

            if (controllerPointers.Length > 1 && controllerPointers[1] != null)
            {
                GvrTrackedController trackedController1 =
                    controllerPointers[1].GetComponent <GvrTrackedController>();
                foreach (var hand in ALL_HANDS)
                {
                    GvrControllerInputDevice device = GvrControllerInput.GetDevice(hand);
                    if (device.GetButtonDown(POINTER_BUTTON_MASK))
                    {
                        // Match the button to our own controllerPointers list.
                        if (device == trackedController1.ControllerInputDevice)
                        {
                            newPointer = 1;
                        }
                        else
                        {
                            newPointer = 0;
                        }
                        break;
                    }
                }
            }

            if (newPointer != activeControllerPointer)
            {
                activeControllerPointer = newPointer;
                SetVRInputMechanism();
            }

#if !RUNNING_ON_ANDROID_DEVICE
            UpdateEmulatedPlatformIfPlayerSettingsChanged();
            if ((isDaydream && gvrEmulatedPlatformType == EmulatedPlatformType.Daydream) ||
                (!isDaydream && gvrEmulatedPlatformType == EmulatedPlatformType.Cardboard))
            {
                return;
            }

            isDaydream = (gvrEmulatedPlatformType == EmulatedPlatformType.Daydream);
            SetVRInputMechanism();
#else
            // Running on an Android device.
            // Viewer type switched at runtime.
            if (!IsDeviceDaydreamReady() || viewerPlatform == GvrSettings.ViewerPlatform)
            {
                return;
            }

            isDaydream     = GvrSettings.ViewerPlatform == GvrSettings.ViewerPlatformType.Daydream;
            viewerPlatform = GvrSettings.ViewerPlatform;
            SetVRInputMechanism();
#endif  // !RUNNING_ON_ANDROID_DEVICE
        }
예제 #4
0
 // Update is called once per frame
 void Update()
 {
     if (controller.GetButtonDown(GvrControllerButton.App))
     {
         sceneController.Reset();
         resetCanvas.enabled = true;
     }
 }
예제 #5
0
    // Update is called once per frame
    void Update()
    {
        if (_pointingAt)
        {
            // While touching the pad pan the map
            if (_dominantController.GetButton(GvrControllerButton.TouchPadTouch))
            {
                Vector2 touchPos = _dominantController.TouchPos;

                if (_previousTouchState)
                {
                    _translate = new Vector3();
                    Vector2 orientationDelta = touchPos - _previousTouch;

                    _translate.x += orientationDelta.x * panFactor;
                    _translate.z += orientationDelta.y * panFactor;

                    this.transform.Translate(_translate);
                }
                _previousTouchState = true;
                _previousTouch      = touchPos;
            }
            // When the pad is let go recenter the map
            if (_dominantController.GetButtonUp(GvrControllerButton.TouchPadTouch))
            {
                Recenter();
                _previousTouch      = _dominantController.TouchPos;
                _previousTouchState = false;
            }
            // When the button is clicked zoom in
            if (_dominantController.GetButtonDown(GvrControllerButton.TouchPadButton)) // Using event instead
            {
            }
            // When the app button is clicked zoom out
            if (_dominantController.GetButtonDown(GvrControllerButton.App)) // TODO: Change to double click
            {
                ZoomOut();
            }
        }

        CullSiteMarkers();
    }
예제 #6
0
        /// Returns true in the frame the user starts pressing down any of buttons specified
        /// in `buttons` on any controller.
        public static bool AnyButtonDown(GvrControllerButton buttons)
        {
            bool ret = false;

            foreach (var hand in AllHands)
            {
                GvrControllerInputDevice device = GvrControllerInput.GetDevice(hand);
                ret |= device.GetButtonDown(buttons);
            }
            return(ret);
        }
예제 #7
0
 public override void OnUpdate(GameController gameController)
 {
     if (controller.GetButtonDown(GvrControllerButton.TouchPadButton))
     {
         downTime = Time.time;
     }
     if (controller.GetButtonUp(GvrControllerButton.TouchPadButton))
     {
         if ((Time.time - downTime) < 1.0f)
         {
             gameController.GoToNextHole();
         }
     }
 }
예제 #8
0
 public override void OnUpdate(GameController gameController)
 {
     if (controller.GetButtonDown(GvrControllerButton.TouchPadButton))
     {
         downTime = Time.time;
     }
     if (controller.GetButtonUp(GvrControllerButton.TouchPadButton))
     {
         if ((Time.time - downTime) < 1.0f)
         {
             gameController.SetState(State.PRE_THROW);
         }
     }
 }
예제 #9
0
    private void Update()
    {
        //Checking for click towards the left
        if (controller.GetButtonDown(GvrControllerButton.TouchPadButton) && controller.TouchPos.x < 0)
        {
            BackPage();
        }
        //Checking for click towards the right
        if (controller.GetButtonDown(GvrControllerButton.TouchPadButton) && controller.TouchPos.x > 0)
        {
            ForwardPage();
        }

        /* This will correctly check if a swipe is occurring. Sensitivity
         * most likely needs adjustment
         * distance = lastTouchPos - controller.TouchPos;
         * if (distance.magnitude >= 0.1)
         * {
         *  OnSwipe();
         * }
         * lastTouchPos = controller.TouchPos;
         */
    }
예제 #10
0
 public override void OnUpdate(GameController gameController)
 {
     if (controller.GetButtonDown(GvrControllerButton.TouchPadButton))
     {
         downTime = Time.time;
     }
     if (controller.GetButtonUp(GvrControllerButton.TouchPadButton))
     {
         if ((Time.time - downTime) < 1.0f)
         {
             Vector3 position = gameController.GetDisc().transform.position;
             gameController.MovePlayerToDiscPosition(position);
             gameController.SetState(State.PRE_THROW);
         }
     }
 }
예제 #11
0
    // Update is called once per frame
    void Update()
    {
        if (controller.GetButtonDown(GvrControllerButton.App))
        {
            currentActive = (currentActive + 1) % 4;
        }
        switch (currentActive)
        {
        case 0:
            hudVideo.SetActive(true);
            followVideo.SetActive(false);
            podium.SetActive(false);
            break;

        case 1:
            hudVideo.SetActive(false);
            followVideo.SetActive(true);
            podium.SetActive(false);
            followVideo.GetComponent <FrontVideo>().enabled       = true;
            followVideo.GetComponent <DelayFollowVideo>().enabled = false;
            break;

        case 2:
            hudVideo.SetActive(false);
            followVideo.SetActive(true);
            podium.SetActive(false);
            followVideo.GetComponent <FrontVideo>().enabled       = false;
            followVideo.GetComponent <DelayFollowVideo>().enabled = true;
            break;

        case 3:
            hudVideo.SetActive(false);
            followVideo.SetActive(false);
            podium.SetActive(true);
            break;

        default:
            hudVideo.SetActive(true);
            followVideo.SetActive(false);
            podium.SetActive(false);
            break;
        }
    }
예제 #12
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.C) || gvrController.GetButtonDown(GvrControllerButton.App))
        {
            aud.volume = 1;
            aud.PlayOneShot(CoinSE);
            StartCoroutine(FadeOut());
            credit++;
        }

        CreditText.text = credit.ToString();

        if (credit > 0)
        {
            StartButton.interactable = true;
        }
        else
        {
            StartButton.interactable = false;
        }
    }
예제 #13
0
    public override void OnUpdate(GameController gameController)
    {
        GvrControllerInputDevice controller = gameController.GetController();

        //Vector3 lookDirection = Camera.main.transform.forward;
        //lookDirection.y = 0;
        //lookDirection.Normalize();

        //if(Vector3.Dot(direction, lookDirection) < 0.95f)
        //{
        //direction = Vector3.Slerp(direction, lookDirection, Time.deltaTime);
        //SetArrowTransform(gameController);
        //}


        if (controller.GetButtonDown(GvrControllerButton.TouchPadButton))
        {
            gameController.GetThrowController().SetDirection(direction);
            gameController.SetState(State.THROWING);
        }
    }
예제 #14
0
    // Update is called once per frame
    void Update()
    {
        if (playVideo.startPlaying && !playVideo.videoPlayer.isPlaying && videoPlay)
        {
            videoPlay = false;
            playVideo.videoPlayer.enabled = false;
            playVideo.videoCanvas.SetActive(false);
            videoNum++;
            if (videoNum != videoFiles.Capacity)
            {
                playVideo.fileName = videoFiles[videoNum];
            }
            audioPlay = false;
            //Debug.Log("Video hidden");
        }

        if (!videoPlay && !audioPlay && !narratorAudio.isPlaying && audioNum != audioFiles.Capacity)
        {
            narratorAudio.clip = currAudio;
            narratorAudio.Play();
            audioPlay = true;
            //Debug.Log("Playing audio");
        }

        if (audioNum == 0 && audioPlay)
        {
            overlay.SetActive(true);
        }

        if (!narratorAudio.isPlaying && audioPlay && !videoPlay)
        {
            audioPlay = false;
            audioNum++;
            //Debug.Log(audioNum);
            videoPlay = true;
            if (audioNum != audioFiles.Capacity)
            {
                //Debug.Log("Switching tracks");
                currAudio = Resources.Load <AudioClip>("Audio/Section1/" + audioFiles[audioNum]);
            }
        }

        if (videoPlay && !audioPlay && videoNum != videoFiles.Capacity)
        {
            if (videoNum == 0 && sceneStarted)
            {
                //Debug.Log("Scene starting");
                playVideo.videoPlayer.enabled = true;
                playVideo.videoCanvas.SetActive(true);
            }
            if (videoNum == 1 && placed)
            {
                playVideo.videoPlayer.enabled = true;
                playVideo.videoCanvas.SetActive(true);
            }
            if (videoNum == 2 && markerReached && blocker)
            {
                playVideo.videoPlayer.enabled = true;
                playVideo.videoCanvas.SetActive(true);
            }
        }


        //Image disappears at correct time
        if (playVideo.videoPlayer.isPlaying && videoNum == 1 && playVideo.videoPlayer.time >= 39)
        {
            sceneObjects[1].SetActive(false);
        }


        //Make the plantation markers appear at the correct time
        if (playVideo.videoPlayer.isPlaying && videoNum == 1 && playVideo.videoPlayer.time >= 77)
        {
            sceneObjects[3].SetActive(true);
            sceneObjects[7].SetActive(true);
        }

        //Plantation markers disappear, cube showing user where to go appears
        if (!playVideo.videoPlayer.isPlaying && videoNum == 2)
        {
            sceneObjects[3].SetActive(false);
            sceneObjects[6].SetActive(true);
        }

        if (controller.GetButtonDown(GvrControllerButton.TouchPadButton))
        {
            Debug.Log("Video: " + !playVideo.videoPlayer.isPlaying + " Video num: " + (videoNum == 2) + " Faded " + !faded);
            if (!playVideo.videoPlayer.isPlaying && videoNum == 2 && !faded)
            {
                markerReached = true;
                sceneObjects[6].SetActive(false);
                visionBlocker.SetActive(true);
                //visionBlock.FadeIn();
                Debug.Log("Vision blocker fading in 1");
            }
        }

        if (markerReached && visionBlock.image.color.a == 1 && !blocker && time == 10000.0f)
        {
            //Debug.Log("setting time");
            faded = true;
            time  = Time.time;
        }

        //Debug.Log("time " + time);

        //Debug.Log("Marker reached: " + (markerReached) + " Faded in: " + faded + " blocker: " + !blocker + " Time met: " + (Time.time - time >= 2.0f));

        if (markerReached && faded && !blocker && Time.time - time >= 4.0f)
        {
            GvrBetaHeadset.SetSeeThroughConfig(GvrBetaSeeThroughCameraMode.Disabled, GvrBetaSeeThroughSceneType.Virtual);
            //visionBlock.FadeOut();
            Debug.Log("Vision blocker fading out 1");
            sceneObjects[0].SetActive(false);
            sceneObjects[3].SetActive(false);
            sceneObjects[6].SetActive(false);
            sceneObjects[4].SetActive(true);
            sceneObjects[8].SetActive(true);
            blocker = true;
            visionBlocker.SetActive(false);
            //visionBlock.FadeOut();
        }

        if (playVideo.videoPlayer.isPlaying && videoNum == 2)
        {
            sceneObjects[6].SetActive(false);
        }

        if (playVideo.videoPlayer.isPlaying && videoNum == 2 && playVideo.videoPlayer.time >= 26)
        {
            sceneObjects[4].SetActive(false);
            sceneObjects[8].SetActive(false);
            sceneObjects[5].SetActive(true);
            sceneObjects[9].SetActive(true);
        }

        if (playVideo.videoPlayer.isPlaying && videoNum == 2 && playVideo.videoPlayer.time >= 38 && !sceneEnding)
        {
            Debug.Log("Vision blocker fading in 2");
            visionBlocker.SetActive(true);
            time        = Time.time;
            sceneEnding = true;
        }

        if (playVideo.videoPlayer.isPlaying && videoNum == 2 && playVideo.videoPlayer.time >= 38.5f && sceneEnding)
        {
            sceneObjects[5].SetActive(false);
            sceneObjects[9].SetActive(false);
        }

        if (sceneEnding && Time.time - time >= 4.0f && visionBlocker.activeSelf)
        {
            Debug.Log("Vision blocker fading out 2");
            visionBlocker.SetActive(false);
            GvrBetaHeadset.SetSeeThroughConfig(GvrBetaSeeThroughCameraMode.RawImage, GvrBetaSeeThroughSceneType.Augmented);
        }

        /*
         * if(visionBlocker.activeSelf && videoNum == 2)
         * {
         *  visionBlocker.SetActive(false);
         * }
         *
         * if(markerReached && videoNum == 2)
         * {
         *  visionBlocker.SetActive(true);
         *  GvrBetaHeadset.SetSeeThroughConfig(GvrBetaSeeThroughCameraMode.Disabled, GvrBetaSeeThroughSceneType.Virtual);
         * }
         */

        if (imageOverlay.anchored && !placed)
        {
            placed = true;
            overlay.transform.position = player.transform.TransformPoint(Vector3.forward * 0 + Vector3.right * 0 + Vector3.down * 2);
            sceneObjects[0].SetActive(true);
            sceneObjects[1].SetActive(true);
        }
    }
예제 #15
0
    // Update is called once per frame
    void Update()
    {
        //if (gvrController.)

        // Double Click Judge
        if (Input.GetMouseButtonDown(0) || gvrController.GetButtonDown(GvrControllerButton.App))
        {
            IsDoubleClick = false;
            if (clickStartTime > 0)
            {
                if ((Time.time - clickStartTime) < 0.3f)
                {
                    IsDoubleClick = true;
                }
            }
            clickStartTime = Time.time;
        }

        if (IsDoubleClick)
        {
            Pause(!pause);
            IsDoubleClick = false;
        }

        if (IsPause)
        {
            return;
        }

        HitText.text    = HitCount.ToString();
        BittenText.text = BittenCount.ToString();

        if (currProg.status == WaniStatus.bye)
        {
            return;
        }

        elapsed  += Time.deltaTime;
        span     += Time.deltaTime;
        interval -= Time.deltaTime;

        if (span > currProg.time)
        {
            span     = 0;
            counter  = 0;
            currProg = WaniQ.Dequeue();
            Debug.Log(elapsed + " status = " + currProg.status);

            switch (currProg.status)
            {
            case WaniStatus.eatyou:
                aud.volume = 1;
                aud.PlayOneShot(EatYouSE);
                StartCoroutine(PlayBGM(1));
                break;

            case WaniStatus.angry:
                aud.Stop();
                aud.volume = 1;
                aud.PlayOneShot(AngrySE);

                EnableDeadLine(true);
                StartCoroutine(PlayBGM(1, true));
                break;

            case WaniStatus.finish:
                aud.Stop();
                StartCoroutine(Result());
                break;

            case WaniStatus.bye:
                aud.volume = 1;
                aud.PlayOneShot(SurrenderSE);
                break;

            default:
                break;
            }
        }
        else
        {
            if (interval > 0)
            {
                return;
            }


            switch (currProg.status)
            {
            case WaniStatus.wani1:
                if (counter == 0)
                {
                    Wani[2].GetComponent <WaniController>().Forward = true;
                }
                else
                {
                    Wani[Random.Range(0, 5)].GetComponent <WaniController>().Forward = true;
                }
                interval = 2;
                break;

            case WaniStatus.wani2:
                Shuffle(dat);

                Wani[dat[0]].GetComponent <WaniController>().Forward = true;
                Wani[dat[1]].GetComponent <WaniController>().Forward = true;

                interval = 2;

                break;

            case WaniStatus.wani3:

                Shuffle(dat);

                Wani[dat[0]].GetComponent <WaniController>().Forward = true;
                Wani[dat[1]].GetComponent <WaniController>().Forward = true;

                if (counter == 0 || counter == 2 || counter == 3)
                {
                    Wani[dat[2]].GetComponent <WaniController>().Forward = true;
                }

                interval = 2;
                break;

            case WaniStatus.wani4:
                if (counter == 0)
                {
                    Wani[0].GetComponent <WaniController>().Forward = true;
                    Shuffle(dat);
                }
                else if (counter < 5)
                {
                    Wani[counter].GetComponent <WaniController>().Forward = true;
                }
                else
                {
                    Wani[dat[counter % 5]].GetComponent <WaniController>().Forward = true;
                }

                interval = 1;

                break;

            case WaniStatus.wani5:
                if (counter % 2 == 0)
                {
                    Shuffle(dat);
                    Wani[dat[0]].GetComponent <WaniController>().Forward = true;
                    interval = 0.3f;
                }
                else
                {
                    Wani[dat[1]].GetComponent <WaniController>().Forward = true;
                    interval = 1.7f;
                }

                break;

            case WaniStatus.wani6:
                if (counter % 5 == 0)
                {
                    Shuffle(dat);
                }
                Wani[dat[counter % 5]].GetComponent <WaniController>().Forward = true;
                interval = 0.3f;
                break;

            default:
                break;
            }

            counter++;
        }
    }