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
 /// <summary>
 /// Sets a player field in the Actor table.
 /// </summary>
 /// <param name="fieldName">Field name.</param>
 /// <param name="value">Value.</param>
 public void SetPlayerField(string fieldName, object value)
 {
     if (debug)
     {
         Debug.Log(string.Format("SetPlayerField({0}, {1}", fieldName, value));
     }
     DialogueLua.SetActorField(LuaPlayerIndex, fieldName, value);
 }
        public override void SaveItems(object serializedData, Action <bool> callback)
        {
            Assert.IsNotNull(callback, "Callback has to be set ( null given )");
            Assert.IsTrue(serializedData is string, "Serialized data is not string, json collection serializer can only use a JSON string.");

            DialogueLua.SetActorField(actorName, "InventoryPro_" + fieldName, (string)serializedData);
            callback(true);
        }
Exemplo n.º 4
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.º 5
0
        public void OnRecordPersistentData()
        {
            if (!enabled || m_factionMember == null)
            {
                return;
            }
            var data = m_factionMember.SerializeToString();

            DialogueLua.SetActorField(m_actorName, FactionMemberFieldName, data);
        }
        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.º 7
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();
        }