public IEnumerator MarketTransition()
    {
        if (CurrentLocation != Location.MAIN)
        {
            yield return(StartCoroutine(ResetTransition()));
        }
        CurrentLocation = Location.MARKET;
        MainCam.LerpToTransform(Market.ObjectCamera.transform.position, Market.ObjectCamera.transform.rotation.eulerAngles);
        yield return(new WaitForSeconds(MainCam.LerpTime - MainCamFade.Duration * 0.95f));

        MainCamFade.FadeOut();
        yield return(new WaitForSeconds(MainCamFade.Duration));

        MainCam.transform.position = DrawHall.DrawCamera.transform.position;
        MainCam.transform.rotation = DrawHall.DrawCamera.transform.rotation;
        MainCamFade.FadeIn();
        yield return(true);
    }
示例#2
0
    private IEnumerator LoadGameLevelWithFade(string levelToLoad, bool setAsCurrentLevel, bool setAsActiveLevel, bool useFadeEffect = false, bool unloadOtherScenes = false)
    {
        if (useFadeEffect)
        {
            FadeCamera.FadeOut();

            while (FadeCamera.CurrentFadeLevel < 1f)
            {
                yield return(null);
            }
        }

        SceneManager.LoadScene(levelToLoad, LoadSceneMode.Additive);

        if (setAsCurrentLevel)
        {
            SelectCurrentLevel(levelToLoad);
        }

        Scene sceneToLoad = SceneManager.GetSceneByName(levelToLoad);

        if (setAsCurrentLevel)
        {
            CurrentGameScene = sceneToLoad;
        }

        while (sceneToLoad.isLoaded == false)
        {
            yield return(null);
        }

        if (setAsActiveLevel)
        {
            SceneManager.SetActiveScene(sceneToLoad);
        }

        if (unloadOtherScenes)
        {
            for (int i = 0; i < SceneManager.sceneCount; i++)
            {
                Scene sceneToUnload = SceneManager.GetSceneAt(i);

                if (sceneToUnload.buildIndex == sceneToLoad.buildIndex)
                {
                    continue;
                }

                SceneManager.UnloadSceneAsync(sceneToUnload);
            }
        }

        yield return(null);

        if (useFadeEffect)
        {
            FadeCamera.FadeIn();

            while (FadeCamera.CurrentFadeLevel > 0f)
            {
                yield return(null);
            }
        }

        IsLoadingScene = false;
    }