73 lines
2.0 KiB
C#
73 lines
2.0 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Networking;
|
|
using UnityEngine.UI;
|
|
|
|
public class RankAllPanel : BasePanel
|
|
{
|
|
public Button btnClose;
|
|
public Button btnHelp;
|
|
|
|
//本机玩家名次
|
|
public Text txtRank;
|
|
//玩家名字
|
|
public Text txtName;
|
|
//本机玩家分数
|
|
public Text txtScore;
|
|
|
|
public ScrollRect svRank;
|
|
|
|
|
|
public override void Init()
|
|
{
|
|
btnClose.onClick.AddListener(() =>
|
|
{
|
|
UIManager.Instance.HidePanel<RankAllPanel>(false);
|
|
});
|
|
}
|
|
|
|
//给外界更新面板
|
|
public void UpdatePanel(List<PlayerData> rankData)
|
|
{
|
|
for (int i = 0; i < rankData.Count; i++)
|
|
{
|
|
//动态创建预设体对象
|
|
if (i < 3)
|
|
{
|
|
GameObject item = Instantiate(Resources.Load<GameObject>("UI/RankItem1"));
|
|
item.transform.SetParent(svRank.content, false);
|
|
RankItem1 rankItem1 = item.GetComponent<RankItem1>();
|
|
rankItem1.InitInfo(rankData[i], i + 1);
|
|
}
|
|
else
|
|
{
|
|
GameObject item = Instantiate(Resources.Load<GameObject>("UI/RankItem2"));
|
|
item.transform.SetParent(svRank.content, false);
|
|
RankItem2 rankItem2 = item.GetComponent<RankItem2>();
|
|
rankItem2.InitInfo(rankData[i], i + 1);
|
|
}
|
|
}
|
|
|
|
UpdatePlayer(GameDataMgr.Instance.rankAllData);
|
|
}
|
|
|
|
public void UpdatePlayer(Dictionary<string, List<PlayerData>> rankData)
|
|
{
|
|
for (int i = 0; i < rankData["UserList"].Count; i++)
|
|
{
|
|
if (GameDataMgr.Instance.player.openId == rankData["UserList"][i].openId)
|
|
{
|
|
txtRank.text = (i+1).ToString();
|
|
txtName.text = GameDataMgr.Instance.player.username;
|
|
txtScore.text = rankData["UserList"][i].weekScore.ToString();
|
|
return;
|
|
}
|
|
}
|
|
|
|
txtRank.text = "";
|
|
txtName.text = GameDataMgr.Instance.player.username;
|
|
txtScore.text = "无";
|
|
}
|
|
}
|