/// <summary> /// 设置排行单项数据 /// </summary> private void SetBattleRankItem(GameObject go, NetMessage.MemberInfo memberInfo, int rank) { string icon = ""; string name = "--"; int score = 0; int mvp = 0; bool self = false; if (memberInfo != null) { icon = memberInfo.icon; name = memberInfo.name; score = memberInfo.score; mvp = memberInfo.mvp; self = memberInfo.id == LocalPlayer.Get().playerData.userId; } go.transform.Find("icon").GetComponent <UISprite> ().spriteName = icon; go.transform.Find("name").GetComponent <UILabel> ().text = name; go.transform.Find("score").GetComponent <UILabel> ().text = score.ToString(); go.transform.Find("mvp").GetComponent <UILabel> ().text = mvp.ToString(); go.transform.Find("rank").GetComponent <UILabel> ().text = rank.ToString(); if (rank > 3) { go.transform.Find("rank/bg").gameObject.SetActive(false); } go.transform.Find("bg").gameObject.SetActive(self); go.SetActive(memberInfo != null); }
public override void OnUIEventHandler(EventId eventId, params object[] args) { if (eventId == EventId.OnGetLeagueInfoResult) { // 获取的是自身的联赛信息,则要么在战斗,要么在等待 leagueInfo = (NetMessage.LeagueInfo)args [0]; selfInfo = (NetMessage.MemberInfo)args [1]; start = TimeSystem.Instance.GetTime(leagueInfo.combat_start); end = TimeSystem.Instance.GetTime(leagueInfo.combat_finish); DateTime serverTime = TimeSystem.Instance.GetServerTime(); if (serverTime.CompareTo(start) < 0) { // 未开始 SetWaitPage(); } else if (serverTime.CompareTo(end) < 0) { // 战斗中 if (selfInfo.battle_num == 0) { SetWaitPage(); } else { SetBattlePage(); // 请求排行榜 NetSystem.Instance.helper.RequestLeagueRank(leagueInfo.id, 0); } } else { // 已结束 SetResultPage(); // 请求排行榜 NetSystem.Instance.helper.RequestLeagueRank(leagueInfo.id, 0); } } else if (eventId == EventId.OnLeagueListResult) { // 展示报名信息 int start = (int)args [0]; IList <NetMessage.LeagueInfo> leagueList = (IList <NetMessage.LeagueInfo>)args [1]; if (leagueList == null || leagueList.Count == 0) { // 没有活动 SetNotOpenPage(); } else { // 显示第一个活动 SetSignUpPage(leagueList [0]); } } else if (eventId == EventId.OnLeagueSignUpResult) { // 报名结果 NetMessage.ErrCode code = (NetMessage.ErrCode)args [0]; string leagueId = (string)args [1]; if (code == NetMessage.ErrCode.EC_Ok) { // 不需要,自动发送获取联赛信息的消息 } else if (code == NetMessage.ErrCode.EC_LeagueIsFull) { Tips.Make(LanguageDataProvider.GetValue(210)); } else if (code == NetMessage.ErrCode.EC_LeagueIn) { Tips.Make(LanguageDataProvider.GetValue(211)); } else if (code == NetMessage.ErrCode.EC_LeagueNotExist) { Tips.Make(LanguageDataProvider.GetValue(212)); } else if (code == NetMessage.ErrCode.EC_LeagueNotOpen) { Tips.Make(LanguageDataProvider.GetValue(213)); } else { Tips.Make(LanguageDataProvider.GetValue(214) + code); } } else if (eventId == EventId.OnLeagueRankResult) { IList <NetMessage.MemberInfo> list = (IList <NetMessage.MemberInfo>)args [1]; rankList.AddRange(list); if (battlePage.activeSelf) { SetRankScrollView(battleRankScrollView, battleRankGrid, battleStaticRanks); } else if (resultPage.activeSelf) { SetRankScrollView(resultRankScrollView, resultRankGrid, resultStaticRanks); // 设置结果自己的排名 SetResultSelfRank(); } } else if (eventId == EventId.OnLeagueMatchResult) { NetMessage.ErrCode code = (NetMessage.ErrCode)args [0]; if (code == NetMessage.ErrCode.EC_Ok) { } else if (code == NetMessage.ErrCode.EC_LeagueNotInMatchTime) { Tips.Make(LanguageDataProvider.GetValue(215)); } else { Tips.Make(LanguageDataProvider.GetValue(216)); } } }