/// <summary> /// 更新游戏排行榜数据 /// </summary> /// <param name="_ms"></param> public bool UpdateGameRankingData(UMessage _ms) { CCustomDialog.CloseCustomWaitUI(); RightChessScrolllRect.vertical = true; byte State = _ms.ReadByte(); if (State != 0) { Debug.Log("比赛排行榜数据错误!错误码:" + State); return(false); } SerializableDictionary <int, CPlayerRankingInfo> GameRankingDataDictionary = null; long ContestID = _ms.ReadLong(); if (!ContestRankingDataDictionary.ContainsKey(ContestID)) { ContestRankingDataDictionary.Add(ContestID, new SerializableDictionary <int, CPlayerRankingInfo>()); } GameRankingDataDictionary = ContestRankingDataDictionary[ContestID]; ushort StartIndex = _ms.ReaduShort(); byte DataNum = _ms.ReadByte(); ushort EndIndex = (ushort)(StartIndex + DataNum - 1); CPlayerRankingInfo PlayerRankingInfo = null; for (int index = 0; index < DataNum; ++index) { PlayerRankingInfo = new CPlayerRankingInfo(); PlayerRankingInfo.PlayerName = _ms.ReadString(); PlayerRankingInfo.PlayerIconUrl = _ms.ReadString(); PlayerRankingInfo.PlayerFaceID = _ms.ReadInt(); PlayerRankingInfo.PlayerScore = _ms.ReadInt(); PlayerRankingInfo.PlayerOppScore = _ms.ReadInt(); PlayerRankingInfo.ShengJuValue = _ms.ReadByte(); PlayerRankingInfo.ZhiShengValue = _ms.ReadByte(); PlayerRankingInfo.HouShouValue = _ms.ReadByte(); int RankIndex = StartIndex + index; if (GameRankingDataDictionary.ContainsKey(RankIndex)) { GameRankingDataDictionary[RankIndex] = PlayerRankingInfo; } else { GameRankingDataDictionary.Add(RankIndex, PlayerRankingInfo); } } if (m_ContestID == ContestID) { RefreshGameContestRankingPlayerPanel(StartIndex, EndIndex); } return(true); }
/// <summary> /// 刷新排行榜玩家数据 /// </summary> /// <param name="StartIndex"></param> /// <param name="EndIndex"></param> private void RefreshGameContestRankingPlayerPanel(ushort StartIndex, ushort EndIndex) { Transform PlayerInfoTransform = null; CPlayerRankingInfo PlayerDataInfo = null; for (int index = StartIndex; index <= EndIndex; ++index) { PlayerDataInfo = ContestRankingDataDictionary[m_ContestID][index]; PlayerInfoTransform = RightChessScrolllRect.content.GetChild(index).GetChild(0); Image HeadImage = PlayerInfoTransform.Find("playerinfo/Image_HeadBG/Image_HeadMask/Image_HeadImage").GetComponent <Image>(); HeadImage.sprite = GameMain.hall_.GetIcon(PlayerDataInfo.PlayerIconUrl, (uint)(m_ContestID * 1000 + index), PlayerDataInfo.PlayerFaceID); PlayerInfoTransform.Find("playerinfo/TextName").GetComponent <Text>().text = PlayerDataInfo.PlayerName; PlayerInfoTransform.Find("Textjifen").GetComponent <Text>().text = PlayerDataInfo.PlayerScore.ToString(); PlayerInfoTransform.Find("Textxiaofen").GetComponent <Text>().text = PlayerDataInfo.PlayerOppScore.ToString(); PlayerInfoTransform.Find("Textshengju").GetComponent <Text>().text = PlayerDataInfo.ShengJuValue.ToString(); PlayerInfoTransform.Find("Textzhisheng").GetComponent <Text>().text = PlayerDataInfo.ZhiShengValue.ToString(); PlayerInfoTransform.Find("Texthoushou").GetComponent <Text>().text = PlayerDataInfo.HouShouValue.ToString(); } }