Exemplo n.º 1
0
        private static byte[] CustomLoader(ref string filepath)
        {
            string scriptPath = string.Empty;

            filepath = filepath.Replace(".", "/");

            if (!GameUtility.Assets.runtimeMode)
            {
                scriptPath = Utility.Path.Combine(GameConst.LUA_SCRIPTS_PATH, filepath) + ".lua";;

                return(Utility.Files.ReadAllBytes(scriptPath));
            }

            scriptPath = GameUtility.Assets.GetAssetPath(AssetBundles.Lua, filepath) + GameConst.LUA_EXTENSION;
            var request = AssetsManger.LoadAsset(scriptPath, typeof(TextAsset));

            if (!string.IsNullOrEmpty(request.error))
            {
                Log.Error(request.error);
                return(null);
            }
            request.Release();
            var text = (request.asset as TextAsset).text;

            return(System.Text.Encoding.UTF8.GetBytes(text));
        }
Exemplo n.º 2
0
        public void Init(string path)
        {
            TextAsset request = (TextAsset)AssetsManger.LoadAsset(path, typeof(TextAsset)).asset;

            string[] words = request.text.Split(new string[1] {
                "\r\n"
            }, StringSplitOptions.None);
            for (int i = 0; i < words.Length; ++i)
            {
                string singleWord = words[i];
                if (singleWord.Length > 0)
                {
                    Dictionary <string, Node> next   = null;
                    Dictionary <string, Node> nowDic = dic;
                    if (!nowDic.ContainsKey(singleWord[0].ToString()))
                    {
                        Node rootNode = new Node();
                        rootNode.depth = 1;
                        nowDic.Add(singleWord[0].ToString(), rootNode);
                        next = rootNode.next;
                    }
                    else
                    {
                        next = nowDic[singleWord[0].ToString()].next;
                    }

                    Node nextNode = null;
                    for (int j = 1; j < singleWord.Length; ++j)
                    {
                        if (next == null)
                        {
                            next           = new Dictionary <string, Node>();
                            nextNode       = new Node();
                            nextNode.depth = j + 1;
                            next.Add(singleWord[j].ToString(), nextNode);
                            nowDic[singleWord[j - 1].ToString()].next = next;
                        }
                        else
                        {
                            if (!next.ContainsKey(singleWord[j].ToString()))
                            {
                                nextNode       = new Node();
                                nextNode.depth = j + 1;
                                next.Add(singleWord[j].ToString(), nextNode);
                            }
                            else
                            {
                                nextNode = next[singleWord[j].ToString()];
                            }
                        }
                        nowDic = next;
                        next   = nextNode.next;
                    }
                }
            }
            //PrintNode("", dic);
        }