예제 #1
0
    // -------------------------------私有方法----------------------------------



    /// <summary>
    /// 初始化lua文件
    /// </summary>
    private void InitLua()
    {
        // 读Lua文件
        LuaState lua = new LuaState();

        lua.Start();
        var packPath = Application.dataPath + "\\Lua\\pk_tabs\\";

        lua.DoFile(Application.dataPath + "\\Lua\\framework\\classWC.lua");
        lua.DoFile(Application.dataPath + "\\Lua\\framework\\luacsv.lua");
        var kezhi = lua.DoFile(packPath + "kezhi_c.lua");

        SDataUtils.setData("kezhi_c", (LuaTable)((LuaTable)kezhi[0])["head"], (LuaTable)((LuaTable)kezhi[0])["body"]);
        var armyBaseData = lua.DoFile(packPath + "armybase_c.lua");

        SDataUtils.setData("armybase_c", (LuaTable)((LuaTable)armyBaseData[0])["head"], (LuaTable)((LuaTable)armyBaseData[0])["body"]);
        var constantData = lua.DoFile(packPath + "Constant.lua");

        SDataUtils.setData("constant", (LuaTable)((LuaTable)constantData[0])["head"], (LuaTable)((LuaTable)constantData[0])["body"]);
        var aimData = lua.DoFile(packPath + "armyaim_c.lua");

        SDataUtils.setData("armyaim_c", (LuaTable)((LuaTable)aimData[0])["head"], (LuaTable)((LuaTable)aimData[0])["body"]);
        var aoeData = lua.DoFile(packPath + "armyaoe_c.lua");

        SDataUtils.setData("armyaoe_c", (LuaTable)((LuaTable)aoeData[0])["head"], (LuaTable)((LuaTable)aoeData[0])["body"]);
    }
예제 #2
0
 static int setData(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         string   arg0 = ToLua.CheckString(L, 1);
         LuaTable arg1 = ToLua.CheckLuaTable(L, 2);
         LuaTable arg2 = ToLua.CheckLuaTable(L, 3);
         SDataUtils.setData(arg0, arg1, arg2);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }