Exemplo n.º 1
0
        public static void OnCreateServerSkillTime()
        {
            //遍历文件夹

            string path            = AssetBundleUtility.PackagePathToAssetsPath("Lua");
            string AssetbundleName = AssetBundleUtility.AssetBundlePathToAssetBundleName(path);

            XLua.LuaEnv luaEnv = new XLua.LuaEnv();
            luaEnv.AddLoader(CustomLoader);
            luaEnv.AddBuildin("pb", XLua.LuaDLL.Lua.LoadPb);
            luaEnv.AddBuildin("cjson", XLua.LuaDLL.Lua.LoadRapidJson);
            string cmd = string.Format("require('{0}/Editor/AssetBundle/SkillTimeline')", Application.dataPath);

            luaEnv.DoString(cmd);
            XLua.LuaFunction func = luaEnv.Global.Get <XLua.LuaFunction>("ParseSkillTime");
            object[]         obj  = func.Call();
            if (obj != null && obj.Length > 0)
            {
                string serverPath = string.Format("{0}/{1}.txt", Application.dataPath.Substring(0, Application.dataPath.Length - 7), "normal_timeline");
                if (File.Exists(serverPath))
                {
                    File.Delete(serverPath);
                }

                FileStream   fs = new FileStream(serverPath, FileMode.Create);
                StreamWriter sw = new StreamWriter(fs);
                sw.Write("id" + "\t" + "roleId" + "\t" + "key" + "\t" + "time");
                sw.WriteLine();
                sw.Write("int" + "\t" + "int" + "\t" + "string" + "\t" + "float");
                sw.WriteLine();

                XLua.LuaTable tempTable = obj[0] as XLua.LuaTable;
                int           index     = 1;
                tempTable.ForEach <int, XLua.LuaTable>(delegate(int a, XLua.LuaTable luaTable) {
                    sw.Write(index + "\t" + luaTable.Get <int>("roldId") + "\t" + luaTable.Get <string>("key")
                             + "\t" + luaTable.Get <float>("time"));
                    sw.WriteLine();
                    index++;
                });

                sw.Close();
                fs.Close();
            }

            func = luaEnv.Global.Get <XLua.LuaFunction>("ParseCSkillTime");
            obj  = func.Call();
            if (obj != null && obj.Length > 0)
            {
                string serverPath = string.Format("{0}/{1}.txt", Application.dataPath.Substring(0, Application.dataPath.Length - 7), "cc_timeline");
                if (File.Exists(serverPath))
                {
                    File.Delete(serverPath);
                }

                FileStream   fs = new FileStream(serverPath, FileMode.Create);
                StreamWriter sw = new StreamWriter(fs);
                sw.Write("id" + "\t" + "key" + "\t" + "time");
                sw.WriteLine();
                sw.Write("int" + "\t" + "string" + "\t" + "float");
                sw.WriteLine();

                XLua.LuaTable tempTable = obj[0] as XLua.LuaTable;
                int           index     = 1;
                tempTable.ForEach <int, XLua.LuaTable>(delegate(int a, XLua.LuaTable luaTable) {
                    sw.Write(index + "\t" + luaTable.Get <string>("key")
                             + "\t" + luaTable.Get <float>("time"));
                    sw.WriteLine();
                    index++;
                });

                sw.Close();
                fs.Close();
            }
        }
Exemplo n.º 2
0
 public AssetsPathMapping()
 {
     AssetName       = AssetBundleUtility.PackagePathToAssetsPath(AssetBundleConfig.AssetsPathMapFileName);
     AssetbundleName = AssetBundleUtility.AssetBundlePathToAssetBundleName(AssetName);
 }