少年修仙传客户端代码仓库
client_Wu Xijin
2019-04-08 aa62264ce70008889d090d7402298e7850350708
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 Snxxz.UI;
using System.Collections;
using System.Collections.Generic;
 
using UnityEngine;
using UnityEngine.UI;
namespace EnhancedUI.EnhancedScroller
{
    public class FairyViewCell : ScrollerUI
    {
        [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 fakeFairy = false;
            if (index >= FairyModel.FakeFairyStartIndex)
            {
                index = index - FairyModel.FakeFairyStartIndex;
                fakeFairy = true;
            }
            if (!fakeFairy && index >= model.fairyList.Count)
            {
                return;
            }
            PlayerFairyData.FairyData fairy = null;
            if (!fakeFairy)
            {
                fairy = model.fairyList[index];
            }
            DisplayRank(fakeFairy ? (index + model.fairyList.Count) : index);
            var _fakeId = fakeFairy ? model.fakeFairyIds[index] : 0;
            m_FairyNameTxt.text = fakeFairy ? model.fakeFairyNames[_fakeId - 1] : fairy.FamilyName;
            m_FairyNameTxt.color = fakeFairy || !SelfFairy(fairy) ? UIHelper.GetUIColor(TextColType.NavyBrown) : UIHelper.GetUIColor(TextColType.Green, true);
            m_FairyLeaderNameTxt.text = fakeFairy ? string.Empty : fairy.leaderName;
            m_RealmImg.gameObject.SetActive(!fakeFairy && fairy.OfficialRank > 0);
            if (!fakeFairy && fairy.OfficialRank > 0)
            {
                RealmConfig presentCfg = RealmConfig.Get(fairy.OfficialRank);
                if (presentCfg != null)
                {
                    m_RealmImg.SetSprite(presentCfg.Img);
                    m_RealmImg.SetNativeSize();
                }
            }
            m_FairyLvTxt.text = fakeFairy ? "1" : fairy.FamilyLV.ToString();
            FamilyConfig cfg = FamilyConfig.Get(fakeFairy ? 1 : fairy.FamilyLV);
            if (cfg != null)
            {
                m_FairyMemberCntTxt.text = StringUtility.Contact(fakeFairy ? 0 : fairy.MemberCount, "/", cfg.memberCnt);
            }
 
            if (fakeFairy)
            {
                m_FairyGradeTxt.text = string.Empty;
            }
            else
            {
                if (fairy.WarRank != 0)
                {
                    m_FairyGradeTxt.text = GetGrade((int)fairy.WarRank);
                }
                else
                {
                    m_FairyGradeTxt.text = UIHelper.ReplaceLargeNum(fairy.totalFightPower);
                }
            }
 
            m_SelectImg.SetSprite(model.presentFairy == (fakeFairy ? index + FairyModel.FakeFairyStartIndex : index) ? "RankList_ChoosenBottom" :
                (fakeFairy ? index + model.fairyList.Count : index) % 2 == 0 ? "RankList_SingleBottom" : "RankList_QuanTouMing");
            if (PlayerDatas.Instance.fairyData.IsSearching)
            {
                return;
            }
            if (!fakeFairy && 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.gameObject.SetActive(_index < 3);
            m_RankTxt.gameObject.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();
            }
        }
 
        public string GetGrade(int _rank)
        {
            _rank = Mathf.CeilToInt((float)_rank / 4);
            switch (_rank)
            {
                case 1:
                    return Language.Get("Fairy_S");
                case 2:
                    return Language.Get("Fairy_A");
                case 3:
                    return Language.Get("Fairy_B");
                case 4:
                    return Language.Get("Fairy_C");
                default:
                    return Language.Get("Fairy_D");
            }
        }
 
        private bool SelfFairy(PlayerFairyData.FairyData _fairy)
        {
            if (!PlayerDatas.Instance.fairyData.HasFairy)
            {
                return false;
            }
            return PlayerDatas.Instance.fairyData.fairy.FamilyID == _fairy.FamilyID;
        }
    }
}