//顾问公会好友度转换 private AdviserGuildInfo ChangeAdviserGuildData(Dictionary <string, object> data) { AdviserGuildInfo info = new AdviserGuildInfo(); info.guildID = GameConvert.IntConvert(data["guildID"]); info.guildName = GameConvert.StringConvert(data["guildName"]); info.friendliness = GameConvert.IntConvert(data["friendliness"]); return(info); }
//顾问公会好友度列表 public void onAdviserGuildRank(List <object> list) { GuildCounselorConfig.mGuildFriendsList.Clear(); for (int i = 0; i < list.Count; i++) { Dictionary <string, object> data = list[i] as Dictionary <string, object>; AdviserGuildInfo info = ChangeAdviserGuildData(data); GuildCounselorConfig.mGuildFriendsList.Add(info); } if (GuildCounselorMediator.guildcounselorMediator != null) { GuildCounselorMediator.guildcounselorMediator.SetAdviserGuildList(); } }
//友好度排序 private int AdviserSort(AdviserGuildInfo info1, AdviserGuildInfo info2) { if (info1.friendliness < info2.friendliness) { return(1); } else if (info1.friendliness > info2.friendliness) { return(-1); } else { return(0); } }
//刷新公会列表 private void UpdateRankGrid(UIGridItem item) { AdviserGuildInfo info = item.oData as AdviserGuildInfo; UILabel rankitem = item.mScripts[0] as UILabel; UILabel guildname = item.mScripts[1] as UILabel; UILabel amity = item.mScripts[2] as UILabel; UISprite lalong = item.mScripts[3] as UISprite; rankitem.text = info.rank.ToString(); guildname.text = info.guildName; amity.text = info.friendliness.ToString(); AdviserInfo data = GuildCounselorConfig.GetAdviserInfo(mCurAdviser.id); lalong.gameObject.SetActive(data.guildDBID == info.guildID); }
//添加右侧信息列表 public void SetAdviserGuildList() { List <AdviserGuildInfo> adviserguildlist = GuildCounselorConfig.mGuildFriendsList; adviserguildlist.Sort(AdviserSort); List <object> list = new List <object>(); for (int i = 0; i < adviserguildlist.Count; i++) { AdviserGuildInfo item = adviserguildlist[i]; item.rank = i + 1; list.Add(item); } panel.rankGrid.AddCustomDataList(list); }
//更新顾问公会好友度 public void onUpdataAdviserGuild(Dictionary <string, object> data) { AdviserGuildInfo adviserGuild = ChangeAdviserGuildData(data); for (int i = 0; i < GuildCounselorConfig.mGuildFriendsList.Count; i++) { AdviserGuildInfo info = GuildCounselorConfig.mGuildFriendsList[i]; if (info.guildID == adviserGuild.guildID) { GuildCounselorConfig.mGuildFriendsList.Remove(info); } } GuildCounselorConfig.mGuildFriendsList.Add(adviserGuild); if (GuildCounselorMediator.guildcounselorMediator != null) { GuildCounselorMediator.guildcounselorMediator.SetAdviserGuildList(); } }