public static void CloseBattleScene()
    {
        if (!battleSceneInUse)
        {
            Debug.LogError("Battle trying to be closed while battle not already active");
            return;
        }

        Scene freeRoamScene = sceneRecordStack.Peek().scene;
        FreeRoamSceneController freeRoamSceneController = GetFreeRoamSceneController(freeRoamScene);

        StartFadeOut();

        FadeOutComplete += () =>
        {
            PlayerGameObject.GetComponent <PlayerController>().SetMoveDelay(sceneChangePlayerMoveDelay);

            battleSceneInUse = false;

            SceneManager.SetActiveScene(freeRoamScene);

            //Wait until old scene unloaded before starting next scene
            SceneManager.UnloadSceneAsync(battleScene).completed += (ao) =>
            {
                freeRoamSceneController.SetDoorsEnabledState(true);
                freeRoamSceneController.SetEnabledState(true);
                StartFadeIn();
            };
        };
    }
Beispiel #2
0
    public static void LaunchTradeScene()
    {
        if (tradeScene != null)
        {
            Debug.LogError("Trade trying to be launched while battle already active");
            return;
        }

        if (pausedFreeRoamScene != null)
        {
            Debug.LogError("Trying to launch trade scene while there is already a paused scene");
            return;
        }

        pausedFreeRoamScene = CurrentScene;
        FreeRoamSceneController pausedSceneController = GetFreeRoamSceneController((Scene)pausedFreeRoamScene);

        pausedSceneController.SetDoorsEnabledState(false);
        pausedSceneController.SetSceneRunningState(false);

        StartFadeOut();

        FadeOutComplete += () =>
        {
            pausedSceneController.SetSceneRunningState(true);
            pausedSceneController.SetEnabledState(false);

            int newSceneIndex = SceneManager.sceneCount;

            AsyncOperation loadSceneOperation = SceneManager.LoadSceneAsync(tradeSceneIdentifier, LoadSceneMode.Additive);

            loadSceneOperation.completed += (ao) =>
            {
                tradeScene = SceneManager.GetSceneAt(newSceneIndex);

                Trade.TradeManager tradeManager = Trade.TradeManager.GetTradeSceneTradeManager((Scene)tradeScene);

                SceneManager.SetActiveScene((Scene)tradeScene);

                StartFadeIn();

                FadeInComplete += () =>
                {
                    tradeManager.StartTradeScene();
                };
            };
        };
    }
    public static void LaunchBattleScene()
    {
        RefreshCurrentSceneStack();

        if (battleSceneInUse)
        {
            Debug.LogError("Battle trying to be launched while battle already active");
            return;
        }

        Scene freeRoamScene = sceneRecordStack.Peek().scene;
        FreeRoamSceneController freeRoamSceneController = GetFreeRoamSceneController(freeRoamScene);

        freeRoamSceneController.SetDoorsEnabledState(false);
        freeRoamSceneController.SetSceneRunningState(false);

        StartFadeOut();

        FadeOutComplete += () =>
        {
            freeRoamSceneController.SetSceneRunningState(true);
            freeRoamSceneController.SetEnabledState(false);

            //https://low-scope.com/unity-quick-get-a-reference-to-a-newly-loaded-scene/
            int newSceneIndex = SceneManager.sceneCount;

            AsyncOperation loadSceneOperation = SceneManager.LoadSceneAsync(battleSceneIdentifier, LoadSceneMode.Additive);

            loadSceneOperation.completed += (ao) =>
            {
                battleScene      = SceneManager.GetSceneAt(newSceneIndex);
                battleSceneInUse = true;

                Battle.BattleManager battleManager = Battle.BattleManager.GetBattleSceneBattleManager(battleScene);

                SceneManager.SetActiveScene(battleScene);

                StartFadeIn();

                FadeInComplete += () =>
                {
                    battleManager.StartBattle();
                };
            };
        };
    }
Beispiel #4
0
    public static void CloseTradeScene()
    {
        if (tradeScene == null)
        {
            Debug.LogError("Trade trying to be closed while battle not active");
            return;
        }

        if (pausedFreeRoamScene == null)
        {
            Debug.LogError("Trying to close trade scene while there is no paused scene to return to");
            return;
        }

        FreeRoamSceneController pausedSceneController = GetFreeRoamSceneController((Scene)pausedFreeRoamScene);

        StartFadeOut();

        FadeOutComplete += () =>
        {
            PlayerGameObject.GetComponent <PlayerController>().SetMoveDelay(sceneChangePlayerMoveDelay);

            SceneManager.SetActiveScene((Scene)pausedFreeRoamScene);

            //Wait until old scene unloaded before starting next scene
            SceneManager.UnloadSceneAsync((Scene)tradeScene).completed += (ao) =>
            {
                pausedSceneController.SetDoorsEnabledState(true);
                pausedSceneController.SetEnabledState(true);

                CloseTradeScene_Variables();

                PlayerGameObject.GetComponent <PlayerController>().PlaySceneAreaMusic();

                StartFadeIn();
            };
        };
    }