少年修仙传客户端代码仓库
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Thursday, May 30, 2019
//--------------------------------------------------------
 
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
namespace vnxbqy.UI
{
 
    public class ReikiQualityInfomationWin : Window
    {
        [SerializeField] ScrollerController m_ScrollerControl;
        [SerializeField] Image m_ReikiIcon;
        [SerializeField] Text[] m_PropertyNames;
        [SerializeField] ReikiRootButton[] m_ReikiRootButtons;
        [SerializeField] Button m_Close;
 
        int m_SelectReiki = 0;
        int selectReiki
        {
            get { return m_SelectReiki; }
            set
            {
                if (m_SelectReiki != value)
                {
                    m_SelectReiki = value;
                    Display();
                }
            }
        }
 
 
        ReikiRootModel model { get { return ModelCenter.Instance.GetModel<ReikiRootModel>(); } }
        #region Built-in
        protected override void BindController()
        {
        }
 
        protected override void AddListeners()
        {
            m_Close.AddListener(CloseClick);
            m_ScrollerControl.OnRefreshCell += OnRefreshCell;
            for (int i = 0; i < m_ReikiRootButtons.Length; i++)
            {
                var index = i;
                m_ReikiRootButtons[i].button.SetListener(() =>
                {
                    OnSelectReiki(index);
                });
            }
        }
 
        protected override void OnPreOpen()
        {
            var list = new List<int>(model.reikiRoots);
            list.Sort((x, y) =>
            {
                var lhs_quality = model.GetReikiRootQuality(x);
                var rhs_quality = model.GetReikiRootQuality(y);
                if (lhs_quality != rhs_quality)
                {
                    return -lhs_quality.CompareTo(rhs_quality);
                }
                return x.CompareTo(y);
            });
 
            m_SelectReiki = list[0];
        }
 
        protected override void OnActived()
        {
            base.OnActived();
            Display();
        }
 
        protected override void OnAfterOpen()
        {
        }
 
        protected override void OnPreClose()
        {
        }
 
        protected override void OnAfterClose()
        {
        }
        #endregion
 
        void Display()
        {
            DisplayBase();
            DisplaySelect();
            DisplayQualitys();
        }
 
        void DisplayBase()
        {
            m_ReikiIcon.SetSprite("XT_LG_" + selectReiki);
            var job = PlayerDatas.Instance.baseData.Job;
            var totalPropertys = model.qualityPropertySorts[job];
            for (int i = 0; i < m_PropertyNames.Length; i++)
            {
                m_PropertyNames[i].SetActive(i < totalPropertys.Count);
                if (i < totalPropertys.Count)
                {
                    var config = PlayerPropertyConfig.Get(totalPropertys[i]);
                    m_PropertyNames[i].text = config.Name;
                }
            }
        }
 
        void DisplayQualitys()
        {
            var max = model.GetMaxReikiRootQuality(selectReiki);
            m_ScrollerControl.Refresh();
            var index = 0;
            for (int i = 1; i <= max; i++)
            {
                m_ScrollerControl.AddCell(ScrollerDataType.Header, i);
                if (i == model.GetReikiRootQuality(selectReiki))
                {
                    index = i - 1;
                }
            }
            m_ScrollerControl.Restart();
 
            m_ScrollerControl.JumpIndex(index);
        }
 
        void DisplaySelect()
        {
            for (int i = 0; i < m_ReikiRootButtons.Length; i++)
            {
                m_ReikiRootButtons[i].select.SetActive(i == model.reikiRoots.IndexOf(selectReiki));
                var imageEx = m_ReikiRootButtons[i].button.image as ImageEx;
                imageEx.gray = i != model.reikiRoots.IndexOf(selectReiki);
            }
        }
 
        private void OnSelectReiki(int index)
        {
            selectReiki = model.reikiRoots[index];
        }
 
        private void OnRefreshCell(ScrollerDataType type, CellView cell)
        {
            var qualityCell = cell as ReikiQualityCell;
            qualityCell.Display(selectReiki, cell.index);
        }
 
        [Serializable]
        public class ReikiRootButton
        {
            public Button button;
            public Transform select;
        }
    }
 
}