125 lines
3.7 KiB
C#
125 lines
3.7 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using GCGame.Table;
|
|
using Module.Log;
|
|
|
|
public class TestingCopyRankInfo
|
|
{
|
|
public long _Rank;
|
|
public string _Name;
|
|
public long _PassedLevel;
|
|
public long _OnRankTime;
|
|
public bool _IsSelf;
|
|
public TestingCopyRankInfo(long rank, string name, long passedLevel, long onRankTime, bool isSelf)
|
|
{
|
|
_Rank = rank;
|
|
_Name = name;
|
|
_PassedLevel = passedLevel;
|
|
_OnRankTime = onRankTime;
|
|
_IsSelf = isSelf;
|
|
}
|
|
}
|
|
|
|
public class TestingRankPanelCtr : MonoBehaviour {
|
|
|
|
public static TestingRankPanelCtr Instance;
|
|
void Awake()
|
|
{
|
|
Instance = this;
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
Instance = null;
|
|
}
|
|
|
|
private int _FubenId = -1;
|
|
private int _SelectDiffcultyType = -1;
|
|
private int _NeedSendDiffcultyEnum = -1;
|
|
public void SetFuBtnId(int _Id, int selectDiffcultyType)
|
|
{
|
|
_SelectDiffcultyType = selectDiffcultyType;
|
|
_FubenId = _Id;
|
|
GetDiffcultyType();
|
|
AskForInfo();
|
|
}
|
|
|
|
public void GetDiffcultyType()
|
|
{
|
|
Tab_TestingCopy testingCopy = TableManager.GetTestingCopyByID(_FubenId, 0);
|
|
if(testingCopy != null)
|
|
{
|
|
_NeedSendDiffcultyEnum = testingCopy.GetDiffcultyEnumValuebyIndex(_SelectDiffcultyType);
|
|
}
|
|
}
|
|
|
|
public void AskForInfo()
|
|
{
|
|
CG_REQ_RANK_LIST req = (CG_REQ_RANK_LIST)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_RANK_LIST);
|
|
req.Ranktype = _NeedSendDiffcultyEnum;
|
|
req.SendPacket();
|
|
}
|
|
|
|
public UIContainerBase _RankItemContainer;
|
|
|
|
private List<TestingCopyRankInfo> _RankInfoList;
|
|
public void OnRankInfoPacket(GC_RET_RANK_LIST packet)
|
|
{
|
|
_RankInfoList = new List<TestingCopyRankInfo>();
|
|
if(Singleton<ObjManager>.GetInstance() == null || !Singleton<ObjManager>.GetInstance().MainPlayer)
|
|
{
|
|
LogModule.ErrorLog("Get Mainplayer null");
|
|
return;
|
|
}
|
|
|
|
ulong _SelfGUID = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Guid;
|
|
for (int index = 0; index < packet.ranklistCount; index++)
|
|
{
|
|
long _PacketSelfGUID = GetProValueInt((int)RankWindowNew.RankPropID.UserGuid, packet.GetRanklist(index));
|
|
TestingCopyRankInfo info = new TestingCopyRankInfo(
|
|
index + 1, //排名
|
|
GetProValueStr((int)RankWindowNew.RankPropID.UserName, packet.GetRanklist(index)),
|
|
GetProValueInt((int)RankWindowNew.RankPropID.TestingCopyPassedLevel, packet.GetRanklist(index)),
|
|
GetProValueInt((int)RankWindowNew.RankPropID.RecordTime, packet.GetRanklist(index)),
|
|
_SelfGUID == (ulong)_PacketSelfGUID);
|
|
|
|
_RankInfoList.Add(info);
|
|
}
|
|
|
|
_RankItemContainer.InitContentItem(_RankInfoList);
|
|
}
|
|
|
|
public void OnBackClick()
|
|
{
|
|
UIManager.CloseUI(UIInfo.TestingRankPanel);
|
|
}
|
|
|
|
long GetProValueInt(int proID, RankElemStruct ranklist)
|
|
{
|
|
if (ranklist == null)
|
|
return -1;
|
|
for (int i = 0; i < ranklist.numberfieldsCount; i++)
|
|
{
|
|
RankFieldNumberStruct numberInfo = ranklist.GetNumberfields(i);
|
|
if (proID == numberInfo.Propid)
|
|
return numberInfo.Propvalue;
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
string GetProValueStr(int proID, RankElemStruct ranklist)
|
|
{
|
|
if (ranklist == null)
|
|
return "";
|
|
for (int i = 0; i < ranklist.stringfieldsCount; i++)
|
|
{
|
|
RankFieldStringStruct stringInfo = ranklist.GetStringfields(i);
|
|
if (proID == stringInfo.Propid)
|
|
return stringInfo.Propvalue;
|
|
}
|
|
return "";
|
|
}
|
|
}
|