Exemple #1
0
    private void Btn_Click(int index)
    {
        isEnter = true;
        Dictionary <string, object> data = new Dictionary <string, object> ();

        data ["type"] = index;
        NetHttp.inst.Send(NetBase.HTTP_SENDGUILDREDBAG, data, (VoHttp vo) =>
        {
            GRoot.inst.touchable = false;
            ViewManager.inst.ShowIcon(userModel.GetReward(vo.data), () =>
            {
                GRoot.inst.touchable = true;
                userModel.UpdateData(vo.data);
                this.DispatchGlobalEventWith(MainEvent.CHAT_SENDREDBAG);
            });
            ViewManager.inst.CloseView(this);
        });
    }
    private void List_Render(int index, GObject item)
    {
//		Debug.LogError("Render Index:" + item.parent.width);
        GComponent go = item.asCom;

        go.name = index + "";
        go.RemoveChildren();
//        go.x = GRoot.inst.width/9;
//		go.x = item.parent.width - go.width;
        Dictionary <string, object> data = (Dictionary <string, object>)ld [index];
        GComponent     it;
        GButton        head;
        GTextField     text;
        GButton        btn1;
        GButton        btn2;
        ComProgressBar bar;

        if (data ["ctype"].ToString() == "chat")
        {
            GImage bg;
            it = Tools.GetComponent(Config.ITEM_CHAT).asCom;
            Controller c1 = it.GetController("c1");
            if (data ["uid"].ToString() == userModel.uid)
            {
                c1.selectedIndex = 1;
                it = it.GetChild("n1").asCom;
            }
            else
            {
                c1.selectedIndex = 0;
                it = it.GetChild("n0").asCom;
            }
            head = it.GetChild("n0").asButton;
            text = it.GetChild("n2").asTextField;
            bg   = it.GetChild("n5").asImage;


            it.GetChild("n1").text = ModelUser.GetUname(data ["uid"], data ["uname"]);
            Dictionary <string, object> use = data ["head"] as Dictionary <string, object>;
            Tools.SetLoaderButtonUrl(head, ModelUser.GetHeadUrl(use ["use"].ToString()));
            text.text = data ["chat"].ToString();
            it.GetChild("n4").text = ((DateTime)data ["time"]).ToString("HH:mm:ss");
            if (text.textHeight > 29)
            {
                float c = text.textHeight - 29;
                bg.height           = bg.height + c;
                go.height           = (115 - 29) + text.textHeight;
                it.GetChild("n4").y = it.GetChild("n4").y + c;
            }
            else
            {
                go.height           = 115;
                it.GetChild("n4").y = 90;
            }
            head.onClick.Add(() =>
            {
                this.DispatchGlobalEvent(new MainEvent(MainEvent.SHOW_USER, new object[] {
                    null,
                    data ["uid"].ToString(),
                    roleModel.tab_CurSelect1,
                    roleModel.tab_CurSelect2,
                    roleModel.tab_CurSelect3
                }));
            });
            go.AddChild(it);
            chatModel.IsEffect(data, go);
        }
        else if (data ["ctype"].ToString() == "guild")
        {
            GTextField rank;
            it   = Tools.GetComponent(Config.ITEM_GUILD).asCom;
            head = it.GetChild("n3").asButton;
            rank = it.GetChild("n6").asTextField;
            btn1 = it.GetChild("n0").asButton;
            btn2 = it.GetChild("n7").asButton;

            it.GetChild("n4").text = ModelUser.GetUname(data ["uid"], data ["uname"]);
            it.GetChild("n2").text = Tools.GetMessageById("22014");
            Dictionary <string, object> use = data ["head"] as Dictionary <string, object>;
            head.GetChild("n2").text = data ["lv"].ToString();
            Tools.SetLoaderButtonUrl(head.GetChild("n0").asButton, ModelUser.GetHeadUrl(use ["use"].ToString()));
            it.GetChild("n9").text = ((DateTime)data ["time"]).ToString("HH:mm:ss");
            rank.text = Tools.GetMessageById("22002", new string[] { data ["rank_score"].ToString() });
            go.height = 280;
            go.AddChild(it);
            chatModel.IsEffect(data, go);
            btn1.onClick.Add(() =>
            {
                Dictionary <string, object> d1 = new Dictionary <string, object> ();
                d1 ["uid"]  = data ["uid"].ToString();
                d1 ["flag"] = 1;
                NetHttp.inst.Send(NetBase.HTTP_GUILD_JOIN, d1, (VoHttp vo) =>
                {
//					Log.debug (vo.data.ToString ());
                    if (!Convert.ToBoolean(vo.data))
                    {
                        chatModel.RemoveChat("guild", data ["uid"].ToString());
                        ViewManager.inst.ShowText(Tools.GetMessageById("22029"));
                        list.RemoveChildAt(index);
                    }
                });
            });
            btn2.onClick.Add(() =>
            {
                Dictionary <string, object> d1 = new Dictionary <string, object> ();
                d1 ["uid"]  = data ["uid"].ToString();
                d1 ["flag"] = 2;
                NetHttp.inst.Send(NetBase.HTTP_GUILD_JOIN, d1, null);
            });
        }
        else if (data ["ctype"].ToString() == "guild_join")
        {
            it   = Tools.GetComponent(Config.ITEM_TEXT).asCom;
            text = it.GetChild("n0").asTextField;
            Dictionary <string, object> user1 = (Dictionary <string, object>)data ["user1"];
            Dictionary <string, object> user2 = (Dictionary <string, object>)data ["user2"];
            string name2 = ModelUser.GetUname(user2 ["uid"], user2 ["uname"]);
            if (user1 == null)
            {
                text.text = Tools.GetMessageById("22028", new string[] { name2 });
            }
            else
            {
                string name1 = ModelUser.GetUname(user1 ["uid"], user1 ["uname"]);
                if (data ["flag"].ToString() == "1")
                {
                    text.text = Tools.GetMessageById("22004", new string[] { name1, name2 });
                }
                else
                {
                    text.text = Tools.GetMessageById("22005", new string[] { name1, name2 });
                }
            }
            go.height = 70f;
//			try{
            go.AddChild(it);
//			}catch(Exception ee){
//			}
            chatModel.IsEffect(data, go);
        }
        else if (data ["ctype"].ToString() == "guild_modify")
        {
            it   = Tools.GetComponent(Config.ITEM_TEXT).asCom;
            text = it.GetChild("n0").asTextField;
            if (data.ContainsKey("user"))
            {
                Dictionary <string, object> user = (Dictionary <string, object>)data ["user"];
                string name0 = ModelUser.GetUname(user ["uid"], user ["uname"]);
                text.text = Tools.GetMessageById("22030", new string[] { name0 });
            }
            else
            {
                Dictionary <string, object> user1 = (Dictionary <string, object>)data ["user1"];
                Dictionary <string, object> user2 = (Dictionary <string, object>)data ["user2"];
                string name1   = ModelUser.GetUname(user1 ["uid"], user1 ["uname"]);
                string name2   = ModelUser.GetUname(user2 ["uid"], user2 ["uname"]);
                int    num     = Convert.ToInt32(data ["num"]);
                int    old_num = Convert.ToInt32(data ["old_num"]);
                if (num == -1)
                {
                    text.text = Tools.GetMessageById("22008", new string[] { name1, name2 });
                }
                else if (num == 0)
                {
                    text.text = Tools.GetMessageById("22009", new string[] { name1, name2 });
                }
                else if (num < old_num)
                {
                    text.text = Tools.GetMessageById("22006", new string[] { name1, name2 });
                }
                else
                {
                    text.text = Tools.GetMessageById("22007", new string[] { name1, name2 });
                }
            }
            go.height = 70;
            go.AddChild(it);
            chatModel.IsEffect(data, go);
        }
        else if (data ["ctype"].ToString() == "send_guild_redbag")
        {
//			go.name = go.name+"_isRed";
            it = Tools.GetComponent(Config.ITEM_RED1).asCom;
            GLoader load = it.GetChild("n6").asLoader;
            load.url = data ["type"].ToString() == "0" ? Tools.GetResourceUrl("Image2:n_icon_bthb2") : Tools.GetResourceUrl("Image2:n_icon_bthb1");
//			it.GetChild ("n1").text = ModelUser.GetUname (data ["uid"], data ["uname"]);
            string ti = Tools.GetMessageById("22017", new string[] { ModelUser.GetUname(data ["uid"], data ["uname"]) });
            ti = Tools.GetMessageColor(ti, new string[] { "dc8100" });
            it.GetChild("n2").text     = ti;
            it.GetChild("n4").text     = ((DateTime)data ["time"]).ToString("HH:mm:ss");
            it.GetChild("n11").text    = Tools.GetMessageById("22011");
            it.GetChild("n12").visible = true;
            if (Convert.ToBoolean(data ["is_my_grab"]))
            {
                it.GetChild("n12").text = Tools.GetMessageById("22034");
            }
            else if (Convert.ToBoolean(data ["is_grab_all"]))
            {
                it.GetChild("n12").text = Tools.GetMessageById("22046");
            }
            else
            {
                it.GetChild("n12").visible = false;
            }
            load.onClick.Add(() =>
            {
                if (!chatModel.isSendRedBagOutTime(data))
                {
                    ViewManager.inst.ShowText(Tools.GetMessageById("22039"));
                    return;
                }
                Dictionary <string, object> d = new Dictionary <string, object> ();
                d ["redbag_id"] = data ["id"].ToString();
                NetHttp.inst.Send(NetBase.HTTP_GRABGUILDREDBAG, d, (VoHttp vo) =>
                {
                    Dictionary <string, object> da   = (Dictionary <string, object>)vo.data;
                    Dictionary <string, object> gift = (Dictionary <string, object>)da ["gift"];
                    chatModel.grab_List = (object[])da ["grab_list"];
                    chatModel.card_List = (object[])da ["card_list"];
                    chatModel.grab_Type = Convert.ToInt32(data ["type"]);
                    if (gift == null)
                    {
                        if (!Convert.ToBoolean(data ["is_my_grab"]))
                        {
                            data ["is_avable"]  = false;
                            data ["is_my_grab"] = true;
                            chatModel.UpdateRedBagData(data);
                            chatModel.Remove_RedCount();
                            this.List_Render(index, item);
                        }
                        ViewManager.inst.ShowView <MediatorRed2> ();
                    }
                    else
                    {
                        data ["is_avable"]  = false;
                        data ["is_my_grab"] = true;
                        chatModel.UpdateRedBagData(data);
                        chatModel.Remove_RedCount();
                        this.List_Render(index, item);
                        chatModel.isRedbagGift = true;
                        //ViewManager.inst.ShowIcon (gift, () =>
                        //{
                        int gold = userModel.gold;
                        userModel.UpdateData(vo.data);
                        int gold2 = gift.ContainsKey("gold") ? Convert.ToInt32(gift["gold"]) : 0;
                        if (gold + gold2 != userModel.gold)
                        {
                            ViewManager.inst.ShowText(Tools.GetMessageById("33212"));
                        }
                        userModel.records ["guild_redbag_log"] = da ["guild_redbag_log"];
                        ViewManager.inst.ShowView <MediatorRed2> ();
//						});
//						ViewManager.inst.ShowReward (gift);
                    }
                });
            });
            go.height = 280;
            go.AddChild(it);
            chatModel.IsEffect(data, go);
        }
        else if (data ["ctype"].ToString() == "require_guild_support")
        {
//			go.name = go.name+"_isRed";
            it   = Tools.GetComponent(Config.ITEM_REQUEST).asCom;
            text = it.GetChild("n2").asTextField;
            bar  = it.GetChild("n9") as ComProgressBar;
            bar.SetTextSize(28);
            bar.offsetY = 8;
            ComCard ci = it.GetChild("n8") as ComCard;
            btn1      = it.GetChild("n5").asButton;
            btn1.text = Tools.GetMessageById("22049");
            bar.skin  = ComProgressBar.BAR7;

            CardVo vo = DataManager.inst.GetCardVo(data ["cid"].ToString());
            text.text = Tools.GetMessageById("22019");
            it.GetChild("n16").text = Tools.GetMessageById("22012");
            it.GetChild("n10").text = Tools.GetMessageById("22033");
            it.GetChild("n18").text = Tools.GetMessageColor("[0]" + vo.exp + "[/0]/" + vo.maxExp, new string[] { "a6fb30" });
            it.GetChild("n1").text  = ModelUser.GetUname(data ["uid"], data ["uname"]);
            it.GetChild("n4").text  = ((DateTime)data ["time"]).ToString("HH:mm:ss");
            Dictionary <string, object> da = (Dictionary <string, object>)data ["data"];
            int count = 0;
            foreach (string n in da.Keys)
            {
                count += Convert.ToInt32(da [n]);
            }
            int max = chatModel.GetCardRequestCount(data ["cid"].ToString(), Convert.ToInt32(data ["effort_lv"]));
            bar.value = count;
            bar.max   = max;
            it.GetChild("n20").asTextField.text = bar.text;
            ci.SetData(vo.id, 1, 1);
            ci.SetText(Tools.GetMessageById(vo.name));
            if (data ["uid"].ToString() == userModel.uid || vo.exp == 0 || !chatModel.IsSendGiveCard() ||
                !chatModel.IsSendCardOver(data) || !chatModel.isSendSupportOutTime(data) || count >= max)
            {
                go.name     = go.name + "_isExc";
                btn1.grayed = true;
            }
            btn1.onClick.Add(() =>
            {
                if (isRequestEffect)
                {
                    return;
                }
                if (count >= max)
                {
                    ViewManager.inst.ShowText(Tools.GetMessageById("22038"));
                    return;
                }
                else if (data ["uid"].ToString() == userModel.uid)
                {
                    ViewManager.inst.ShowText(Tools.GetMessageById("22035"));
                    return;
                }
                else if (vo.exp == 0)
                {
                    ViewManager.inst.ShowText(Tools.GetMessageById("22036"));
                    return;
                }
                else if (!chatModel.IsSendGiveCard())
                {
                    ViewManager.inst.ShowText(Tools.GetMessageById("22022"));
                    return;
                }
                else if (!chatModel.IsSendCardOver(data))
                {
                    ViewManager.inst.ShowText(Tools.GetMessageById("22024"));
                    return;
                }
                else if (!chatModel.isSendSupportOutTime(data))
                {
                    ViewManager.inst.ShowText(Tools.GetMessageById("22037"));
                    return;
                }
                Dictionary <string, object> d = new Dictionary <string, object> ();
                d ["support_id"] = data ["id"].ToString();
                NetHttp.inst.Send(NetBase.HTPP_SENDGUILDSUPPORT, d, (VoHttp v) =>
                {
                    chatModel.Remove_RedCount();
                    isRequestEffect = true;
                    ViewManager.inst.ShowIcon(userModel.GetReward(v.data), () =>
                    {
                        userModel.UpdateData(v.data);
                        chatModel.UpdateGuildSupport(data);
                        DispatchManager.inst.Dispatch(new MainEvent(MainEvent.CHAT_SENDGUILDSUPPORT));
                        isRequestEffect = false;
                    });
                });
            });
            go.height = 300;
            go.AddChild(it);
            chatModel.IsEffect(data, go);
        }
        else if (data ["ctype"].ToString() == "guild_fight_share")
        {
            it = Tools.GetComponent(Config.ITEM_SHARE).asCom;
            object[] fight = (object[])data ["fight_data"];
//			it.GetChild ("n4").text = ModelUser.GetUname (data ["uid"], data ["uname"]);
            string na = "[0]" + ModelUser.GetUname(data ["uid"], data ["uname"]) + "[/0]";
            na = Tools.GetMessageColor(na, new string[] { "dc8100" });
            if (fight [0].ToString() == "1")
            {
                it.GetChild("n2").text = na + Tools.GetMessageById("22042");
            }
            else
            {
                it.GetChild("n2").text = na + Tools.GetMessageById("22043");
            }
            it.GetChild("n6").text = data ["chat"].ToString();
            it.GetChild("n9").text = ((DateTime)data ["time"]).ToString("HH:mm:ss");
            it.GetChild("n0").asButton.onClick.Add(() =>
            {
                this.DispatchGlobalEventWith(MainEvent.SHOW_FIGHTDETAIL, data);
            });
            go.height = 255;
            go.AddChild(it);
            chatModel.IsEffect(data, go);
        }
//		go.Center ();
    }
Exemple #3
0
    public void Socket_Listen()
    {
        NetSocket.inst.AddListener(NetBase.SOCKET_CHAT, (VoSocket vo) =>
        {
            Dictionary <string, object> data = (Dictionary <string, object>)vo.data;
            data ["ctype"]  = "chat";
            data ["effect"] = true;
            chatModel.all.Add(data);
            DispatchManager.inst.Dispatch(new MainEvent(MainEvent.CHAT_SEND, vo.data));
        });

        NetSocket.inst.AddListener(NetBase.SOCKET_APPLEJOINGUILD, (VoSocket vo) =>
        {
            Dictionary <string, object> data = (Dictionary <string, object>)vo.data;
            data ["ctype"]  = "guild";
            data ["effect"] = true;
            chatModel.all.Add(data);
            chatModel.Add_RedCount();
            DispatchManager.inst.Dispatch(new MainEvent(MainEvent.CHAT_APPLEJOINGUILD, vo.data));
        });

        NetSocket.inst.AddListener(NetBase.SOCKET_GUILDJOIN, (VoSocket vo) =>
        {
            Dictionary <string, object> data  = (Dictionary <string, object>)vo.data;
            Dictionary <string, object> user1 = (Dictionary <string, object>)data ["user1"];
            Dictionary <string, object> user2 = (Dictionary <string, object>)data ["user2"];
            string uid      = user2 ["uid"].ToString();
            int index       = chatModel.RemoveChat("guild", uid);
            data ["ctype"]  = "guild_join";
            data ["effect"] = true;
            chatModel.all.Add(data);

            if (index != -1)
            {
                chatModel.Remove_RedCount();
            }
            else
            {
                chatModel.Add_RedCount();
            }
            DispatchManager.inst.Dispatch(new MainEvent(MainEvent.CHAT_GUILDJOIN, vo.data));
        });

        NetSocket.inst.AddListener(NetBase.SOCKET_GUILDMODIFY, (VoSocket vo) =>
        {
            Dictionary <string, object> data  = (Dictionary <string, object>)vo.data;
            Dictionary <string, object> user1 = (Dictionary <string, object>)data ["user1"];
            Dictionary <string, object> user2 = (Dictionary <string, object>)data ["user2"];
            if (Convert.ToInt32(data ["num"]) == -1)             //被T
            {
                chatModel.Clear();
                if (userModel.uid == user2 ["uid"].ToString())
                {
                    DispatchManager.inst.Dispatch(new MainEvent(MainEvent.GUILD_ESC, 10));
                }
                else if (guildModel.my_guild_member != null)
                {
                    guildModel.my_guild_member.Remove(user2 ["uid"].ToString());
                }
            }
            else
            {
                Dictionary <string, object> ttt;
                if (guildModel.my_guild_member != null && guildModel.my_guild_member.ContainsKey(user2 ["uid"].ToString()))
                {
                    ttt = (Dictionary <string, object>)guildModel.my_guild_member [user2 ["uid"].ToString()];
                    ttt ["gradation"] = Convert.ToInt32(data ["num"]);

                    if (userModel.uid == user2 ["uid"].ToString())
                    {
                        guildModel.my_guild_job = Convert.ToInt32(data ["num"]);
                    }
                    if (Convert.ToInt32(data ["num"]) == 0)
                    {
                        ttt = (Dictionary <string, object>)guildModel.my_guild_member [user1 ["uid"].ToString()];
                        ttt ["gradation"] = 1;
                        if (userModel.uid == user1 ["uid"].ToString())
                        {
                            guildModel.my_guild_job = 1;
                        }
                    }
                }
            }
            data ["ctype"]  = "guild_modify";
            data ["effect"] = true;
            chatModel.all.Add(data);
            DispatchManager.inst.Dispatch(new MainEvent(MainEvent.CHAT_GUILDMODIFY, vo.data));
        });

        NetSocket.inst.AddListener(NetBase.SOCKET_GUILDEXIT, (VoSocket vo) =>
        {
            Dictionary <string, object> data  = (Dictionary <string, object>)vo.data;
            Dictionary <string, object> user1 = (Dictionary <string, object>)data ["user"];
            if (userModel.uid == user1 ["uid"].ToString())
            {
                chatModel.Clear();
            }
            else
            {
                data ["ctype"]  = "guild_modify";
                data ["effect"] = true;
                chatModel.all.Add(data);
                DispatchManager.inst.Dispatch(new MainEvent(MainEvent.CHAT_GUILDMODIFY, vo.data));
            }
        });

        NetSocket.inst.AddListener(NetBase.SOCKET_SENDGUILDREDBAG, (VoSocket vo) =>
        {
            Dictionary <string, object> data = (Dictionary <string, object>)vo.data;
            data ["ctype"]  = "send_guild_redbag";
            data ["effect"] = true;
            chatModel.all.Add(data);
            chatModel.Add_RedCount();
            DispatchManager.inst.Dispatch(new MainEvent(MainEvent.CHAT_SENDGUILDREDBAG, vo.data));
        });

        NetSocket.inst.AddListener(NetBase.SOCKET_REQUIREGUILDSUPPORT, (VoSocket vo) =>
        {
            Dictionary <string, object> data = (Dictionary <string, object>)vo.data;
            data ["ctype"]  = "require_guild_support";
            data ["effect"] = true;
            chatModel.all.Add(data);
            if (data ["uid"].ToString() != userModel.uid)
            {
                chatModel.Add_RedCount();
            }
            DispatchManager.inst.Dispatch(new MainEvent(MainEvent.CHAT_REQUIREGUILDSUPPORT, vo.data));
        });

        NetSocket.inst.AddListener(NetBase.SOCKET_SENDGUILDSUPPORT, (VoSocket vo) =>
        {
            Dictionary <string, object> data = (Dictionary <string, object>)vo.data;
            Dictionary <string, object> da   = (Dictionary <string, object>)data ["require_user"];
            string uid    = da ["uid"].ToString();
            string cardId = "";
            string name   = ModelUser.GetUname(data ["uid"], data ["name"]);
            int count     = -1;
            if (userModel.uid == uid)
            {
                foreach (string n in da.Keys)
                {
                    if (n == Config.ASSET_GOLD)
                    {
                        userModel.gold = Convert.ToInt32(da [n]);
                    }
                    else if (n == Config.ASSET_CARD)
                    {
                        Dictionary <string, object> temp = (Dictionary <string, object>)da [n];
                        foreach (string id in temp.Keys)
                        {
                            count = userModel.GetCardMulCard(userModel.card [id], temp [id]);
                            userModel.card [id] = temp [id];
                            cardId = id;
                        }
                    }
                }
                if (count != -1)
                {
                    string str = "";
                    str        = count == 0 ? " " : "X" + count.ToString();
                    string msg = Tools.GetMessageById("14035", new string[] { name, CardVo.GetCardName(cardId), str });
                    msg        = Tools.GetMessageColor(msg, new string[] { "dc8100", "2699ea" });
                    if (count == 0)
                    {
                        ViewManager.inst.ShowText(Tools.GetMessageById("33212"));
                    }
                    ViewManager.inst.ShowMessage(msg);
                }
            }
            chatModel.UpdateGuildSupport(data);             //List<int> index =
            DispatchManager.inst.Dispatch(new MainEvent(MainEvent.CHAT_SENDGUILDSUPPORT));
        });

        NetSocket.inst.AddListener(NetBase.SOCKET_GUILDFIGHTSHARE, (VoSocket vo) =>
        {
            Dictionary <string, object> data = (Dictionary <string, object>)vo.data;
            data ["ctype"]  = "guild_fight_share";
            data ["effect"] = true;
            chatModel.all.Add(data);
            DispatchManager.inst.Dispatch(new MainEvent(MainEvent.CHAT_FIGHTSHARE, vo.data));
        });

        NetSocket.inst.AddListener(NetBase.SOCKET_NOTICE, (VoSocket vo) =>
        {
            Dictionary <string, object> d = (Dictionary <string, object>)vo.data;
            foreach (string n in d.Keys)
            {
                userModel.notice [n] = d [n];
            }
            DispatchManager.inst.Dispatch(new MainEvent(MainEvent.RED_UPDATE, vo.data));
        });

        NetSocket.inst.AddListener(NetBase.SOCKET_GETINVITE, (VoSocket vo) =>
        {
            if (!userModel.IsInvite())
            {
                return;
            }
//			bool isOk = userModel.GetUnlcok (Config.UNLOCK_TEAMMATCH);
//			if (!isOk)
//				return;
//			isOk = userModel.GetUnlcok (Config.UNLOCK_FREEMATCH1);
//			if (!isOk)
//				return;
//			isOk = userModel.GetUnlcok (Config.UNLOCK_FREEMATCH2);
//			if (!isOk)
//				return;
            Dictionary <string, object> data = (Dictionary <string, object>)vo.data;
            data ["type"] = 0;
            ViewManager.inst.ShowInviteAlert(data);
//			string name = ModelUser.GetUname (data ["uid"], data ["name"]);
//			string teamId = data ["team_id"].ToString ();
//			ViewManager.inst.ShowAlert (Tools.GetMessageById ("25006", new String[]{ name }), (int index) =>
//			{
//				if (index == 1)
//				{
//					Dictionary<string,object> da = new Dictionary<string, object> ();
//					da ["team_id"] = teamId;
//					NetSocket.inst.Send (NetBase.SOCKET_ACCEPTINVITE, da);
//				}
//			}, true);
        });

        NetSocket.inst.AddListener(NetBase.SOCKET_ACCEPTINVITE, (VoSocket vo) =>
        {
            if (vo.data is Boolean && !Convert.ToBoolean(vo.data))
            {
                ViewManager.inst.ShowText(Tools.GetMessageById("25007"));
                return;
            }
            fightModel.SetTeam(vo.data);
            fightModel.isRequest = false;
            ViewManager.inst.ShowScene <MediatorMain> ();
            ViewManager.inst.ShowView <MediatorTeamMatch> ();
            ViewManager.inst.CloseInviteAlertAll();
        });

        NetSocket.inst.AddListener(NetBase.SOCKET_FREEGETINVITE, (VoSocket vo) =>
        {
            if (!userModel.IsInvite())
            {
                return;
            }
            bool isOk = userModel.GetUnlcok(Config.UNLOCK_TEAMMATCH);
            if (!isOk)
            {
                return;
            }
            isOk = userModel.GetUnlcok(Config.UNLOCK_FREEMATCH1);
            if (!isOk)
            {
                return;
            }
            isOk = userModel.GetUnlcok(Config.UNLOCK_FREEMATCH2);
            if (!isOk)
            {
                return;
            }
            Dictionary <string, object> data = (Dictionary <string, object>)vo.data;
            data ["type"] = 1;
            ViewManager.inst.ShowInviteAlert(data);
//			string name = ModelUser.GetUname (data ["uid"], data ["name"]);
//			string roomId = data ["room_id"].ToString ();
//			ViewManager.inst.ShowAlert (Tools.GetMessageById ("25040", new String[]{ name }), (int index) =>
//			{
//				if (index == 1)
//				{
//					Dictionary<string,object> da = new Dictionary<string, object> ();
//					da ["room_id"] = roomId;
//					NetSocket.inst.Send (NetBase.SOCKET_FREEACCEPTINVITE, da);
//				}
//			}, true);
        });

        NetSocket.inst.AddListener(NetBase.SOCKET_FREEACCEPTINVITE, (VoSocket vo) =>
        {
            if (vo.data is Boolean && !Convert.ToBoolean(vo.data))
            {
                ViewManager.inst.ShowText(Tools.GetMessageById("25007"));
                return;
            }
            fightModel.SetFreeTeam(vo.data);
            fightModel.isRequest = false;
            ViewManager.inst.ShowScene <MediatorMain> ();
            ViewManager.inst.ShowView <MediatorFreeMatch> ();
            ViewManager.inst.CloseInviteAlertAll();
        });

        NetSocket.inst.AddListener(NetBase.SOCKET_SHOWMSG, (VoSocket vo) =>
        {
            Dictionary <string, object> data = (Dictionary <string, object>)vo.data;
            string id = data ["id"].ToString();
            Dictionary <string, object> reward = userModel.GetReward(data ["data"]);
            userModel.UpdateData(data ["data"]);
            string msg = "";
            if (id == "share")
            {
                msg = Tools.GetMessageById("14034", new string[] { reward ["coin"].ToString() });
                msg = Tools.GetMessageColor(msg, new string[] { "dc8100", "2699ea" });
                DispatchManager.inst.Dispatch(new MainEvent(MainEvent.EVENTSHARE, "3"));
                ViewManager.inst.ShowMessage(msg);
            }
        });

        NetSocket.inst.AddListener(NetBase.SOCKET_GRABGUILDREDBAG, (VoSocket vo) =>
        {
            userModel.records ["guild_redbag_log"] = vo.data;
//			Dictionary<string,object> da = (Dictionary<string,object>)vo.data;
//			Log.debug ("remain_num - " + da ["remain_num"].ToString ());
            DispatchManager.inst.Dispatch(new MainEvent(MainEvent.CHAT_ISSENDREDBAG));
        });

        NetSocket.inst.AddListener(NetBase.SOCKET_GETRESUILTPUSH, (VoSocket vo) =>
        {
            if (fightModel.fightResult != null)
            {
                return;
            }
            Dictionary <string, object> data = new Dictionary <string, object> ();
            data ["data"]          = vo.data;
            data ["type"]          = fightModel.fightType;
            fightModel.fightResult = data;
            DispatchManager.inst.Dispatch(new MainEvent(MainEvent.FIGHT_RESULT, data));
        });
        NetSocket.inst.AddListener(NetBase.SOCKET_GETRESUILTTEAMPUSH, (VoSocket vo) =>
        {
            if (fightModel.fightResult != null)
            {
                return;
            }
            Dictionary <string, object> data = new Dictionary <string, object> ();
            data ["data"]          = vo.data;
            data ["type"]          = fightModel.fightType;
            fightModel.fightResult = data;
            DispatchManager.inst.Dispatch(new MainEvent(MainEvent.FIGHT_RESULT, data));
        });
    }