Example #1
0
    // Update is called once per frame
    void Update()
    {
        if (GameStarted && !GameOver && Input.GetKeyUp(KeyCode.Escape))
        {
            //Fade music to volume
            pauseMenu.Toggle();
        }

        if (GameOver && waitUntilGameOverDismissal <= 0 && !CameraFade.Fading)
        {
            if (musicOn)
            {
                foreach (var playlistController in PlaylistController.Instances)
                {
                    var localPlaylist = playlistController;
                    localPlaylist.FadeToVolume(0f, 1f, () => {
                        localPlaylist.StopPlaylist();
                        localPlaylist.PlaylistVolume = 1f;
                    });
                }
                musicOn = false;
            }

            if (Input.GetMouseButtonUp((int)Mouse.LeftButton) || Input.anyKey)
            {
                CameraFade.StartAlphaFade(Color.white, false, 1.2f, 0f, () => { PersistentUtility.Instance.GoToScene("ScoreScene"); });
            }
        }

        if (waitUntilGameOverDismissal > 0)
        {
            waitUntilGameOverDismissal -= Time.deltaTime;
        }

        if (!Mathf.Approximately(prevAspectRatio, mainCamera.camera.aspect))
        {
            InitializeCamera();
        }
    }