Exemplo n.º 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);
        }
    }
Exemplo n.º 2
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 = 0;
            //int nbuy_ios = 0;
            int ndiamond = 0;
            nbuy_android = tbl.Get <int>("buy_android");
            //nbuy_ios = tbl.Get<int>("buy_ios");
            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;
        }

        System.Collections.Generic.Dictionary <string, string> data = new System.Collections.Generic.Dictionary <string, string>();
        data["dataType"]     = "6";
        data["roleID"]       = PlayerData.Instance.RoleID.ToString();
        data["roleName"]     = PlayerData.Instance.Name;
        data["roleLevel"]    = PlayerData.Instance.BaseAttr.Level.ToString();
        data["zoneId"]       = Account.Instance.ServerId.ToString();
        data["zoneName"]     = Account.Instance.ServerName;
        data["itemName"]     = itemName;
        data["count"]        = "1";
        data["amount"]       = amount.ToString();
        data["itemId"]       = configID.ToString();
        data["callBackInfo"] = PlayerData.Instance.RoleID.ToString() + ";" + configID.ToString() + ";" + "0";

        this.SetExtData(data);
    }
Exemplo n.º 3
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)
        {
            print(string.Format("key = {0}, value = {1}", key, table.Get <string>(key)));
            tempdict.Add(key, table.Get <string>(key));
        }
        return(MiniJSON.Json.Serialize(tempdict));
    }
Exemplo n.º 4
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);
    }
Exemplo n.º 5
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]);
    }
Exemplo n.º 6
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));
        }
    }
Exemplo n.º 7
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, "客户端向游戏服发起生成订单请求-完成");
        //这里向游戏服发起充值
    }
Exemplo n.º 8
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));
     }
 }
Exemplo n.º 9
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);
            }
        }
    }
Exemplo n.º 10
0
    public void Init()
    {
        print("===============" + gameObject);

        print(table);
        table.Set("gameObject", gameObject);
        _Awake = table.Get <LuaObjectAction>("Awake");
        _Start = table.Get <LuaObjectAction>("Start");

        _Update = table.Get <LuaObjectAction>("Update");
        if (_Awake != null)
        {
            if (args != null)
            {
                _Awake(table, args);
            }
            else
            {
                _Awake(table);
            }
            //this.gameObject.AddComponent("Lua")
        }
    }
Exemplo n.º 11
0
        static object[] CallLuaTargetMethod(LuaTable tbl, string methodName, params object[] args)
        {
            LuaTypes type  = LuaTypes.LUA_TNIL;
            object   value = null;

            tbl.Get <string, object>(methodName, out value, out type);
            LuaFunction func = value as LuaFunction;

            if (type != LuaTypes.LUA_TFUNCTION || func == null)
            {
                return(null);
            }

            return(func.Call(args));
        }
    //----------------------------------------------------------------------------
    // PlayState.Playingに変更されたときに呼び出される
    public override void OnBehaviourPlay(
        UnityEngine.Playables.Playable playable,
        UnityEngine.Playables.FrameData info
        )
    {
        if (textAsset != null)
        {
            scriptEnv = LuaEngine.LuaEnv.NewTable();
            // スクリプトごとに別々の環境を設定すると、スクリプト間でのグローバル変数と関数の競合をある程度防ぐことができます。
            XLua.LuaTable meta = LuaEngine.LuaEnv.NewTable();
            meta.Set("__index", LuaEngine.LuaEnv.Global);
            scriptEnv.SetMetaTable(meta);
            meta.Dispose();

            scriptEnv.Set("self", owner);
            LuaEngine.LuaEnv.DoString(textAsset.text, textAsset.GetHashCode().ToString(), scriptEnv);

            Action luaAwake = scriptEnv.Get <Action>("awake");
            scriptEnv.Get("update", out luaUpdate);
            scriptEnv.Get("ondestroy", out luaOnDestroy);

            luaAwake?.Invoke();
        }
    }
Exemplo n.º 13
0
        List <string> ParseLuaBehaviour_Begin(RealStatePtr L, string filename, ref int originTop, ref LuaTable argsTable)
        {
            originTop = LuaAPI.lua_gettop(L);
            List <string> keylist = null;

            try
            {
                byte[]   chunk = System.IO.File.ReadAllBytes(filename);
                object[] rets  = Utils.Lua.DoString(chunk, filename);

                if (rets.Length == 0)
                {
                    throw new Exception("lua file " + filename + " need return table type");
                }

                LuaTable table = rets[0] as LuaTable;

                if (table == null)
                {
                    throw new Exception("lua file " + filename + " convert to table type failed");
                }

                argsTable = table.Get <string, LuaTable>(LuaTarget.ArgsName);

                if (argsTable == null)
                {
                    throw new Exception("lua file " + filename + " field " + LuaTarget.ArgsName + " should be table type");
                }

                keylist = new List <string>();

                argsTable.ForEach <string, object>((key, value, valueType) =>
                {
                    if (valueType == LuaTypes.LUA_TTABLE || valueType == LuaTypes.LUA_TNUMBER || valueType == LuaTypes.LUA_TSTRING ||
                        valueType == LuaTypes.LUA_TBOOLEAN || valueType == LuaTypes.LUA_TUSERDATA || valueType == LuaTypes.LUA_TLIGHTUSERDATA)
                    {
                        keylist.Add(key);
                    }
                });
            }
            catch (Exception e)
            {
                LuaAPI.lua_settop(L, originTop);
                throw e;
            }

            return(keylist);
        }
Exemplo n.º 14
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);
         }
     }
 }
Exemplo n.º 15
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);
            }
        }
    }
Exemplo n.º 16
0
    public void GE_PLAYER_LV(GameEvent ge, EventParameter param)
    {
        int        oldLevel       = param.intParameter;
        int        level          = PlayerData.Instance.BaseAttr.Level;
        List <int> skillLockLevel = GetSkillLockLevel();
        int        skillIndex     = -1;

        for (int i = 0; i < skillLockLevel.Count; i++)
        {
            if (skillLockLevel[i] <= level && skillLockLevel[i] > oldLevel)
            {
                skillIndex = i;
                break;
            }
        }
        if (skillIndex == -1)
        {
            return;
        }

        CoreEntry.gEventMgr.TriggerEvent(GameEvent.GE_SHOW_BATTER, null);

        PanelBase panel = MainPanelMgr.Instance.ShowDialog("UISkillOpenTips");

        XLua.LuaTable tbl = panel.GetEnvTable();

        ShowInfo setFunc = null;

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

        if (null != setFunc)
        {
            setFunc(skillIndex);
        }
        Invoke("DelayReBindLock", delayTime);

        //Debug.LogError("skillIndex");
    }
Exemplo n.º 17
0
        List <DescriptorValue> ParseLuaTarget_GetValues(RealStatePtr L, LuaTable argsTable, List <string> keylist)
        {
            List <DescriptorValue> valuelist = new List <DescriptorValue>();

            foreach (var key in keylist)
            {
                Descriptor[] descriptors = null;
                object       value       = null;
                LuaTypes     valueType   = LuaTypes.LUA_TNIL;

                argsTable.Get <string, object>(key, out value, out valueType);
                DescriptorValue dv = new DescriptorValue();

                dv.v    = ParseLuaTarget_LuaValue(L, value, valueType, out descriptors);
                dv.desc = descriptors;

                valuelist.Add(dv);
            }

            return(valuelist);
        }
Exemplo n.º 18
0
        internal static int Print(RealStatePtr L)
        {
            try
            {
                int    n = LuaAPI.lua_gettop(L);
                string s = String.Empty;

                if (0 != LuaAPI.xlua_getglobal(L, "tostring"))
                {
                    return(LuaAPI.luaL_error(L, "can not get tostring in print:"));
                }

                for (int i = 1; i <= n; i++)
                {
                    LuaAPI.lua_pushvalue(L, -1);  /* function to be called */
                    LuaAPI.lua_pushvalue(L, i);   /* value to print */
                    if (0 != LuaAPI.lua_pcall(L, 1, 1, 0))
                    {
                        return(LuaAPI.lua_error(L));
                    }
                    s += LuaAPI.lua_tostring(L, -1);

                    if (i != n)
                    {
                        s += "\t";
                    }

                    LuaAPI.lua_pop(L, 1);  /* pop result */
                }
                //add by zhehua
                LuaTable debugTable = GameEntry.XLua.luaGlobal.Get <LuaTable>("debug");
                XLua.VoidReturnString tracebackFunc = debugTable.Get <XLua.VoidReturnString>("traceback");
                UnityEngine.Debug.Log(s + '\n' + tracebackFunc.Invoke());
                return(0);
            }
            catch (System.Exception e)
            {
                return(LuaAPI.luaL_error(L, "c# exception in print:" + e));
            }
        }
Exemplo n.º 19
0
 public object[] Call(string funcName, params object[] args)
 {
     XLua.LuaFunction f = mLuaModule.Get <string, XLua.LuaFunction>(funcName);
     if (f == null)
     {
         throw new XLua.LuaException("No lua function: " + funcName);
     }
     object[] allArgs;
     if (args == null)
     {
         allArgs = new object[1];
     }
     else
     {
         allArgs = new object[args.Length + 1];
         for (int i = 0; i < args.Length; i++)
         {
             allArgs[i + 1] = args[i];
         }
     }
     allArgs[0] = mLuaModule;
     return(f.Call(allArgs));
 }
Exemplo n.º 20
0
    public void CallBackPay(int configID)
    {
        Debug.Log("服务器订单回调::::" + configID);
        XLua.LuaTable G = LuaMgr.Instance.GetLuaEnv().Global;
        Dictionary <int, XLua.LuaTable> diamond = G.Get <Dictionary <int, XLua.LuaTable> >("t_diamondsqw");

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

        if (monthcard == null)
        {
            Debug.LogError("payerror: t_monthcard" + configID.ToString());
            return;
        }
        int    amount   = 1;
        string itemName = "错误";
        string itemDesc = "错误";

        XLua.LuaTable tbl       = null;
        string        iosshopid = "";

        if (diamond.TryGetValue(configID, out tbl))
        {
            int nbuy_android = 0;
            //int nbuy_ios = 0;
#pragma warning disable 0219
            int ndiamond = 0;
            //nbuy_ios = tbl.Get<int>("buy_ios");
            ndiamond = tbl.Get <int>("diamond");

#if UNITY_EDITOR
            nbuy_android = tbl.Get <int>("buy_android");
#elif UNITY_IOS
            nbuy_android = tbl.Get <int>("buy_ios");
#elif UNITY_ANDROID
            nbuy_android = tbl.Get <int>("buy_android");
#endif
            amount   = nbuy_android;
            itemName = tbl.Get <string>("commodity_name");//ndiamond.ToString() + uLocalization.Get("钻石");
            itemDesc = tbl.Get <string>("description");
        }
        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;
        }
        System.Collections.Generic.Dictionary <string, string> data = new System.Collections.Generic.Dictionary <string, string>();
        iosshopid = tbl.Get <string>("iosshopid");

        data["orderId"]     = sdkPayOrderId;                                    //订单号
        data["productId"]   = configID.ToString();                              //商品ID
        data["productDes"]  = itemDesc;                                         //商品描述
        data["productName"] = itemName;                                         //商品名字
        data["money"]       = (amount / 100).ToString();                        //商品金额
        data["count"]       = "1";                                              //商品数量
        data["coinType"]    = "人民币";                                            //币种
        int nServerId = Account.Instance.ServerId;
        data["serverId"]    = Account.Instance.ServerId.ToString();             //区服ID
        data["serverName"]  = Account.Instance.ServerName;                      //区服名称
        data["roleId"]      = PlayerData.Instance.RoleID.ToString();            //角色ID
        data["roleName"]    = PlayerData.Instance.Name;                         //角色名称
        data["roleLevel"]   = PlayerData.Instance.BaseAttr.Level.ToString();    //角色等级
        data["vipLevel"]    = PlayerData.Instance.BaseAttr.VIPLevel.ToString(); //vip等级
        data["roleBalance"] = PlayerData.Instance.BindGold.ToString();          //金币
        data["society"]     = PlayerData.Instance.GuildData.GuildName;          //公会
        if (data["society"] == "")
        {
            data["society"] = "无";
        }
        data["exchangeRate"]          = "";                         //兑换率
        data["extraInfo"]             = sdkPayExtension;            //额外信息
        data["serverTime"]            = sdkTime;                    //服務器時間
        data["sign"]                  = sdkSign;                    //加密碼
        data["flag"]                  = sdkFlag;                    //表示
        data["userId"]                = userID;                     //賬號ID
        data["accountId"]             = Account.Instance.AccountId; //賬號ID
        Account.Instance.isRecharging = true;

        //SQWSDK.Instance.pay(nType, sdkPayOrderId, sdkPayExtension, amount, data["productId"], itemName, itemDesc);
        Debug.Log("37玩 平台 充值接口:");
        SQWSDK.Instance.payJson(JsonMapper.ToJson(data));
    }
Exemplo n.º 21
0
        public void Encode(XLua.LuaTable luaTable, BinaryWriter stream)
        {
            var dictionary = luaTable.Cast <Dictionary <String, object> >();

            foreach (var v in _attrs)
            {
                try
                {
                    if (v.type.Equals(s_sString))
                    {
                        doSerialize(stream, (String)dictionary[v.name]);
                    }
                    else if (v.type.Equals(s_sInt32))
                    {
                        doSerialize(stream, Convert.ToInt32(dictionary[v.name]));
                    }
                    else if (v.type.Equals(s_sUint32))
                    {
                        doSerialize(stream, Convert.ToUInt32(dictionary[v.name]));
                    }
                    else if (v.type.Equals(s_sEnum))
                    {
                        doSerialize(stream, Convert.ToInt32(dictionary[v.name]));
                    }
                    else if (v.type.Equals(s_sUint8))
                    {
                        doSerialize(stream, Convert.ToByte(dictionary[v.name]));
                    }
                    else if (v.type.Equals(s_sUint16))
                    {
                        doSerialize(stream, Convert.ToUInt16(dictionary[v.name]));
                    }
                    else if (v.type.Equals(s_sUint64))
                    {
                        doSerialize(stream, Convert.ToUInt64(dictionary[v.name]));
                    }
                    else if (v.type.Equals(s_sInt8))
                    {
                        doSerialize(stream, Convert.ToSByte(dictionary[v.name]));
                    }
                    else if (v.type.Equals(s_sInt16))
                    {
                        doSerialize(stream, Convert.ToInt16(dictionary[v.name]));
                    }
                    else if (v.type.Equals(s_sInt64))
                    {
                        doSerialize(stream, Convert.ToInt64(dictionary[v.name]));
                    }
                    else if (v.type.Equals(s_sDouble))
                    {
                        doSerialize(stream, Convert.ToDouble(dictionary[v.name]));
                    }
                    else if (v.type.Equals(s_sFloat))
                    {
                        doSerialize(stream, Convert.ToSingle(dictionary[v.name]));
                    }
                    else if (v.type.Equals(s_sBool))
                    {
                        doSerialize(stream, Convert.ToBoolean(dictionary[v.name]));
                    }
                    else
                    {
                        XLua.LuaTable table = (XLua.LuaTable)dictionary[v.name];
                        table.Get <String, MessageLua>(s_sSelf).Encode(table, stream);
                    }
                }
                catch (Exception e)
                {
                    UnityEngine.Debug.LogException(e);
                }
            }
        }
Exemplo n.º 22
0
    public void CallBackPay(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 = "错误";
        string itemDesc = "错误";

        XLua.LuaTable tbl = null;
        if (diamond.TryGetValue(configID, out tbl))
        {
            int nbuy_android = 0;
            //int nbuy_ios = 0;
#pragma warning disable 0219
            int ndiamond = 0;
            //nbuy_ios = tbl.Get<int>("buy_ios");
            ndiamond = tbl.Get <int>("diamond");

#if UNITY_EDITOR
            nbuy_android = tbl.Get <int>("buy_android");
#elif UNITY_IOS
            nbuy_android = tbl.Get <int>("buy_ios");
#elif UNITY_ANDROID
            nbuy_android = tbl.Get <int>("buy_android");
#endif
            amount   = nbuy_android;
            itemName = tbl.Get <string>("commodity_name");//ndiamond.ToString() + uLocalization.Get("钻石");
            itemDesc = tbl.Get <string>("description");
        }
        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;
        }

        data["dataType"]        = "6";
        data["roleID"]          = PlayerData.Instance.RoleID.ToString();
        data["roleName"]        = PlayerData.Instance.Name;
        data["roleLevel"]       = PlayerData.Instance.BaseAttr.Level.ToString();
        data["zoneId"]          = Account.Instance.ZoneID.ToString();
        data["zoneName"]        = Account.Instance.ServerName;
        data["itemName"]        = itemName;
        data["itemDesc"]        = itemDesc;
        data["count"]           = "1";
        data["amount"]          = amount.ToString();
        data["itemId"]          = configID.ToString();
        data["strPayOrder"]     = sdkPayOrderId;
        data["strPayExtension"] = sdkPayExtension;
        data["callBackInfo"]    = PlayerData.Instance.RoleID.ToString() + ";" + configID.ToString() + ";" + "0";

        Account.Instance.isRecharging = true;

#if UNITY_EDITOR
#elif UNITY_IOS
        //ios平台 走这里
        XYSDK.Instance.pay(0, data["strPayOrder"], data["strPayExtension"], amount, data["itemId"], data["itemName"], data["itemName"]);
#elif UNITY_ANDROID
        this.SetExtData(data);
#endif
        int       versionCode = CommonTools.GetVersionCode();
        ArrayList list        = new ArrayList(needAdaptsJRTT);
        if (list.Contains(versionCode))
        {
            //用作今日头条信息
            payToutiaoInfo._type     = itemName;
            payToutiaoInfo._name     = itemName;
            payToutiaoInfo._id       = configID.ToString();
            payToutiaoInfo._num      = 1;
            payToutiaoInfo._channel  = "支付宝";
            payToutiaoInfo._currency = "人民币";
            payToutiaoInfo._success  = true;
            payToutiaoInfo._amount   = amount;

            Debug.Log("ToutiaoPurchase: " + amount + " : " + sdkPayOrderId + " : " + sdkPayExtension);
            XYSDK.Instance.ToutiaoPurchase();
            return;
        }



        Debug.Log("TrackingOrder: " + amount + " : " + sdkPayOrderId + " : " + sdkPayExtension);
        XYSDK.Instance.TrackingOrder(amount.ToString(), sdkPayOrderId, sdkPayExtension);
    }
Exemplo n.º 23
0
        public override void Deserialize(BinaryReader stream)
        {
            var messageLua = luaTable.Get <MessageLua>(s_sSelf);

            messageLua.Decode(luaTable, stream);
        }
Exemplo n.º 24
0
 public object this[string key]
 {
     get{ return(_G.Get <object>(key)); }
 }
Exemplo n.º 25
0
 protected void Awake()
 {
     LoadLua(true);
     runNow(table.Get <string, Action <LuaTable> >("AwakeCS"));
     StartCoroutine(runEndFrame(internalInit, null));
 }
Exemplo n.º 26
0
        void OnInspectorGUI_Playing()
        {
            var currTarget = target as LuaTarget;

            if (currTarget == null || !currTarget.Valid)
            {
                EditorGUILayout.HelpBox("lua not initialized", MessageType.Warning);
                return;
            }

            EditorGUI.BeginDisabledGroup(false);

            int originTop = LuaAPI.lua_gettop(Utils.LuaL);

            LuaAPI.lua_getref(Utils.LuaL, currTarget.LuaReference);
            object value = Utils.ObjTranslator.GetObject(Utils.LuaL, -1, typeof(object));

            ShowInternalItem_Playing(string.Empty, string.Empty, value);

            LuaAPI.lua_settop(Utils.LuaL, originTop);

            EditorGUI.EndDisabledGroup();

            originTop = LuaAPI.lua_gettop(Utils.LuaL);

            object   evtVal       = null;
            LuaTypes evtValueType = LuaTypes.LUA_TNIL;

            currTarget.Table.Get <string, object>(LuaTarget.NameEvents, out evtVal, out evtValueType);
            if (evtValueType == LuaTypes.LUA_TTABLE)
            {
                var events = new List <string>();
                EditorGUILayout.BeginVertical("Box");

                LuaTable evtTable = evtVal as LuaTable;

                evtTable.ForEach <string, object>((key, val, type) =>
                {
                    if (type != LuaTypes.LUA_TFUNCTION)
                    {
                        return;
                    }

                    events.Add(key);
                });

                if (content != null)
                {
                    var eventsFieldIndex = GetFieldSourceIndex(content, LuaTarget.ArgsName);
                    var orderMap         = (eventsFieldIndex.Key == -1 || eventsFieldIndex.Value == -1) ? null : GetOrderedKey(events, content.Substring(eventsFieldIndex.Key, eventsFieldIndex.Value - eventsFieldIndex.Key - 1));

                    events = events.OrderBy(key => { int index; orderMap.TryGetValue(key, out index); return(index); }).ToList();
                }

                int methodNum = 0;
                EditorGUILayout.BeginHorizontal();
                bool invoked = false;

                foreach (var key in events)
                {
                    if (GUILayout.Button(key) && !invoked)
                    {
                        invoked = true;
                        LuaFunction func = null;

                        evtTable.Get <string, LuaFunction>(key, out func);
                        if (func != null)
                        {
                            func.Call(evtTable, editorMethodArgument);
                        }
                    }

                    methodNum++;
                    if (methodNum % maxMethodButtonPerRow == 0)
                    {
                        methodNum = 0;
                        EditorGUILayout.EndHorizontal();
                        EditorGUILayout.BeginHorizontal();
                    }
                }

                if (methodNum % maxMethodButtonPerRow != 0)
                {
                    EditorGUILayout.LabelField(string.Empty);
                }

                EditorGUILayout.EndHorizontal();

                editorMethodArgument = EditorGUILayout.TextField("Method Argument", editorMethodArgument);
                EditorGUILayout.EndVertical();
            }

            LuaAPI.lua_settop(Utils.LuaL, originTop);

            if (GUILayout.Button("Reload"))
            {
                currTarget.Reload();
                content = null;
            }
        }