//--------------------------------------------------------
|
// [Author]: 玩个游戏
|
// [ Date ]: Wednesday, September 26, 2018
|
//--------------------------------------------------------
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
//玩家通用排名
|
public class PlayerRankCell : MonoBehaviour
|
{
|
[SerializeField] AvatarCell avatarCell;
|
[SerializeField] Text rankText;
|
[SerializeField] Text rankValueText; //排名比较内容
|
[SerializeField] Text nameText;
|
[SerializeField] OfficialTitleCell officialTitleCell;
|
[SerializeField] Button queryPlayerBtn; //后续添加点击查看玩家详情
|
|
|
// rank 为0 代表玩家自己
|
public void Display(int rankType, int rank, string valueFormat)
|
{
|
RankData rankData = null;
|
if (rank != 0)
|
{
|
rankData = RankModel.Instance.GetRankDataByRank(rankType, rank);
|
}
|
else
|
{
|
rankData = RankModel.Instance.GetMyRank(rankType);
|
if (rankData == null)
|
{
|
//取玩家自己的数据
|
avatarCell.InitUI(AvatarHelper.GetAvatarModel((int)PlayerDatas.Instance.baseData.PlayerID,
|
PlayerDatas.Instance.baseData.face,
|
PlayerDatas.Instance.baseData.facePic));
|
rankText.text = Language.Get("L1045");
|
rankValueText.text = "0";//Language.Get("L1125");
|
nameText.text = PlayerDatas.Instance.baseData.PlayerName;
|
officialTitleCell.InitUI(PlayerDatas.Instance.baseData.realmLevel, PlayerDatas.Instance.baseData.TitleID);
|
return;
|
}
|
rank = rankData.rank;
|
}
|
if (rankData == null)
|
{
|
officialTitleCell.SetActive(false);
|
avatarCell.SetActive(false);
|
nameText.text = Language.Get("L1124");
|
rankValueText.text = "0";//Language.Get("L1125");
|
}
|
else
|
{
|
officialTitleCell.SetActive(true);
|
officialTitleCell.InitUI((int)rankData.value1, (int)rankData.value2);
|
avatarCell.SetActive(true);
|
avatarCell.InitUI(AvatarHelper.GetAvatarModel((int)rankData.id, (int)rankData.value3, (int)rankData.value4));
|
nameText.text = rankData.name1;
|
rankValueText.text = string.Format(valueFormat, UIHelper.ReplaceLargeNum(rankData.cmpValue2 + rankData.cmpValue * Constants.ExpPointValue));
|
}
|
|
rankText.text = rank.ToString();
|
if (queryPlayerBtn != null)
|
{
|
queryPlayerBtn.AddListener(() =>
|
{
|
|
});
|
}
|
}
|
}
|
|
|
|
|
|