示例#1
0
        public void Load()
        {
            if (_SaveData.Length > 0)
            {
                using (MemoryStream ms = new MemoryStream(_SaveData))
                {
                    using (BinaryReader r = new BinaryReader(ms))
                    {
                        float ver = r.ReadSingle();
                        if (ver != Story.SaveVersion)
                        {
                            Debug.LogError("Error:Archive data version not same! Curent: " + Story.SaveVersion + " Data: " + ver);
                        }

                        string storyData = r.ReadString();
                        _story = JsonUtility.FromJson <Story>(storyData);
                        _story.LoadOnlyThisNode(r);
                    }
                }
            }

            if (_story == null)
            {
                _story = new Story();
            }

            for (int i = 0; i < _missionSaveList.Count; i++)
            {
                MissionData data = _missionSaveList[i];
                if (!data.MissionObject)
                {
                    Debug.Log("Mission Not Found: " + data.Name);
                    continue;
                }

                data.MissionObject.Load();
                data.MissionObject._mission._name = data.Name;

                NodeModifier.SetContent(data.MissionObject._mission, _story);
            }

            //设置已连接的节点
            for (int i = 0; i < _missionSaveList.Count; i++)
            {
                MissionData data = _missionSaveList[i];
                if (!data.MissionObject)
                {
                    continue;
                }
                if (data.MissionObject._nextMissionNodeList.Count > 0)
                {
                    foreach (var item in data.MissionObject._nextMissionNodeList)
                    {
                        MissionData next = GetMissionSaveDataByName(item.Name);
                        if (next == null)
                        {
                            continue;
                        }
                        if (next.MissionObject == null)
                        {
                            continue;
                        }
                        if (item.IsSingleNode)
                        {
                            data.MissionObject._mission.AddNextNode(next.MissionObject._mission);
                        }
                        else
                        {
                            Mission.SetParent(next.MissionObject._mission, data.MissionObject._mission);
                        }
                    }
                }
            }
        }
示例#2
0
        public void Load()
        {
            if (_SaveData.Length > 0)
            {
                using (MemoryStream ms = new MemoryStream(_SaveData))
                {
                    using (BinaryReader r = new BinaryReader(ms))
                    {
                        float ver = r.ReadSingle();
                        if (ver != Story.SaveVersion)
                        {
                            Debug.LogError("Error:Archive data version not same! Curent: " + Story.SaveVersion + " Data: " + ver);
#if UNITY_EDITOR
                            if (!_queryloaded)
                            {
                                _queryloaded = true;
                                if (!UnityEditor.EditorUtility.DisplayDialog("Error!", "Error:Archive data version not the same! Curent Version: " + Story.SaveVersion + " Data Version:" + ver, "Force Load", "Cancel"))
                                {
                                    return;
                                }
                            }
#endif
                        }

                        _queryloaded = false;

                        string storyData = r.ReadString();
                        _story = JsonUtility.FromJson <Story>(storyData);
                        _story.LoadOnlyThisNode(r);
                    }
                }
            }

            if (_story == null)
            {
                _story = new Story();
            }

            _haveNullData = false;
            for (int i = 0; i < _missionSaveList.Count; i++)
            {
                MissionData data = _missionSaveList[i];
                if (!data.MissionObject)
                {
                    Debug.Log("Mission Not Found: " + data.Name);
                    _haveNullData = true;
                    continue;
                }

                data.MissionObject.Load();
                data.MissionObject._mission._name = data.Name;

                NodeModifier.SetContent(data.MissionObject._mission, _story);
            }

            //设置已连接的节点
            for (int i = 0; i < _missionSaveList.Count; i++)
            {
                MissionData data = _missionSaveList[i];
                if (!data.MissionObject)
                {
                    continue;
                }
                if (data.MissionObject._nextMissionNodeList.Count > 0)
                {
                    foreach (var item in data.MissionObject._nextMissionNodeList)
                    {
                        MissionData next = GetMissionSaveDataByName(item.Name);
                        if (next == null)
                        {
                            continue;
                        }
                        if (next.MissionObject == null)
                        {
                            continue;
                        }
                        if (item.IsSingleNode)
                        {
                            data.MissionObject._mission.AddNextNode(next.MissionObject._mission);
                        }
                        else
                        {
                            Mission.SetParent(next.MissionObject._mission, data.MissionObject._mission);
                        }
                    }
                }
            }

            if (_haveNullData)
            {
                UnityEditor.EditorUtility.DisplayDialog("Attention!", "You have some Mission File Lost! ", "OK");
            }
        }