Exemplo n.º 1
0
        public void Start()
        {
            var levelName         = GetParameter(0);
            var loadingSceneIndex = GetParameterAsInt(1, -1);
            var spawnpoint        = GetParameter(2);

            if (string.IsNullOrEmpty(levelName))
            {
                if (DialogueDebug.LogWarnings)
                {
                    Debug.LogWarning("Dialogue System: Sequencer: LoadingSceneTo(" + GetParameters() + ") level name is an empty string");
                }
            }
            else
            {
                if (DialogueDebug.LogInfo)
                {
                    Debug.Log("Dialogue System: Sequencer: LoadingSceneTo(" + levelName + ", " + loadingSceneIndex + ", " + spawnpoint + ")");
                }
                DialogueLua.SetActorField("Player", "Spawnpoint", spawnpoint);
                var saveHelper = FindObjectOfType <SaveHelper>();
                if (saveHelper != null)
                {
                    saveHelper.LoadLevel(levelName, loadingSceneIndex);
                }
                else
                {
                    PersistentDataManager.LevelWillBeUnloaded();
                    LoadingScene.SetDestinationScene(levelName);
                    SceneManager.LoadScene(loadingSceneIndex);
                }
            }
            Stop();
        }
Exemplo n.º 2
0
 public virtual void ReturnToTitleMenu()
 {
     DialogueManager.ResetDatabase(DatabaseResetOptions.RevertToDefault);
     PersistentDataManager.LevelWillBeUnloaded();
     SceneManager.LoadScene(FindObjectOfType <TitleMenu>().titleSceneIndex);
     FindObjectOfType <TitleMenu>().titleMenuPanel.Open();
 }
Exemplo n.º 3
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);
         }
     }
 }
Exemplo n.º 4
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();
                }
            }
        }
Exemplo n.º 5
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);
                }
            }
        }
        public void Start()
        {
            string levelName = GetParameter(0);

            /*;*/
            if (string.IsNullOrEmpty(levelName))
            {
                if (DialogueDebug.LogWarnings)
                {
                    Debug.LogWarning(string.Format("{0}: Sequencer: LoadLevel() level name is an empty string", DialogueDebug.Prefix));
                }
            }
            else
            {
                if (DialogueDebug.LogInfo)
                {
                    Debug.Log(string.Format("{0}: Sequencer: LoadLevel({1})", DialogueDebug.Prefix, levelName));
                }
                var levelManager = FindObjectOfType <LevelManager>();
                if (levelManager != null)
                {
                    levelManager.LoadLevel(levelName);
                }
                else
                {
                    PersistentDataManager.Record();
                    PersistentDataManager.LevelWillBeUnloaded();
                    GameObject.Find("Loader").SendMessage("LoadLevel", levelName);                    //Application.LoadLevel(levelName);
                    PersistentDataManager.Apply();
                }
            }
            Stop();
        }
Exemplo n.º 7
0
        public void Start()
        {
            string levelName  = GetParameter(0);
            string spawnpoint = GetParameter(1);
            bool   additive   = string.Equals(GetParameter(2), "additive", System.StringComparison.OrdinalIgnoreCase);

            if (string.IsNullOrEmpty(levelName))
            {
                if (DialogueDebug.logWarnings)
                {
                    Debug.LogWarning(string.Format("{0}: Sequencer: LoadLevel() level name is an empty string", DialogueDebug.Prefix));
                }
            }
            else
            {
                if (DialogueDebug.logInfo)
                {
                    Debug.Log(string.Format("{0}: Sequencer: LoadLevel({1})", DialogueDebug.Prefix, GetParameters()));
                }
                DialogueLua.SetActorField("Player", "Spawnpoint", spawnpoint);
                var saveSystem = FindObjectOfType <SaveSystem>();
                if (saveSystem != null)
                {
                    if (additive)
                    {
                        SaveSystem.LoadAdditiveScene(levelName);
                    }
                    else
                    {
                        PersistentDataManager.LevelWillBeUnloaded();
                        SaveSystem.LoadScene(string.IsNullOrEmpty(spawnpoint) ? levelName : levelName + "@" + spawnpoint);
                    }
                }
                else
                {
                    if (additive)
                    {
                        UnityEngine.SceneManagement.SceneManager.LoadScene(levelName, UnityEngine.SceneManagement.LoadSceneMode.Additive);
                    }
                    else
                    {
                        var levelManager = FindObjectOfType <LevelManager>();
                        if (levelManager != null)
                        {
                            levelManager.LoadLevel(levelName);
                        }
                        else
                        {
                            PersistentDataManager.Record();
                            PersistentDataManager.LevelWillBeUnloaded();
                            UnityEngine.SceneManagement.SceneManager.LoadScene(levelName, UnityEngine.SceneManagement.LoadSceneMode.Single);
                            PersistentDataManager.Apply();
                        }
                    }
                }
            }
            Stop();
        }
Exemplo n.º 8
0
        private void RestartGame()
        {
            Debug.Log("Restarting game");
            FPSyncLuaPlayerOnLoadLevel syncOnLoad = DialogueManager.Instance.GetComponent <FPSyncLuaPlayerOnLoadLevel>();

            if (syncOnLoad != null)
            {
                syncOnLoad.dontApplyLuaNextLoadLevel = true;
            }
            PersistentDataManager.LevelWillBeUnloaded();
            DialogueManager.ResetDatabase(DatabaseResetOptions.RevertToDefault);
            Application.LoadLevel(0);
        }
Exemplo n.º 9
0
        private void LoadGame()
        {
            PersistentDataManager.LevelWillBeUnloaded();
            var saveSystem = FindObjectOfType <SaveSystem>();

            if (saveSystem != null)
            {
                if (SaveSystem.HasSavedGameInSlot(1))
                {
                    SaveSystem.LoadFromSlot(1);
                    DialogueManager.ShowAlert("Game loaded.");
                }
                else
                {
                    DialogueManager.ShowAlert("Save a game first.");
                }
            }
            else
            {
                if (PlayerPrefs.HasKey("SavedGame"))
                {
                    string saveData = PlayerPrefs.GetString("SavedGame");
                    Debug.Log("Load Game Data: " + saveData);
                    LevelManager levelManager = FindObjectOfType <LevelManager>();
                    if (levelManager != null)
                    {
                        levelManager.LoadGame(saveData);
                    }
                    else
                    {
                        PersistentDataManager.ApplySaveData(saveData);
                        DialogueManager.SendUpdateTracker();
                    }
                    DialogueManager.ShowAlert("Game loaded.");
                }
                else
                {
                    DialogueManager.ShowAlert("Save a game first.");
                }
            }
        }
        public void Start()
        {
            string levelName  = GetParameter(0);
            string spawnpoint = GetParameter(1);

            if (string.IsNullOrEmpty(levelName))
            {
                if (DialogueDebug.LogWarnings)
                {
                    Debug.LogWarning(string.Format("{0}: Sequencer: LoadLevel() level name is an empty string", DialogueDebug.Prefix));
                }
            }
            else
            {
                if (DialogueDebug.LogInfo)
                {
                    Debug.Log(string.Format("{0}: Sequencer: LoadLevel({1})", DialogueDebug.Prefix, GetParameters()));
                }
                DialogueLua.SetActorField("Player", "Spawnpoint", spawnpoint);
                var levelManager = FindObjectOfType <LevelManager>();
                if (levelManager != null)
                {
                    levelManager.LoadLevel(levelName);
                }
                else
                {
                    PersistentDataManager.Record();
                    PersistentDataManager.LevelWillBeUnloaded();
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
                    UnityEngine.SceneManagement.SceneManager.LoadScene(levelName, UnityEngine.SceneManagement.LoadSceneMode.Single);
#else
                    Application.LoadLevel(levelName);
#endif
                    PersistentDataManager.Apply();
                }
            }
            Stop();
        }
Exemplo n.º 11
0
        public void Start()
        {
            var levelName  = GetParameter(0);
            var spawnpoint = GetParameter(2);

            if (string.IsNullOrEmpty(levelName))
            {
                if (DialogueDebug.LogWarnings)
                {
                    Debug.LogWarning("Dialogue System: Sequencer: LoadingSceneTo(" + GetParameters() + ") level name is an empty string. Loading by scene index is no longer supported.");
                }
            }
            {
                if (DialogueDebug.LogInfo)
                {
                    Debug.Log("Dialogue System: Sequencer: LoadingSceneTo(" + levelName + ",(ignored), " + spawnpoint + ")");
                }
                var s = string.IsNullOrEmpty(spawnpoint) ? levelName : (levelName + "@" + spawnpoint);
                PersistentDataManager.LevelWillBeUnloaded();
                SaveSystem.LoadScene(s);
            }
            Stop();
        }
        public void Start()
        {
            string levelName = GetParameter(0);

            if (string.IsNullOrEmpty(levelName))
            {
                if (DialogueDebug.LogWarnings)
                {
                    Debug.LogWarning(string.Format("{0}: Sequencer: LoadLevel() level name is an empty string", DialogueDebug.Prefix));
                }
            }
            else
            {
                if (DialogueDebug.LogInfo)
                {
                    Debug.Log(string.Format("{0}: Sequencer: LoadLevel({1})", DialogueDebug.Prefix, levelName));
                }
                PersistentDataManager.Record();
                PersistentDataManager.LevelWillBeUnloaded();
                Application.LoadLevel(levelName);
            }
            Stop();
        }
Exemplo n.º 13
0
        public void Start()
        {
            string levelName = GetParameter(0);

            if (string.IsNullOrEmpty(levelName))
            {
                if (DialogueDebug.LogWarnings)
                {
                    Debug.LogWarning(string.Format("{0}: Sequencer: LoadLevel() level name is an empty string", DialogueDebug.Prefix));
                }
            }
            else
            {
                if (DialogueDebug.LogInfo)
                {
                    Debug.Log(string.Format("{0}: Sequencer: LoadLevel({1})", DialogueDebug.Prefix, levelName));
                }
                var levelManager = FindObjectOfType <LevelManager>();
                if (levelManager != null)
                {
                    levelManager.LoadLevel(levelName);
                }
                else
                {
                    PersistentDataManager.Record();
                    PersistentDataManager.LevelWillBeUnloaded();
                                        #if UNITY_4_6 || UNITY_4_7 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2
                    Application.LoadLevel(levelName);
                                        #else
                    SceneManager.LoadScene(levelName);
                                        #endif
                    PersistentDataManager.Apply();
                }
            }
            Stop();
        }
Exemplo n.º 14
0
 public override void OnEnter()
 {
     PersistentDataManager.LevelWillBeUnloaded();
     Finish();
 }
Exemplo n.º 15
0
        public override void OnEnter()
        {
            string level = (levelName == null) ? null : levelName.Value;

            if (string.IsNullOrEmpty(level))
            {
                LogError("Level name is an empty string");
            }
            else
            {
                if (dontDestroyOnLoad.Value)
                {
                    var root = Owner.transform.root;
                    UnityEngine.Object.DontDestroyOnLoad(root.gameObject);
                }
                var levelManager = GameObject.FindObjectOfType <LevelManager>();
                if (levelManager != null && !resetDialogueDatabase)
                {
                    levelManager.LoadLevel(level);
                }
                else
                {
                    PersistentDataManager.LevelWillBeUnloaded();
                    if (resetDialogueDatabase)
                    {
                        DatabaseResetOptions databaseResetOption = resetToInitialDatabase ? DatabaseResetOptions.RevertToDefault : DatabaseResetOptions.KeepAllLoaded;
                        DialogueManager.ResetDatabase(databaseResetOption);
                    }
                    else
                    {
                        if (resetToInitialDatabase)
                        {
                            LogWarning("Reset To Initial Database is ticked, but it has no effect because Reset Dialogue Database is unticked.");
                        }
                        PersistentDataManager.Record();
                    }
#if UNITY_4_6 || UNITY_4_7 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2
                    if (async)
                    {
                        if (additive)
                        {
                            asyncOperation = Application.LoadLevelAdditiveAsync(level);
                        }
                        else
                        {
                            asyncOperation = Application.LoadLevelAsync(level);
                        }
                        return; // Don't finish yet.
                    }
                    else
                    {
                        if (additive)
                        {
                            Application.LoadLevelAdditive(level);
                        }
                        else
                        {
                            Application.LoadLevel(level);
                        }
#else
                    if (async)
                    {
                        if (additive)
                        {
                            asyncOperation = SceneManager.LoadSceneAsync(level, LoadSceneMode.Additive);
                        }
                        else
                        {
                            asyncOperation = SceneManager.LoadSceneAsync(level);
                        }
                        return;                         // Don't finish yet.
                    }
                    else
                    {
                        if (additive)
                        {
                            SceneManager.LoadScene(level, LoadSceneMode.Additive);
                        }
                        else
                        {
                            SceneManager.LoadScene(level);
                        }
#endif
                    }
                }
            }
            DoneLoadingLevel();
        }
Exemplo n.º 16
0
        public override void OnEnter()
        {
            string level = (levelName == null) ? null : levelName.Value;

            if (string.IsNullOrEmpty(level))
            {
                LogError("Level name is an empty string");
            }
            else
            {
                if (dontDestroyOnLoad.Value)
                {
                    var root = Owner.transform.root;
                    UnityEngine.Object.DontDestroyOnLoad(root.gameObject);
                }

                DialogueLua.SetActorField("Player", "Spawnpoint", spawnpoint);
                var saveSystem = GameObject.FindObjectOfType <SaveSystem>();
                if (saveSystem != null)
                {
                    PersistentDataManager.LevelWillBeUnloaded();
                    SaveSystem.LoadScene(string.IsNullOrEmpty(spawnpoint.Value) ? levelName.Value : levelName.Value + "@" + spawnpoint.Value);
                }
                else
                {
                    var levelManager = GameObject.FindObjectOfType <LevelManager>();
                    if (levelManager != null && !resetDialogueDatabase)
                    {
                        levelManager.LoadLevel(level);
                    }
                    else
                    {
                        PersistentDataManager.LevelWillBeUnloaded();
                        if (resetDialogueDatabase)
                        {
                            DatabaseResetOptions databaseResetOption = resetToInitialDatabase ? DatabaseResetOptions.RevertToDefault : DatabaseResetOptions.KeepAllLoaded;
                            DialogueManager.ResetDatabase(databaseResetOption);
                        }
                        else
                        {
                            if (resetToInitialDatabase)
                            {
                                LogWarning("Reset To Initial Database is ticked, but it has no effect because Reset Dialogue Database is unticked.");
                            }
                            PersistentDataManager.Record();
                        }
                        if (async)
                        {
                            if (additive)
                            {
                                asyncOperation = SceneManager.LoadSceneAsync(level, LoadSceneMode.Additive);
                            }
                            else
                            {
                                asyncOperation = SceneManager.LoadSceneAsync(level);
                            }
                            return; // Don't finish yet.
                        }
                        else
                        {
                            if (additive)
                            {
                                SceneManager.LoadScene(level, LoadSceneMode.Additive);
                            }
                            else
                            {
                                SceneManager.LoadScene(level);
                            }
                        }
                    }
                }
            }
            DoneLoadingLevel();
        }