Beispiel #1
0
        public static void LoadGameState(int slot)
        {
            string savePath = GetGameSavePath(slot);

            if (!File.Exists(savePath))
            {
                Debug.LogError("No Save File Found For Slot " + slot.ToString());
                return;
            }

            Debug.Log("Starting Load");

            isLoadingSaveSlot = true;

            GameSaveStateInfo savedStateInfo = GetSaveDescription(slot);

            string sceneFromSave = savedStateInfo.sceneName;

            // load the actual save state
            Action <LoadSceneMode> onSceneStartLoad = (mode) => gameSaveState.Reinitialize((Dictionary <string, object>)SystemTools.LoadFromFile(savePath));

            Action <string, LoadSceneMode> onSceneLoaded = (s, mode) => isLoadingSaveSlot = false;

            if (!SceneLoading.LoadSceneAsync(sceneFromSave, onSceneStartLoad, onSceneLoaded, LoadSceneMode.Single, false))
            {
                isLoadingSaveSlot = false;
            }
        }
Beispiel #2
0
        public static void FastTravelTo(string scene, string fastTravelTargetName)
        {
            if (string.IsNullOrEmpty(scene))
            {
                // Debug.LogWarning("No Scene Specified");
                return;
            }

            fastTravelling = true;
            FastTravel.fastTravelTargetName = fastTravelTargetName;

            // if we're not specifying a target, use our default one if
            // specified

            if (getFastTravelDefaultPosition != null)
            {
                if (string.IsNullOrEmpty(fastTravelTargetName))
                {
                    Vector3 pos;
                    if (getFastTravelDefaultPosition(scene, out pos))
                    {
                        FastTravel.fastTravelTargetName = useRawPositionKey;
                        fastTravelTargetPosition        = pos;
                    }
                }
            }


            SceneLoading.LoadSceneAsync(scene, null, null, LoadSceneMode.Single, false);
        }
Beispiel #3
0
 static void LoadInitializationScenes()
 {
     for (int i = 0; i < settings.initSceneNames.Length; i++)
     {
         SceneLoading.LoadSceneAsync(settings.initSceneNames[i], null, null, LoadSceneMode.Additive, false);
     }
 }
Beispiel #4
0
 static void LoadAdditiveMainMenuScenes()
 {
     for (int i = 0; i < settings.mmSceneNames.Length; i++)
     {
         SceneLoading.LoadSceneAsync(settings.mmSceneNames[i], null, null, LoadSceneMode.Additive, false);
     }
 }
Beispiel #5
0
        static void _QuitToMainMenu()
        {
            // load the additive main menu scenes after we load the main menu scene
            Action <string, LoadSceneMode> onSceneLoaded = (s, m) => LoadAdditiveMainMenuScenes();

            SceneLoading.LoadSceneAsync(mainMenuScene, null, onSceneLoaded, LoadSceneMode.Single, false);
        }
Beispiel #6
0
        static void OnApplicationStartAfterMainMenuLoad()
        {
            // Debug.Log("Setting Main Menu as Active Scene");
            SceneLoading.SetActiveScene(mainMenuScene);

            // Debug.Log("Loading Initialization Scenes");
            LoadInitializationScenes();

            // Debug.Log("Loading Additional Main Menu Scenes");
            LoadAdditiveMainMenuScenes();

            SceneLoading.onSceneLoadStart += OnSceneLoadStart;
        }
Beispiel #7
0
        void Start()
        {
            if (!thisInstanceErrored)
            {
                SceneLoading.SetActiveScene(InitializationScenes.mainInitializationScene);

                SaveLoad.LoadSettingsOptions();

                // #if UNITY_EDITOR
                StartCoroutine(SkipToScene());
                // #endif

                // just to not get stuck in full screen mode...
                StartCoroutine(QuitDebug());
            }
        }
Beispiel #8
0
        static void _LoadGame(int slot)
        {
            string savePath = GetGameStatePath(slot, saveExtension);

            if (!File.Exists(savePath))
            {
                Debug.LogError("No Save File Found For Slot " + slot);
                return;
            }

            Debug.Log("Loading game slot " + slot);

            isLoadingSave = true;

            // try and load teh scene from the save state:

            // load the actual save state (if the scene starts loading)
            Action <LoadSceneMode> onSceneStartLoad = (m) => {
                Debug.Log("Loading State From File");
                gameSaveState.SetState((Dictionary <string, object>)IOTools.LoadFromFile(savePath));

                Debug.Log("On Load Game Event");
                if (onGameLoaded != null)
                {
                    onGameLoaded();
                }
            };

            // when the scene is done loading, set 'isLoadingSave' to false
            Action <string, LoadSceneMode> onSceneLoaded = (s, m) => isLoadingSave = false;

            Debug.Log("Getting Save Descriptor");
            SaveStateInfo descriptor = GetSaveDescription(slot);

            Debug.Log("Loading Saved Scene: " + descriptor.sceneName);
            // if theres a problem and this returns false, set 'isLoadingSave' to false
            if (!SceneLoading.LoadSceneAsync(descriptor.sceneName, onSceneStartLoad, onSceneLoaded, LoadSceneMode.Single, false))
            {
                isLoadingSave = false;
            }
        }
Beispiel #9
0
        IEnumerator SkipToScene(string scene)
        {
            yield return(new WaitForSecondsRealtime(3));

            SceneLoading.LoadSceneAsync(scene, null, null);
        }
Beispiel #10
0
 public static void QuitToMainMenu()
 {
     SaveLoad.ClearGameSaveState();
     SceneLoading.LoadSceneAsync(mainMenuScene, null, null);
 }
Beispiel #11
0
 public static void StartNewGame()
 {
     DestroyPlayer();
     SaveLoad.ClearGameSaveState();
     SceneLoading.LoadSceneAsync(settings.newGameScene, null, null);
 }
 static void MovePlayerToUnloadedScene(string scene, MiniTransform target)
 {
     movingPlayer     = true;
     movePlayerTarget = target;
     SceneLoading.LoadSceneAsync(scene, null, null, LoadSceneMode.Single, false);
 }