Пример #1
0
 protected override void OnUpdate()
 {
     XLua.LuaFunction lua_fn = m_lua.Global.Get <XLua.LuaFunction>("on_native_drive_update");
     if (null != lua_fn)
     {
         lua_fn.Call();
     }
 }
Пример #2
0
 //public void initNode(object parent, MethodInfo method,unityAction3 act)
 //{
 //    this.parent = parent;
 //    this.method = method;
 //    this.action = act;
 //}
 public void Run(params object[] objs)
 {
     if (action != null)
     {
         action.Call(objs);
     }
     else
     {
         this.method.Invoke(this.parent, objs);
     }
 }
Пример #3
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();
            }
        }