コード例 #1
0
        // This is called from outside to return the player to the specified scene
        public IEnumerator GoToSpecificScene(int sceneIndex)
        {
            if (fadeOverlay == null)
            {
                fadeOverlay = GameObject.FindWithTag("FadeUI").GetComponent <Image>();
            }

            fadeOverlay.CrossFadeAlpha(1, fadeTime, true);
            yield return(new WaitForSeconds(fadeTime));

            // We load to the new scene
            LoadingScreenManager.LoadScene(sceneIndex);
        }
コード例 #2
0
        // This is used to time the transition
        private IEnumerator TravelCutscene(GameObject player)
        {
            // Getting the proper components
            CharacterController playerController = player.GetComponent <CharacterController>();

            // We stop the player from moving and fade to black
            fadeOverlay.CrossFadeAlpha(1, fadeTime, true);
            yield return(new WaitForSeconds(fadeTime));

            if (toNewScene == true)
            {
                // We load to the new scene and exit
                LoadingScreenManager.LoadScene(newSceneIndex);
                yield return(null);
            }
            else
            {
                // We then teleport the player, change their respawn point
                playerController.WarpCharacter(travelSpot.position);
                yield return(new WaitForFixedUpdate());

                // We set the camera to have new bounds so that it will properly show the player
                GameManager.Instance.MainCamera.minXPos = cameraMinX;
                GameManager.Instance.MainCamera.maxXPos = cameraMaxX;
                GameManager.Instance.MainCamera.minYPos = cameraMinY;
                GameManager.Instance.MainCamera.maxYPos = cameraMaxY;
                GameManager.Instance.MainCamera.minZPos = cameraMinZ;
                GameManager.Instance.MainCamera.maxZPos = cameraMaxZ;
                yield return(new WaitForFixedUpdate());

                // We then tell the transition to fade back in
                fadeOverlay.CrossFadeAlpha(0, fadeTime, true);
                yield return(new WaitForSeconds(fadeTime));

                // We tell this invoke we are done!
                GameManager.Instance.CurrentState = GameStates.NORMAL;
                yield return(null);
            }
        }