yyl
2025-08-11 b2d7bb59dc37c7b350786b076ee2f344b7c8911f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//--------------------------------------------------------
//    [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(() =>
            {
 
            });
        }
    }
}