예제 #1
0
    IEnumerator SendPost(string url, XLua.LuaTable table, System.Action <string> callback)
    {
        WWWForm form = new WWWForm();
        var     keys = table.GetKeys <string>();

        foreach (string key in keys)
        {
            print(string.Format("key = {0}, value = {1}", key, table.Get <string>(key)));
            form.AddField(key, table.Get <string>(key));
        }
        WWW getData = new WWW(url, form);

        yield return(getData);

        print("getData.error = " + getData.error);
        print("getData.text = " + getData.text);
        if (getData.text != null)
        {
            callback(getData.text);
        }
        else
        {
            callback(getData.error);
        }
    }
예제 #2
0
    /// <summary>
    /// 209 设置移动路线
    /// lua移动指令
    /// 移动对象
    /// 是否等待结束
    /// </summary>
    /// <returns></returns>
    public bool command_moveByRoute()
    {
        XLua.LuaTable scriptEnv = LuaManager.getInterpreterEnvTable(this);

        Debug.Log("route:");
        Debug.Log(this.currentParam[0]);

        object[] result = LuaManager.LuaEnv.DoString(this.currentParam[0], string.Format("command_move_by_route_{0}", this.eventId), scriptEnv);

        // 移动对象
        GameCharacterBase character = this.getCharacter(int.Parse(this.currentParam[1]));

        // 是否等待移动结束
        if (bool.Parse(this.currentParam[2]))
        {
            this.movingCharacter = character;
        }

        // 处理移动指令
        List <MoveRoute> list = new List <MoveRoute>();

        for (int i = 0; i < ((XLua.LuaTable)result[0]).Length; i += 1)
        {
            MoveRoute route = ((XLua.LuaTable)result[0]).Get <int, MoveRoute>(i + 1);
            route.args.Add(this.currentParam[1]);               // 操作的事件id
            route.args.Add(this.eventId.ToString());            // 当前解释器所属事件id
            list.Add(route);
            Debug.Log(route);
        }

        character.setMoveRoute(list);

        return(true);
    }
예제 #3
0
    public static SystemData systemData; // 系统设定
    public static void loadAllData()
    {
        XLua.LuaTable env = LuaManager.getSimpleEnvTable();

        // 物品数据
        dataItems = new List <Item>();
        object[] results = LuaManager.LuaEnv.DoString("return require \"data/items\"", string.Format("load_data_{0}", "item"), env);
        if (results != null && results.Length > 0)
        {
            XLua.LuaTable resultTable = ((XLua.LuaTable)results[0]);
            for (int i = 0; i < resultTable.Length; i += 1)
            {
                dataItems.Add(resultTable.Get <int, Item>(i + 1));                      // 从1开始
            }
        }
        // 系统设定
        systemData = new SystemData();
        results    = LuaManager.LuaEnv.DoString("return require \"data/system\"", string.Format("load_data_{0}", "system"), env);
        if (results != null && results.Length > 0)
        {
            systemData = (SystemData)results[0];
        }
        // TODO 测试
        Debug.Log(string.Format("load item finish, len {0}", dataItems.Count));
        foreach (Item item in dataItems)
        {
            Debug.Log(string.Format("load item {0}", item.name));
        }
    }
예제 #4
0
 public MoveRoute(Cmd code, XLua.LuaTable argsTable)
 {
     this.code = code;
     this.args = new List <string>();
     for (int i = 0; i < argsTable.Length; i += 1)
     {
         this.args.Add(argsTable.Get <int, string>(i + 1));
     }
 }
예제 #5
0
    public static XLua.LuaTable getSimpleEnvTable()
    {
        XLua.LuaTable scriptEnv = LuaManager.LuaEnv.NewTable();
        // 为每个脚本设置一个独立的环境,可一定程度上防止脚本间全局变量、函数冲突
        XLua.LuaTable meta = LuaManager.LuaEnv.NewTable();
        meta.Set("__index", LuaManager.LuaEnv.Global);
        scriptEnv.SetMetaTable(meta);
        meta.Dispose();

        return(scriptEnv);
    }
        static int _m_BinarySearch(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                System.Collections.Generic.List <XLua.LuaTable> gen_to_be_invoked = (System.Collections.Generic.List <XLua.LuaTable>)translator.FastGetCSObj(L, 1);


                int gen_param_count = LuaAPI.lua_gettop(L);

                if (gen_param_count == 2 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TTABLE))
                {
                    XLua.LuaTable _item = (XLua.LuaTable)translator.GetObject(L, 2, typeof(XLua.LuaTable));

                    int gen_ret = gen_to_be_invoked.BinarySearch(_item);
                    LuaAPI.xlua_pushinteger(L, gen_ret);



                    return(1);
                }
                if (gen_param_count == 3 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TTABLE) && translator.Assignable <System.Collections.Generic.IComparer <XLua.LuaTable> >(L, 3))
                {
                    XLua.LuaTable _item = (XLua.LuaTable)translator.GetObject(L, 2, typeof(XLua.LuaTable));
                    System.Collections.Generic.IComparer <XLua.LuaTable> _comparer = (System.Collections.Generic.IComparer <XLua.LuaTable>)translator.GetObject(L, 3, typeof(System.Collections.Generic.IComparer <XLua.LuaTable>));

                    int gen_ret = gen_to_be_invoked.BinarySearch(_item, _comparer);
                    LuaAPI.xlua_pushinteger(L, gen_ret);



                    return(1);
                }
                if (gen_param_count == 5 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3) && (LuaAPI.lua_isnil(L, 4) || LuaAPI.lua_type(L, 4) == LuaTypes.LUA_TTABLE) && translator.Assignable <System.Collections.Generic.IComparer <XLua.LuaTable> >(L, 5))
                {
                    int           _index = LuaAPI.xlua_tointeger(L, 2);
                    int           _count = LuaAPI.xlua_tointeger(L, 3);
                    XLua.LuaTable _item  = (XLua.LuaTable)translator.GetObject(L, 4, typeof(XLua.LuaTable));
                    System.Collections.Generic.IComparer <XLua.LuaTable> _comparer = (System.Collections.Generic.IComparer <XLua.LuaTable>)translator.GetObject(L, 5, typeof(System.Collections.Generic.IComparer <XLua.LuaTable>));

                    int gen_ret = gen_to_be_invoked.BinarySearch(_index, _count, _item, _comparer);
                    LuaAPI.xlua_pushinteger(L, gen_ret);



                    return(1);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }

            return(LuaAPI.luaL_error(L, "invalid arguments to System.Collections.Generic.List<XLua.LuaTable>.BinarySearch!"));
        }
    //----------------------------------------------------------------------------
    // PlayState.Pausedに変更されたときに呼び出される
    public override void OnBehaviourPause(
        UnityEngine.Playables.Playable playable,
        UnityEngine.Playables.FrameData info
        )
    {
        luaOnDestroy?.Invoke();
        luaOnDestroy = null;

        scriptEnv?.Dispose();
        scriptEnv = null;
        luaUpdate = null;
    }
예제 #8
0
        static int _g_get_Length(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                XLua.LuaTable gen_to_be_invoked = (XLua.LuaTable)translator.FastGetCSObj(L, 1);
                LuaAPI.xlua_pushinteger(L, gen_to_be_invoked.Length);
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
            return(1);
        }
예제 #9
0
    public string MakeJson(XLua.LuaTable table)
    {
        var keys = table.GetKeys <string>();
        Dictionary <string, string> tempdict = new Dictionary <string, string>();

        foreach (string key in keys)
        {
            //Debug.LogFormat("key = {0}, value = {1}", key, table.Get<string>(key));
            tempdict.Add(key, table.Get <string>(key));
        }
        return(MiniJSON.Json.Serialize(tempdict));
    }
예제 #10
0
        static int _m_LoadString(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                XLua.LuaEnv gen_to_be_invoked = (XLua.LuaEnv)translator.FastGetCSObj(L, 1);


                int gen_param_count = LuaAPI.lua_gettop(L);

                if (gen_param_count == 4 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && (LuaAPI.lua_isnil(L, 3) || LuaAPI.lua_type(L, 3) == LuaTypes.LUA_TSTRING) && (LuaAPI.lua_isnil(L, 4) || LuaAPI.lua_type(L, 4) == LuaTypes.LUA_TTABLE))
                {
                    string        _chunk     = LuaAPI.lua_tostring(L, 2);
                    string        _chunkName = LuaAPI.lua_tostring(L, 3);
                    XLua.LuaTable _env       = (XLua.LuaTable)translator.GetObject(L, 4, typeof(XLua.LuaTable));

                    XLua.LuaFunction gen_ret = gen_to_be_invoked.LoadString(_chunk, _chunkName, _env);
                    translator.Push(L, gen_ret);



                    return(1);
                }
                if (gen_param_count == 3 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && (LuaAPI.lua_isnil(L, 3) || LuaAPI.lua_type(L, 3) == LuaTypes.LUA_TSTRING))
                {
                    string _chunk     = LuaAPI.lua_tostring(L, 2);
                    string _chunkName = LuaAPI.lua_tostring(L, 3);

                    XLua.LuaFunction gen_ret = gen_to_be_invoked.LoadString(_chunk, _chunkName);
                    translator.Push(L, gen_ret);



                    return(1);
                }
                if (gen_param_count == 2 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING))
                {
                    string _chunk = LuaAPI.lua_tostring(L, 2);

                    XLua.LuaFunction gen_ret = gen_to_be_invoked.LoadString(_chunk);
                    translator.Push(L, gen_ret);



                    return(1);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }

            return(LuaAPI.luaL_error(L, "invalid arguments to XLua.LuaEnv.LoadString!"));
        }
예제 #11
0
    public void GetFunction <T>(string tablename, string name, ref T action)
    {
        if (luaEnv != null)
        {
            XLua.LuaTable table = null;

            luaEnv.Global.Get(tablename, out table);
            if (table != null)
            {
                table.Get(name, out action);
            }
        }
    }
예제 #12
0
        static int _m_DoString_xlua_st_(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);



                int gen_param_count = LuaAPI.lua_gettop(L);

                if (gen_param_count == 3 && (LuaAPI.lua_isnil(L, 1) || LuaAPI.lua_type(L, 1) == LuaTypes.LUA_TSTRING) && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && (LuaAPI.lua_isnil(L, 3) || LuaAPI.lua_type(L, 3) == LuaTypes.LUA_TTABLE))
                {
                    string        _chunk     = LuaAPI.lua_tostring(L, 1);
                    string        _chunkName = LuaAPI.lua_tostring(L, 2);
                    XLua.LuaTable _env       = (XLua.LuaTable)translator.GetObject(L, 3, typeof(XLua.LuaTable));

                    object[] gen_ret = LuaSystem.DoString(_chunk, _chunkName, _env);
                    translator.Push(L, gen_ret);



                    return(1);
                }
                if (gen_param_count == 2 && (LuaAPI.lua_isnil(L, 1) || LuaAPI.lua_type(L, 1) == LuaTypes.LUA_TSTRING) && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING))
                {
                    string _chunk     = LuaAPI.lua_tostring(L, 1);
                    string _chunkName = LuaAPI.lua_tostring(L, 2);

                    object[] gen_ret = LuaSystem.DoString(_chunk, _chunkName);
                    translator.Push(L, gen_ret);



                    return(1);
                }
                if (gen_param_count == 1 && (LuaAPI.lua_isnil(L, 1) || LuaAPI.lua_type(L, 1) == LuaTypes.LUA_TSTRING))
                {
                    string _chunk = LuaAPI.lua_tostring(L, 1);

                    object[] gen_ret = LuaSystem.DoString(_chunk);
                    translator.Push(L, gen_ret);



                    return(1);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }

            return(LuaAPI.luaL_error(L, "invalid arguments to LuaSystem.DoString!"));
        }
예제 #13
0
    /// <summary>
    /// 开放给Lua端调用的Post接口
    /// </summary>
    /// <param name="url">URL</param>
    /// <param name="values">值表</param>
    /// <param name="files">文件表,会以二进制的形式向服务端请求(通过WWWForm.AddBinaryData的形式)</param>
    /// <param name="cb">回调</param>
    public void POST(string url, XLua.LuaTable values, XLua.LuaTable files, POSTCB cb)
    {
        Dictionary <string, string> data = new Dictionary <string, string>();
        IDictionaryEnumerator       de   = null;

        if (values != null)
        {
            //de = values.GetEnumerator();
            //while (de.MoveNext())
            //{
            //    data.Add(de.Key as string, de.Value as string);
            //}
            foreach (string key in values.GetKeys <string>())
            {
                data.Add(key, values.Get <string>(key));
            }
        }

        Dictionary <string, KeyValuePair <string, byte[]> > stream = new Dictionary <string, KeyValuePair <string, byte[]> >();

        if (files != null)
        {
            //de = files.GetEnumerator();
            //while (de.MoveNext())
            //{
            //    string field = de.Key as string;
            //    string path = de.Value as string;
            //    if (string.IsNullOrEmpty(path) || !File.Exists(path))
            //    {
            //        GameDebug.LogWarning(string.Format("Unexpect path:{0}", path));
            //        continue;
            //    }
            //    byte[] bytes = File.ReadAllBytes(path);
            //    stream.Add(field, new KeyValuePair<string, byte[]>(Path.GetFileName(path), bytes));
            //}
            foreach (string field in files.GetKeys <string>())
            {
                string path = values.Get <string>(field);
                if (string.IsNullOrEmpty(path) || !File.Exists(path))
                {
                    GameDebug.LogWarning(string.Format("Unexpect path:{0}", path));
                    continue;
                }
                byte[] bytes = File.ReadAllBytes(path);
                stream.Add(field, new KeyValuePair <string, byte[]>(Path.GetFileName(path), bytes));
            }
        }

        POST(url, data, stream, cb, null);
    }
예제 #14
0
        static int _m_SafeDoString(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                LuaBehaviour gen_to_be_invoked = (LuaBehaviour)translator.FastGetCSObj(L, 1);


                int gen_param_count = LuaAPI.lua_gettop(L);

                if (gen_param_count == 4 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && (LuaAPI.lua_isnil(L, 3) || LuaAPI.lua_type(L, 3) == LuaTypes.LUA_TTABLE) && (LuaAPI.lua_isnil(L, 4) || LuaAPI.lua_type(L, 4) == LuaTypes.LUA_TSTRING))
                {
                    string        _scriptContent = LuaAPI.lua_tostring(L, 2);
                    XLua.LuaTable _env           = (XLua.LuaTable)translator.GetObject(L, 3, typeof(XLua.LuaTable));
                    string        _chunkName     = LuaAPI.lua_tostring(L, 4);

                    gen_to_be_invoked.SafeDoString(_scriptContent, _env, _chunkName);



                    return(0);
                }
                if (gen_param_count == 3 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && (LuaAPI.lua_isnil(L, 3) || LuaAPI.lua_type(L, 3) == LuaTypes.LUA_TTABLE))
                {
                    string        _scriptContent = LuaAPI.lua_tostring(L, 2);
                    XLua.LuaTable _env           = (XLua.LuaTable)translator.GetObject(L, 3, typeof(XLua.LuaTable));

                    gen_to_be_invoked.SafeDoString(_scriptContent, _env);



                    return(0);
                }
                if (gen_param_count == 2 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING))
                {
                    string _scriptContent = LuaAPI.lua_tostring(L, 2);

                    gen_to_be_invoked.SafeDoString(_scriptContent);



                    return(0);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }

            return(LuaAPI.luaL_error(L, "invalid arguments to LuaBehaviour.SafeDoString!"));
        }
        static int _m_Execute_xlua_st_(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);



                int gen_param_count = LuaAPI.lua_gettop(L);

                if (gen_param_count == 1 && LuaTypes.LUA_TLIGHTUSERDATA == LuaAPI.lua_type(L, 1))
                {
                    System.IntPtr _L = LuaAPI.lua_touserdata(L, 1);

                    int gen_ret = XLua.TemplateEngine.LuaTemplate.Execute(_L);
                    LuaAPI.xlua_pushinteger(L, gen_ret);



                    return(1);
                }
                if (gen_param_count == 1 && (LuaAPI.lua_isnil(L, 1) || LuaAPI.lua_type(L, 1) == LuaTypes.LUA_TFUNCTION))
                {
                    XLua.LuaFunction _compiledTemplate = (XLua.LuaFunction)translator.GetObject(L, 1, typeof(XLua.LuaFunction));

                    string gen_ret = XLua.TemplateEngine.LuaTemplate.Execute(_compiledTemplate);
                    LuaAPI.lua_pushstring(L, gen_ret);



                    return(1);
                }
                if (gen_param_count == 2 && (LuaAPI.lua_isnil(L, 1) || LuaAPI.lua_type(L, 1) == LuaTypes.LUA_TFUNCTION) && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TTABLE))
                {
                    XLua.LuaFunction _compiledTemplate = (XLua.LuaFunction)translator.GetObject(L, 1, typeof(XLua.LuaFunction));
                    XLua.LuaTable    _parameters       = (XLua.LuaTable)translator.GetObject(L, 2, typeof(XLua.LuaTable));

                    string gen_ret = XLua.TemplateEngine.LuaTemplate.Execute(_compiledTemplate, _parameters);
                    LuaAPI.lua_pushstring(L, gen_ret);



                    return(1);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }

            return(LuaAPI.luaL_error(L, "invalid arguments to XLua.TemplateEngine.LuaTemplate.Execute!"));
        }
예제 #16
0
    // Start is called before the first frame update
    private void Start()
    {
        env = new LuaEnv();
        env.DoString("require 'CallLua'");
        XLua.LuaTable gl = env.Global.Get <XLua.LuaTable>("gameUser");

        Debug.Log("luatable---" + gl.Get <string>("name"));

        //函数
        XLua.LuaFunction fun = gl.Get <XLua.LuaFunction>("Speak");
        fun.Call();
        XLua.LuaFunction fun1     = gl.Get <XLua.LuaFunction>("Caculation");
        object[]         objarray = fun1.Call(gl, 2, 3);
        Debug.Log("result--" + objarray[0]);
    }
예제 #17
0
    void onUploadReccordFileComplete(IGCloudVoice.GCloudVoiceCompleteCode code, string filepath, string fileid)
    {
        if (code == IGCloudVoice.GCloudVoiceCompleteCode.GV_ON_UPLOAD_RECORD_DONE)
        {
            Debug.Log("OnUploadReccordFileComplete succ, filepath:" + filepath + " fileid len=" + fileid.Length + " fileid:" + fileid + " fileid len=" + fileid.Length);

            XLua.LuaTable tab = AppMng.luaEnv.NewTable();
            tab.Set <string, string> ("fileid", fileid);
            EventTool.Run("niuniu", "playroom.sendchat", tab);
        }
        else
        {
            Debug.Log("OnUploadReccordFileComplete error");
        }
    }
예제 #18
0
    /// <summary>
    /// 111 条件分歧
    /// lua, lua条件判定
    /// </summary>
    /// <returns></returns>
    public bool command_condition()
    {
        string condition = this.currentParam[0];

        Debug.Log(condition);

        XLua.LuaTable scriptEnv = LuaManager.getInterpreterEnvTable(this);

        bool result = (bool)LuaManager.LuaEnv.DoString(condition, string.Format("event_condition_{0}", this.eventId), scriptEnv)[0];

        if (!result)
        {
            this.commandConditionSkip(); // 跳转到最近的end
        }
        return(true);
    }
예제 #19
0
 void OnDestroy()
 {
     if (mLuaOnDestroy != null)
     {
         mLuaOnDestroy(mLuaModule, mLuaObject);
     }
     if (mLuaObject != null)
     {
         mLuaObject.Dispose();
         mLuaObject = null;
     }
     mLuaModule    = null;
     mLuaUpdate    = null;
     mLuaOnDestroy = null;
     mLuaStart     = null;
 }
예제 #20
0
    public static void BindMetaTable(XLua.LuaEnv env, XLua.LuaTable table)
    {
        if (env == null)
        {
            return;
        }
        if (table == null)
        {
            return;
        }
        LuaTable t = env.NewTable();

        t.Set("__index", env.Global);
        table.SetMetaTable(t);
        t.Dispose();
    }
예제 #21
0
    /// <summary>
    ///  355 eval
    ///  lua脚本
    /// </summary>
    public bool command_evalScript()
    {
        string src = this.currentParam[0];

        Debug.Log(src);

        XLua.LuaTable scriptEnv = LuaManager.getInterpreterEnvTable(this);

        object[] results = LuaManager.LuaEnv.DoString(src, string.Format("event_eval_{0}", this.eventId), scriptEnv);

        if (results != null && results.Length > 0)
        {
            return((bool)results[0]);
        }

        return(true);
    }
예제 #22
0
    public void Pay(int configID)
    {
        XLua.LuaTable G = LuaMgr.Instance.GetLuaEnv().Global;
        Dictionary <int, XLua.LuaTable> diamond = G.Get <Dictionary <int, XLua.LuaTable> >("t_diamond");

        if (diamond == null)
        {
            Debug.LogError("payerror:" + configID.ToString());
            return;
        }
        Dictionary <int, XLua.LuaTable> monthcard = G.Get <Dictionary <int, XLua.LuaTable> >("t_monthcard");

        if (monthcard == null)
        {
            Debug.LogError("payerror:" + configID.ToString());
            return;
        }
        //int amount = 1;
        //string itemName = "错误";
        XLua.LuaTable tbl = null;
        if (diamond.TryGetValue(configID, out tbl))
        {
            //int nbuy_android = tbl.Get<int>("buy_android");
            //int nbuy_ios = tbl.Get<int>("buy_ios");
            //int ndiamond = tbl.Get<int>("diamond");
            //amount = nbuy_android;
            //itemName = ndiamond.ToString() + uLocalization.Get("钻石");
        }
        else if (monthcard.TryGetValue(configID, out tbl))
        {
            //int card_price = tbl.Get<int>("card_price");
            //int card_type = tbl.Get<int>("card_type");
            //amount = card_price;
            //itemName = uLocalization.Get("月卡") + card_type.ToString();
        }
        else
        {
            Debug.LogError("payerror:" + configID.ToString());
            return;
        }
        SDKMgr.Instance.TagAdd(542, "客户端向游戏服发起生成订单请求-开始");
        NetLogicGame.Instance.SendReqGetRechargeorder(configID, 1, Account.Instance.ServerId, XYSDK.Instance.GetCurrPID(), Account.Instance.ServerName);
        SDKMgr.Instance.TagAdd(574, "客户端向游戏服发起生成订单请求-完成");
        //这里向游戏服发起充值
    }
예제 #23
0
    public void SetLuaModule(LuaTable module, LuaTable data = null)
    {
        mLuaModule      = module;
        mLuaStart       = module.Get <string, MonoBehaviourEvent>("Start");
        mLuaUpdate      = module.Get <string, MonoBehaviourEvent>("Update");
        mLuaFixedUpdate = module.Get <string, MonoBehaviourEvent>("FixedUpdate");
        mLuaLateUpdate  = module.Get <string, MonoBehaviourEvent>("LateUpdate");
        mLuaOnDisable   = module.Get <string, MonoBehaviourEvent>("OnDisable");
        mLuaOnEnable    = module.Get <string, MonoBehaviourEvent>("OnEnable");
        mLuaOnDestroy   = module.Get <string, MonoBehaviourEvent>("OnDestroy");
        mLuaOnGUI       = module.Get <string, MonoBehaviourEvent>("OnGUI");

        mLuaObject = LuaMgr.Instance.Env.NewTable();
        mLuaObject.Set <string, GameObject>("gameObject", gameObject);
        mLuaObject.Set <string, Transform>("transform", transform);
        mLuaObject.Set <string, LuaTable>("data", data);
        mLuaObject.Set <string, LuaBehaviour>("view", this);
    }
예제 #24
0
 public void TrackRechargeSuccessEvent(int id)
 {
     if (bSDK && mSKDType == 1)
     {
         XLua.LuaTable G = LuaMgr.Instance.GetLuaEnv().Global;
         System.Collections.Generic.Dictionary <int, XLua.LuaTable> diamond = G.Get <System.Collections.Generic.Dictionary <int, XLua.LuaTable> >("t_diamond");
         if (diamond == null)
         {
             return;
         }
         XLua.LuaTable tbl = null;
         if (diamond.TryGetValue(id, out tbl))
         {
             int money = tbl.Get <int>("buy_ios");
             XYSDK.Instance.trackRechargeSuccess(money);
         }
     }
 }
예제 #25
0
    public static XLua.LuaTable getInterpreterEnvTable(GameInterpreter interpreter)
    {
        XLua.LuaTable scriptEnv = LuaManager.LuaEnv.NewTable();
        // 为每个脚本设置一个独立的环境,可一定程度上防止脚本间全局变量、函数冲突
        XLua.LuaTable meta = LuaManager.LuaEnv.NewTable();
        meta.Set("__index", LuaManager.LuaEnv.Global);
        scriptEnv.SetMetaTable(meta);
        meta.Dispose();

        scriptEnv.Set("self", interpreter);
        scriptEnv.Set("gameVariables", GameTemp.gameVariables);
        scriptEnv.Set("gameSwitches", GameTemp.gameSwitches);
        scriptEnv.Set("gameSelfSwitches", GameTemp.gameSelfSwitches);
        scriptEnv.Set("gamePlayer", GameTemp.gamePlayer);
        scriptEnv.Set("gameMap", GameTemp.gameMap);

        return(scriptEnv);
    }
예제 #26
0
    void OnRuleClick()
    {
        PanelBase panel = MainPanelMgr.Instance.ShowDialog("UIRule");

        if (null != panel)
        {
            XLua.LuaTable tbl     = panel.GetEnvTable();
            ShowInfo      setFunc = null;
            if (null != tbl)
            {
                tbl.Get("ShowInfo", out setFunc);
            }

            if (null != setFunc)
            {
                setFunc(m_RuleId);
            }
        }
    }
예제 #27
0
        static int _m_NewTable_xlua_st_(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);



                {
                    XLua.LuaTable gen_ret = LuaSystem.NewTable(  );
                    translator.Push(L, gen_ret);



                    return(1);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
        }
예제 #28
0
        int TSLuaFrameworkToolUIEvent_m_AddBaseEvent(RealStatePtr L, int gen_param_count)
        {
            ObjectTranslator translator = this;


            TSLuaFramework.Tool.UIEvent gen_to_be_invoked = (TSLuaFramework.Tool.UIEvent)translator.FastGetCSObj(L, 1);


            {
                UnityEngine.EventSystems.EventTriggerType _triggerType; translator.Get(L, 2, out _triggerType);
                XLua.LuaTable _value = (XLua.LuaTable)translator.GetObject(L, 3, typeof(XLua.LuaTable));

                gen_to_be_invoked.AddBaseEvent(_triggerType, _value);



                return(0);
            }
        }
예제 #29
0
        static int __CreateInstance(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
                if (LuaAPI.lua_gettop(L) == 2 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TTABLE))
                {
                    XLua.LuaTable _sp = (XLua.LuaTable)translator.GetObject(L, 2, typeof(XLua.LuaTable));

                    var gen_ret = new LuaWebSocket(_sp);
                    translator.Push(L, gen_ret);

                    return(1);
                }
            }
            catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
            return(LuaAPI.luaL_error(L, "invalid arguments to LuaWebSocket constructor!"));
        }
예제 #30
0
        static int _m_CallLuaFunction(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                LuaComponent gen_to_be_invoked = (LuaComponent)translator.FastGetCSObj(L, 1);


                int gen_param_count = LuaAPI.lua_gettop(L);

                if (gen_param_count >= 3 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TTABLE) && (LuaAPI.lua_isnil(L, 3) || LuaAPI.lua_type(L, 3) == LuaTypes.LUA_TSTRING) && (LuaTypes.LUA_TNONE == LuaAPI.lua_type(L, 4) || translator.Assignable <object>(L, 4)))
                {
                    XLua.LuaTable _luaTable = (XLua.LuaTable)translator.GetObject(L, 2, typeof(XLua.LuaTable));
                    string        _funcName = LuaAPI.lua_tostring(L, 3);
                    object[]      _param    = translator.GetParams <object>(L, 4);

                    gen_to_be_invoked.CallLuaFunction(_luaTable, _funcName, _param);



                    return(0);
                }
                if (gen_param_count >= 4 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && (LuaAPI.lua_isnil(L, 3) || LuaAPI.lua_type(L, 3) == LuaTypes.LUA_TSTRING) && (LuaAPI.lua_isnil(L, 4) || LuaAPI.lua_type(L, 4) == LuaTypes.LUA_TSTRING) && (LuaTypes.LUA_TNONE == LuaAPI.lua_type(L, 5) || translator.Assignable <object>(L, 5)))
                {
                    string   _luaName   = LuaAPI.lua_tostring(L, 2);
                    string   _className = LuaAPI.lua_tostring(L, 3);
                    string   _funcName  = LuaAPI.lua_tostring(L, 4);
                    object[] _parms     = translator.GetParams <object>(L, 5);

                    gen_to_be_invoked.CallLuaFunction(_luaName, _className, _funcName, _parms);



                    return(0);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }

            return(LuaAPI.luaL_error(L, "invalid arguments to LuaComponent.CallLuaFunction!"));
        }