Example #1
0
 public object DeserializeFrom(Type type, string str)
 {
     return(MongoHelper.FromJson(type, str));
 }
Example #2
0
        public async Task StartAsync()
        {
            using (UnityWebRequestAsync request = EntityFactory.Create <UnityWebRequestAsync>())
            {
                string versionUrl = GlobalConfigComponent.Instance.GlobalProto.GetUrl() + "StreamingAssets/" + "Version.txt";
                Log.Debug(versionUrl);
                await request.DownloadAsync(versionUrl);

                this.VersionConfig = MongoHelper.FromJson <VersionConfig>(request.Request.downloadHandler.text);
            }

            Log.Debug("WebVersion:\n" + MongoHelper.ToJson(this.VersionConfig));

            // 对比本地的Version.txt
            string versionPath = Path.Combine(PathHelper.AppHotfixResPath, "Version.txt");

            if (!File.Exists(versionPath))
            {
                foreach (FileVersionInfo versionInfo in this.VersionConfig.FileVersionInfos)
                {
                    if (versionInfo.File == "Version.txt")
                    {
                        continue;
                    }
                    this.bundles.Enqueue(versionInfo.File);
                    this.TotalSize += versionInfo.Size;
                }
            }
            else
            {
                VersionConfig localVersionConfig = MongoHelper.FromJson <VersionConfig>(File.ReadAllText(versionPath));
                Log.Debug("LocalVersion:\n" + MongoHelper.ToJson(localVersionConfig));
                // 先删除服务器端没有的ab
                foreach (FileVersionInfo fileVersionInfo in localVersionConfig.FileVersionInfos)
                {
                    if (this.VersionConfig.FileInfoDict.ContainsKey(fileVersionInfo.File))
                    {
                        continue;
                    }
                    string abPath = Path.Combine(PathHelper.AppHotfixResPath, fileVersionInfo.File);
                    File.Delete(abPath);
                }

                // 再下载
                foreach (FileVersionInfo fileVersionInfo in this.VersionConfig.FileVersionInfos)
                {
                    FileVersionInfo localVersionInfo;
                    if (localVersionConfig.FileInfoDict.TryGetValue(fileVersionInfo.File, out localVersionInfo))
                    {
                        if (fileVersionInfo.MD5 == localVersionInfo.MD5)
                        {
                            continue;
                        }
                    }

                    if (fileVersionInfo.File == "Version.txt")
                    {
                        continue;
                    }

                    this.bundles.Enqueue(fileVersionInfo.File);
                    this.TotalSize += fileVersionInfo.Size;
                }
            }

            if (this.bundles.Count == 0)
            {
                return;
            }

            Log.Debug($"need download bundles: {this.bundles.ToList().ListToString()}");
            await this.WaitAsync();
        }
Example #3
0
        private void Awake()
        {
            string s = File.ReadAllText("../Config/StartConfig/ClientConfig.txt");

            this.Config = MongoHelper.FromJson <StartConfig>(s);
        }
Example #4
0
 public T DeserializeFrom <T>(string str)
 {
     return(MongoHelper.FromJson <T>(str));
 }
        public void OnGUI()
        {
            _name = EditorDataFields.EditorDataField("名字", _name);

            using (new EditorHorizontalLayout())
            {
                if (GUILayout.Button("搜索客户端"))
                {
                    bool get = false;
                    _goes.Clear();
                    _files.Clear();
                    foreach (NodeParam param in _nodes)
                    {
                        if (param.NodeType.Name == _name)
                        {
                            get       = true;
                            _selected = param;
                            break;
                        }
                    }

                    if (get)
                    {
                        List <string> paths = EditorResHelper.GetAllPath("Assets", true);
                        foreach (string path in paths)
                        {
                            GameObject         go     = AssetDatabase.LoadAssetAtPath <GameObject>(path);
                            BehaviorTreeConfig config = go.GetComponent <BehaviorTreeConfig>();
                            if (!config)
                            {
                                continue;
                            }

                            NodeProto         p     = config.RootNodeProto;
                            Stack <NodeProto> stack = new Stack <NodeProto>();
                            stack.Push(p);

                            while (stack.Count > 0)
                            {
                                NodeProto node = stack.Pop();
                                if (node.Name == _name)
                                {
                                    _goes.Add(go);
                                    break;
                                }

                                foreach (NodeProto child in node.Children)
                                {
                                    stack.Push(child);
                                }
                            }
                        }
                    }
                    else
                    {
                        _selected = null;
                    }
                }
                if (GUILayout.Button("搜索服务器"))
                {
                    string path = EditorTreeConfigHelper.Instance.Config.ServersPath;
                    bool   get  = false;
                    _goes.Clear();
                    _files.Clear();
                    foreach (NodeParam param in _nodes)
                    {
                        if (param.NodeType.Name == _name)
                        {
                            get       = true;
                            _selected = param;
                            break;
                        }
                    }

                    if (get)
                    {
                        string[] files = Directory.GetFiles(path, "*.txt");
                        foreach (string file in files)
                        {
                            try
                            {
                                StreamReader      reader = new StreamReader(file);
                                string            data   = reader.ReadToEnd();
                                NodeProto         p      = MongoHelper.FromJson <NodeProto>(data);
                                Queue <NodeProto> queue  = new Queue <NodeProto>();
                                queue.Enqueue(p);
                                while (queue.Count > 0)
                                {
                                    NodeProto node = queue.Dequeue();
                                    if (node.Name == _name)
                                    {
                                        _files.Add(file);
                                        break;
                                    }

                                    foreach (NodeProto child in node.Children)
                                    {
                                        queue.Enqueue(child);
                                    }
                                }
                            }
                            catch (Exception err)
                            {
                                BehaviourTreeDebugPanel.Error($"文件({file})无法解析成行为树");
                                Log.Error(err);
                            }
                        }
                    }
                }
            }

            if (_selected == null)
            {
                EditorGUILayout.LabelField("请输入节点名称,不需要命名空间");
                return;
            }
            if (_goes.Count > 0)
            {
                EditorDataFields.EditorListDataField(_goes, 20);
            }
            else if (_files.Count > 0)
            {
                EditorDataFields.EditorListDataField(_files, 20);
            }
        }
 public T DeserializeFrom <T>(string str) where T : SerializerBinary
 {
     return(MongoHelper.FromJson <T>(str));
 }
Example #7
0
 public static T ToObject <T>(string str)
 {
     return(MongoHelper.FromJson <T>(str));
 }
Example #8
0
        public void Awake()
        {
            string s = File.ReadAllText("./StartConfig.txt");

            this.Config = MongoHelper.FromJson <StartConfig>(s);
        }
Example #9
0
 public object Clone()
 {
     return(MongoHelper.FromJson <StartConfig>(MongoHelper.ToJson(this)));
 }
Example #10
0
 public static object FromJson(Type type, string str)
 {
     return(MongoHelper.FromJson(type, str));
 }
Example #11
0
 public object Clone()
 {
     return(MongoHelper.FromJson(this.GetType(), this.ToString()));
 }