public void SetData(Dictionary <string, object> data) { this.data = data; if (data ["type"].ToString() == "0") { this.GetChild("n1").text = Tools.GetMessageById("25006", new String[] { ModelUser.GetUname(data ["uid"], data ["name"]) }); } else { this.GetChild("n1").text = Tools.GetMessageById("25040", new String[] { ModelUser.GetUname(data ["uid"], data ["name"]) }); } this.GetChild("n2").text = ModelUser.GetUname(data ["uid"], data ["name"]); GButton head = this.GetChild("n3").asButton; head.GetChild("n2").text = data ["lv"].ToString(); Tools.SetLoaderButtonUrl(head.GetChild("n0").asButton, ModelUser.GetHeadUrl(Tools.Analysis(data, "head.use").ToString())); GButton btn1 = this.GetChild("n4").asButton; btn1.text = Tools.GetMessageById("14056"); GButton btn2 = this.GetChild("n5").asButton; btn2.text = Tools.GetMessageById("14057"); btn1.onClick.Add(Btn1_Click); btn2.onClick.Add(Btn2_Click); }
private void Item_Render(int index, GObject item) { Dictionary <string, object> data = (Dictionary <string, object>)fightModel.micros [index]; GComponent g = item.asCom; g.GetChild("n1").text = ModelUser.GetUname(data ["uid"], data ["name"]); g.GetChild("n3").asButton.onClick.Add(() => { if (g.GetChild("n3").asButton.selected) { fightModel.AddMicro_Uid(data ["uid"].ToString()); } else { fightModel.RemoveMicro_Uid(data ["uid"].ToString()); } }); }
// private void Quit_Click () // { // Quit_Team (); // } private void ItemRender(int index, GObject item) { GComponent g = item.asCom; Controller c = g.GetController("c1"); GComponent bg = g.GetChild("n0").asCom; bg.RemoveEventListeners(); //lht g.GetChild("n13").visible = false; g.GetChild("n17").visible = false; // if (index % 2 == 0) { bg.GetChild("n0").visible = ((index % 2) != 0); // Debug.LogError (bg.GetChild ("n0").visible); if (index > fightModel.team1.Length - 1) { // g.GetChild ("n13").visible = false; c.selectedIndex = 2; if (fightModel.isLeader) { g.GetChild("n12").text = Tools.GetMessageById("25035"); bg.onClick.Add(() => { if (fightModel.team1.Length == 4) { ViewManager.inst.ShowText(Tools.GetMessageById("25048")); return; } fightModel.InviteRequest(); }); } else { g.GetChild("n12").text = Tools.GetMessageById("25047"); } if (fightModel.isMatch) { g.GetChild("n12").text = Tools.GetMessageById("25057"); } return; } Dictionary <string, object> data = (Dictionary <string, object>)fightModel.team1 [index]; // if (fightModel.isLeader) // { // if (data ["uid"].ToString () == userModel.uid) // g.GetChild ("n13").visible = true; // else // g.GetChild ("n13").visible = false; //// } // else // g.GetChild ("n13").visible = false; // g.GetChild ("n4").asLoader.url = Tools.GetSexUrl (data ["sex"]); // } g.GetChild("n5").text = ModelUser.GetUname(data ["uid"], data ["name"]); g.GetChild("n6").text = data ["guild_name"] == null?Tools.GetMessageById("25034") : data ["guild_name"].ToString(); GLoader img = g.GetChild("n11").asCom.GetChild("n1").asLoader; GTextField txt = g.GetChild("n11").asCom.GetChild("n2").asTextField; img.url = userModel.GetRankImg(data ["rank_score"]); txt.text = data ["rank_score"].ToString(); GButton head = g.GetChild("n3").asButton; head.GetChild("n2").text = data ["lv"].ToString(); //Tools.SetLoaderButtonUrl (head.GetChild ("n0").asButton, ModelUser.GetHeadUrl (Tools.Analysis (data, "head.use").ToString ())); if ((int)data["uid"] > 0) { Tools.SetLoaderButtonUrl(head.GetChild("n0").asButton, ModelUser.GetHeadUrl(Tools.Analysis(data, "head.use").ToString())); } else { Tools.SetLoaderButtonUrl(head.GetChild("n0").asButton, ModelUser.GetHeadUrl(data["name"].ToString(), false, true)); } GButton btn = g.GetChild("n8").asButton; btn.text = Tools.GetMessageById("20119"); if (fightModel.isLeader) { if (data ["uid"].ToString() == userModel.uid) { c.selectedIndex = 0; } else { c.selectedIndex = 1; } } else { c.selectedIndex = 0; } btn.RemoveEventListeners(); if (fightModel.isMatch) { btn.enabled = false; } else { btn.enabled = true; } btn.onClick.Add(() => { ViewManager.inst.ShowAlert(Tools.GetMessageById("25049"), (int id) => { if (id == 1) { NetSocket.inst.AddListener(NetBase.SOCKET_QUITTEAM, (VoSocket vo) => { //踢出队员成功提示,未配置上 25014 ViewManager.inst.ShowText(Tools.GetMessageById("25014")); NetSocket.inst.RemoveListener(NetBase.SOCKET_QUITTEAM); Log.debug("踢出队员 - " + vo.data.ToString()); // ViewManager.inst.ShowText (Tools.GetMessageById ("25014")); }); Dictionary <string, object> da = new Dictionary <string, object> (); da ["uid"] = data ["uid"].ToString(); NetSocket.inst.Send(NetBase.SOCKET_QUITTEAM, da); } }, true); }); }
private void ItemRender(int index, GObject item) { GComponent g = item.asCom; GLoader img = g.GetChild("n14").asCom.GetChild("n1").asLoader; GTextField txt = g.GetChild("n14").asCom.GetChild("n2").asTextField; GButton head = g.GetChild("n1").asButton; // head.GetChild("n0").asButton.GetChild("n2").asImage.visible = false;//隐藏邀请界面头像圈 GButton btn = g.GetChild("n6").asButton; GButton btn_mask = g.GetChild("n9").asButton; bool IsVisible = SetListCSS(item, fightModel.curInvite, index); Log.debug("IsVisible" + IsVisible + "," + fightModel.curInvite.Length + "ddd" + index); if (IsVisible) { Dictionary <string, object> data = (Dictionary <string, object>)fightModel.curInvite[index]; g.GetChild("n3").text = ModelUser.GetUname(data["uid"], data["name"]); // g.GetChild ("n4").text = data ["guild_name"] == null ? Tools.GetMessageById ("25034") : data ["guild_name"].ToString (); // g.GetChild ("n13").text = data ["lv"].ToString (); // g.GetChild ("n2").asLoader.url = Tools.GetSexUrl (data ["sex"]); // Controller c1 = g.GetController ("c1"); //g.GetChild("n0").visible = ((index % 2) != 0); if (tabC1.selectedIndex == 0) { g.GetChild("n7").text = Tools.GetNearDistance(data["dis"]); } else { string state = data["state"].ToString(); if (state == "0") { g.GetChild("n7").text = Tools.GetMessageById("25029"); } else if (state == "1") { if (fightModel.isTeam(data["uid"].ToString())) { g.GetChild("n7").text = Tools.GetMessageById("25052"); } else { g.GetChild("n7").text = Tools.GetMessageById("25030"); } } else if (state == "2") { g.GetChild("n7").text = Tools.GetMessageById("25051"); } } img.url = userModel.GetRankImg(data["rank_score"]); txt.text = data["rank_score"].ToString(); head.GetChild("n2").text = data["lv"].ToString(); Tools.SetLoaderButtonUrl(head.GetChild("n0").asButton, ModelUser.GetHeadUrl(Tools.Analysis(data, "head.use").ToString())); btn.selected = Convert.ToBoolean(data["check"]); btn.RemoveEventListeners(); btn.onClick.Add(() => { btn.selected = !btn.selected; data["check"] = btn.selected; this.GetChild("n7").text = Tools.GetMessageById("25036", new string[] { fightModel.GetCheck().ToString() }); bool isok = fightModel.GetInviteSelectAll(tabC1.selectedIndex); check.selected = isok; }); btn_mask.RemoveEventListeners(); btn_mask.onClick.Add(() => { btn.selected = !btn.selected; data["check"] = btn.selected; this.GetChild("n7").text = Tools.GetMessageById("25036", new string[] { fightModel.GetCheck().ToString() }); bool isok = fightModel.GetInviteSelectAll(tabC1.selectedIndex); check.selected = isok; }); } }
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 (); }
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)); }); }
// private void Item_Render (int index, GObject go) // { // ComIcon ci = (go as GComponent).GetChild ("n0") as ComIcon; // ci.SetData (ld [index]); // } private void Item_Render(int index, GObject go) { Dictionary <string, object> data = (Dictionary <string, object>)chatModel.grab_List [index]; GComponent g = go as GComponent; GLoader bg = g.GetChild("n0").asLoader; if (index == 0 || index % 2 == 0) { bg.alpha = 1; } else { bg.alpha = 0; } GButton head = g.GetChild("n1").asButton; GTextField name = g.GetChild("n2").asTextField; // GTextField txt = g.GetChild ("n3").asCom.GetChild ("n0").asTextField; GList list = g.GetChild("n4").asList; Controller c1 = g.GetController("c1"); // (g.GetChild ("n3").asCom as ComGold).RemoveListener (); bg.url = Tools.GetResourceUrl("Image2:n_bg_tanban6"); if (userModel.uid == data ["uid"].ToString()) { c1.selectedIndex = 1; bg.alpha = 1; bg.url = Tools.GetResourceUrl("Image2:n_bg_tanban6_"); } else { c1.selectedIndex = 0; } 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())); name.text = ModelUser.GetUname(data ["uid"].ToString(), ModelUser.GetUname(data ["uid"], data ["uname"])); // txt.text = data ["gold"].ToString (); // bool isGift = chatModel.isRedbagGift; // chatModel.isRedbagGift = false; // if (isGift) // { // if (userModel.uid != data ["uid"].ToString ()) // isGift = false; // } List <object> li = new List <object> (); if (data ["card"] != null) { Dictionary <string, object> da = new Dictionary <string, object> (); da ["card"] = data ["card"]; li = Tools.GetReward(da); } li.Add(new Dictionary <string, object> () { { "gold", data ["gold"] } }); list.itemRenderer = (int i, GObject item) => { ComBigIcon ci = item.asCom.GetChild("n0") as ComBigIcon; Dictionary <string, object> dd = (Dictionary <string, object>)li [i]; foreach (string n in dd.Keys) { ci.SetData(n, Convert.ToInt32(dd [n]), 4); if (chatModel.isRedbagGift && userModel.uid == data ["uid"].ToString()) { ci.RotateCard(1f); } else { ci.RotateCard(0f); } } }; list.numItems = li.Count; list.x = 545 - ((li.Count - 1) * 130); }
private void UpdateItem(int index, object data) { Dictionary <string, object> da = (Dictionary <string, object>)data; GComponent g = items [index]; // g.GetController ("c1").selectedIndex = 2; g.GetChild("n14").visible = false; g.GetChild("n0").asCom.GetChild("n3").visible = false; g.RemoveEventListeners(); g.onClick.Add(() => { if (fightModel.isLeader && (da != null && Convert.ToInt32(da ["uid"]) <= 0)) { NetSocket.inst.AddListener(NetBase.SOCKET_REMOVEBOT, (VoSocket vo) => { NetSocket.inst.RemoveListener(NetBase.SOCKET_REMOVEBOT); if (Convert.ToBoolean(vo.data)) { ViewManager.inst.ShowText(Tools.GetMessageById("25019")); } else { ViewManager.inst.ShowText(Tools.GetMessageById("25020")); } }); Dictionary <string, object> d = new Dictionary <string, object> (); d ["index"] = index; NetSocket.inst.Send(NetBase.SOCKET_REMOVEBOT, d); } else if (da == null || (da != null && Convert.ToInt32(da ["uid"]) <= 0)) { if (fightModel.freeType == 2) { NetSocket.inst.AddListener(NetBase.SOCKET_CHANGEPOS, (VoSocket vo) => { NetSocket.inst.RemoveListener(NetBase.SOCKET_CHANGEPOS); Log.debug("交换位置 - " + vo.data.ToString()); // if (Convert.ToBoolean (vo.data)) // ViewManager.inst.ShowText (Tools.GetMessageById ("25022")); // else // ViewManager.inst.ShowText (Tools.GetMessageById ("25023")); }); Dictionary <string, object> d = new Dictionary <string, object> (); d ["pos"] = index; NetSocket.inst.Send(NetBase.SOCKET_CHANGEPOS, d); } } }); g.touchable = true; if (data == null) { ClearItem(g); return; } if (Convert.ToInt32(da ["uid"]) < 0) { // if (fightModel.isLeader) // { // g.GetController ("c1").selectedIndex = 3; // g.GetChild ("n4").text = Tools.GetMessageById ("25027"); // g.GetChild ("n4").text = Tools.GetMessageById ("25028", new string[]{ da ["uid"].ToString () }); // g.GetChild ("n4").text = da ["name"].ToString (); // } // else // { g.GetController("c1").selectedIndex = 3; g.GetChild("n4").text = da ["name"].ToString(); // } } else { g.GetController("c1").selectedIndex = 0; GButton head = g.GetChild("n0").asButton; head.GetChild("n2").text = da ["lv"].ToString(); Tools.SetLoaderButtonUrl(head.GetChild("n0").asButton, ModelUser.GetHeadUrl(Tools.Analysis(da, "head.use").ToString())); g.GetChild("n1").asTextField.text = ModelUser.GetUname(da ["uid"], da ["name"]); g.GetChild("n14").visible = da ["uid"].ToString() == userModel.uid ? true : false; } }