Example #1
0
    protected IEnumerator LoadSceneRoutine(string scene, ActorInfo actorInfo)
    {
        isLoadingScene = true;
        LocalUserInfo.Me.ClientCharacter = actorInfo;

        yield return(InGameMainMenuUI.Instance.StartFadeCoroutine(InGameMainMenuUI.Instance.FadeInRoutine()));

        string lastScene = SceneManager.GetActiveScene().name;

        ResourcesLoader.Instance.ClearObjectPool();

        CurrentScene = null;

        SceneManager.LoadScene(scene);

        yield return(0);

        while (!SceneManager.GetSceneByName(scene).isLoaded)
        {
            yield return(0);
        }

        CurrentScene = new SceneControl();

        SocketClient.Instance.EmitLoadedScene(actorInfo);

        while (GameCamera.Instance == null)
        {
            yield return(0);
        }

        for (int i = 0; i < SceneInfo.Instance.RoomAbilities.Count; i++)
        {
            actorInfo.AddRoomPrimaryAbility(SceneInfo.Instance.RoomAbilities[i]);
        }

        if (SceneTimerInstance != null)
        {
            StopCoroutine(SceneTimerInstance);
            SceneTimerInstance = null;
        }

        if (SceneInfo.Instance.Timer > 0)
        {
            SceneTimerInstance = StartCoroutine(SceneTimerRoutine(SceneInfo.Instance.Timer));
        }

        GameCamera.Instance.Register(CurrentScene.ClientCharacter.Instance.gameObject);


        InGameMainMenuUI.Instance.ShowGameUI();

        CurrentScene.UpdateAllQuestProgress();

        AudioControl.Instance.SetMusic(SceneInfo.Instance.BGMusic);

        GameCamera.Instance.InstantFocusCamera();

        MovingTroughPortal = false;
        InGame             = true;
        yield return(InGameMainMenuUI.Instance.StartFadeCoroutine(InGameMainMenuUI.Instance.FadeOutRoutine()));

        InGameMainMenuUI.Instance.SetLocationLabel(SceneInfo.Instance.DisplayName);

        isLoadingScene = false;
    }