Exemplo n.º 1
0
        private void Update()
        {
            // todo: disable pausing when game finished


            // EVENT: onGamePaused
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                ExperimentalPauseAndShowMenu.Instance.Pause();
            }

            PlayerMovement();

            if (ExperimentalPauseAndShowMenu.Instance.isPaused)
            {
                return;
            }

            // MARK: Pauseable actions below
            CheckGazeOnSlenderman();

            if (cardboardController.IsGettingCollectable())
            {
                PlayerCollectPage();
            }

            // EVENT: onFlashlightToggled
            if (Input.GetKeyDown(KeyCode.F))
            {
                ExperimentalGameEventManager.InvokeFlashlightToggled();
            }
        }
Exemplo n.º 2
0
        private void CheckGazeOnSlenderman()
        {
            if (gameManager.slenderman == null)
            {
                return;
            }

            Transform slenderman = gameManager.slenderman.transform;
            Transform player     = transform;

            float distance = Vector3.Distance(slenderman.position, player.position);
            float angle    = Vector3.Angle(mainCamera.transform.forward, slenderman.position - player.position);

            if (distance < viewDistance && angle < viewAngle)
            {
                RaycastHit hit;
                if (Physics.Raycast(player.position,
                                    slenderman.position - player.position,
                                    out hit,
                                    viewDistance))
                {
                    if (hit.transform.name == slenderman.name)
                    {
                        // EVENT: onPlayerViewEntered
                        ExperimentalGameEventManager.InvokePlayerViewEntered();
                    }
                }
            }
            else
            {
                // EVENT: onNotPlayerViewEntered
                ExperimentalGameEventManager.InvokeNotPlayerViewEntered();
            }
        }
        public void Pause()
        {
            isPaused = !isPaused;

            // EVENT: onGamePaused
            ExperimentalGameEventManager.InvokeGamePaused();

            if (isPaused)
            {
                Time.timeScale      = 0;
                AudioListener.pause = true;

                worldLight.intensity = 0;

                GetComponent <Canvas>().enabled = true;
            }
            else
            {
                Time.timeScale      = 1;
                AudioListener.pause = false;

                worldLight.intensity = initialLighting;

                GetComponent <Canvas>().enabled = false;
            }
        }
Exemplo n.º 4
0
        private void PlayerCollectPage()
        {
            // EVENT: onGettingCollectable
            ExperimentalGameEventManager.InvokeGettingCollectable();
            cardboardController.GetCollectable();

            // EVENT: onGotCollectable
            ExperimentalGameEventManager.InvokeGotCollectable();
        }
        private void Update()
        {
            // EVENT: onGameWon
            if (pagesCollected == pagesToCollect)
            {
                ExperimentalGameEventManager.InvokeGameWon();
            }

            // EVENT: onGameLost
            if (timeGazedSlender >= maxTimeGazingSlender)
            {
                ExperimentalGameEventManager.InvokeGameLost();
            }
            else if (isTimed)
            {
                if (timeElapsed >= gameTimer)
                {
                    ExperimentalGameEventManager.InvokeGameLost();
                }
                timeElapsed += Time.deltaTime;
            }
        }