少年修仙传客户端代码仓库
lcy
2024-12-16 a39c35fc6449430cd02bccb681c4a0a880e46cd9
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
using vnxbqy.UI;
using System.Collections;
using System.Collections.Generic;
 
using UnityEngine;
using UnityEngine.UI;
namespace EnhancedUI.EnhancedScroller
{
    public class FairyViewCell : ScrollerUI
    {
        [SerializeField] EmblemCell emblemCell;
        [SerializeField] Image m_SelectImg;
        [SerializeField] Image m_RankImg;
        [SerializeField] Image m_RealmImg;
        [SerializeField] Text m_RankTxt;
        [SerializeField] Text m_FairyNameTxt;
        [SerializeField] Text m_FairyLeaderNameTxt;
        [SerializeField] Text m_FairyLvTxt;
        [SerializeField] Text m_FairyMemberCntTxt;
        [SerializeField] Text m_FairyGradeTxt;
 
        private FairyModel m_Model;
        private FairyModel model
        {
            get
            {
                return m_Model ?? (m_Model = ModelCenter.Instance.GetModel<FairyModel>());
            }
        }
        public override void Refresh(CellView cell)
        {
            int index = cell.index;
            bool jiaFairy = false;
            if (index >= FairyModel.JiaFairyStartIndex)
            {
                index = index - FairyModel.JiaFairyStartIndex;
                jiaFairy = true;
            }
            if (!jiaFairy && index >= model.fairyList.Count)
            {
                return;
            }
            PlayerFairyData.FairyData fairy = null;
            if (!jiaFairy)
            {
                fairy = model.fairyList[index];
            }
            DisplayRank(jiaFairy ? (index + model.fairyList.Count) : index);
            var _jiaId = jiaFairy ? model.jiaFairyIds[index] : 0;
 
            if (fairy != null) 
            {
                if (PlayerDatas.Instance.fairyData.fairy == null)
                {
                    emblemCell.InitUI(EmblemHelper.GetOtherEmblemModel(fairy.EmblemID));
                }
                else
                {
                    emblemCell.InitUI(EmblemHelper.GetEmblemModel(jiaFairy ? model.jiaFairyIds[index] : (int)fairy.FamilyID, fairy.EmblemID));
                }
            }
            else
            {
                emblemCell.InitUI(EmblemHelper.GetOtherEmblemModel(EmblemHelper.GetDefaultFamilyEmblemId()));
            }
 
            m_FairyNameTxt.text = jiaFairy ? model.jiaFairyNames[_jiaId - 1] : fairy.FamilyName;
            m_FairyNameTxt.color = jiaFairy || !SelfFairy(fairy) ? UIHelper.GetUIColor(TextColType.NavyBrown) : UIHelper.GetUIColor(TextColType.Green, true);
            m_FairyLeaderNameTxt.text = jiaFairy ? string.Empty : fairy.leaderName;
            m_RealmImg.SetActive(!jiaFairy && fairy.OfficialRank > 0);
            if (!jiaFairy && fairy.OfficialRank > 0)
            {
                RealmConfig presentCfg = RealmConfig.Get(fairy.OfficialRank);
                if (presentCfg != null)
                {
                    m_RealmImg.SetSprite(presentCfg.Img);
                    m_RealmImg.SetNativeSize();
                }
            }
            m_FairyLvTxt.text = jiaFairy ? "1" : fairy.FamilyLV.ToString();
            FamilyConfig cfg = FamilyConfig.Get(jiaFairy ? 1 : fairy.FamilyLV);
            if (cfg != null)
            {
                m_FairyMemberCntTxt.text = StringUtility.Contact(jiaFairy ? 0 : fairy.MemberCount, "/", cfg.memberCnt);
            }
 
            if (jiaFairy)
            {
                m_FairyGradeTxt.text = string.Empty;
            }
            else
            {
                if (fairy.WarRank != 0)
                {
                    m_FairyGradeTxt.text = FairyModel.GetFairyGradeLabel((int)fairy.WarRank);
                }
                else
                {
                    m_FairyGradeTxt.text = UIHelper.ReplaceLargeNum(fairy.totalFightPower);
                }
            }
 
            m_SelectImg.SetSprite(model.presentFairy == (jiaFairy ? index + FairyModel.JiaFairyStartIndex : index) ? "RankList_ChoosenBottom" :
                (jiaFairy ? index + model.fairyList.Count : index) % 2 == 0 ? "RankList_SingleBottom" : "RankList_QuanTouMing");
            if (PlayerDatas.Instance.fairyData.IsSearching)
            {
                return;
            }
            if (!jiaFairy && index >= PlayerFairyData.PageCnt / 2 + model.page * PlayerFairyData.PageCnt && model.fairyList.Count >= PlayerFairyData.PageCnt * (model.page + 1))
            {
                model.page++;
                model.OnSearchPageList();
            }
        }
 
        private void DisplayRank(int _index)
        {
            m_RankImg.SetActive(_index < 3);
            m_RankTxt.SetActive(_index >= 3);
            if (_index < 3)
            {
                m_RankImg.SetSprite(_index == 0 ? "Rank_First" : _index == 1 ? "Rank_Second" : "Rank_Third");
            }
            else
            {
                m_RankTxt.text = (_index + 1).ToString();
            }
        }
 
        private bool SelfFairy(PlayerFairyData.FairyData _fairy)
        {
            if (!PlayerDatas.Instance.fairyData.HasFairy)
            {
                return false;
            }
            return PlayerDatas.Instance.fairyData.fairy.FamilyID == _fairy.FamilyID;
        }
    }
}