Beispiel #1
0
 public virtual void RestartGame()
 {
     ShowLoadInProgress();
     if (useLoadingScene)
     {
         PersistentDataManager.LevelWillBeUnloaded();
         DialogueManager.ResetDatabase(DatabaseResetOptions.RevertToDefault);
         LoadingScene.SetDestinationScene(firstGameplaySceneIndex);
         SceneManager.LoadScene(loadingSceneIndex);
     }
     else
     {
         FindLevelManager();
         if (levelManager != null)
         {
             levelManager.RestartGame();
         }
         else
         {
             PersistentDataManager.LevelWillBeUnloaded();
             DialogueManager.ResetDatabase(DatabaseResetOptions.RevertToDefault);
             SceneManager.LoadScene(firstGameplaySceneIndex);
         }
     }
 }
Beispiel #2
0
        public virtual void LoadLevel(string levelName, int loadingSceneIndex = -1)
        {
            ShowLoadInProgress();
            var loadingSceneIndexToUse = (loadingSceneIndex == -1) ? this.loadingSceneIndex : loadingSceneIndex;

            if (useLoadingScene)
            {
                PersistentDataManager.Record();
                LoadingScene.SetDestinationScene(levelName);
                PersistentDataManager.LevelWillBeUnloaded();
                SceneManager.LoadScene(loadingSceneIndexToUse);
            }
            else
            {
                FindLevelManager();
                if (levelManager != null)
                {
                    levelManager.LoadLevel(levelName);
                }
                else
                {
                    PersistentDataManager.Record();
                    PersistentDataManager.LevelWillBeUnloaded();
                    SceneManager.LoadScene(levelName);
                    PersistentDataManager.Apply();
                }
            }
        }
Beispiel #3
0
        public virtual void LoadGameNow(int slotNum)
        {
            var saveData = (LoadSlotHandler == null) ? PlayerPrefs.GetString(GetSlotDataKey(slotNum)) : LoadSlotHandler(slotNum);

            if (useLoadingScene)
            {
                PersistentDataManager.LevelWillBeUnloaded();
                LoadingScene.SetLoadGameData(saveData);
                SceneManager.LoadScene(loadingSceneIndex);
            }
            else
            {
                FindLevelManager();
                if (levelManager != null)
                {
                    levelManager.LoadGame(saveData);
                }
                else
                {
                    Lua.Run(saveData, true);
                    PersistentDataManager.LevelWillBeUnloaded();
                    if (DialogueLua.DoesVariableExist("SavedLevelName"))
                    {
                        Tools.LoadLevel(DialogueLua.GetVariable("SavedLevelName").AsString);
                    }
                    else
                    {
                        RestartGame();
                    }
                    PersistentDataManager.ApplySaveData(saveData, DatabaseResetOptions.KeepAllLoaded);
                }
            }
        }