少年修仙传客户端代码仓库
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Friday, April 26, 2019
//--------------------------------------------------------
 
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
namespace Snxxz.UI
{
 
    public class ExpertSkillSelectWin : Window
    {
        [SerializeField] PositionTween m_PositionTween;
        [SerializeField] SkillExpertWidget[] m_SkillExperts;
        [SerializeField] UIAlphaTween m_AlphaTween;
        [SerializeField] Image m_SkillIcon;
        [SerializeField] Text m_SkillName;
        [SerializeField] Text m_Reiki;
        [SerializeField] Text m_ReikiPoint;
        [SerializeField] ExpertSkillCyclicScroll m_CyclicScroll;
        [SerializeField] LayoutElement m_LayoutElement;
        [SerializeField] Button m_Active;
        [SerializeField] Button m_Select;
        [SerializeField] Button m_Close1;
        [SerializeField] Button m_Close2;
 
        public static int selectSkillId = 0;
 
        bool m_OpenDetail = false;
 
        int m_SelectExpert = 0;
        int selectExpert
        {
            get { return m_SelectExpert; }
            set
            {
                if (m_SelectExpert != value)
                {
                    if (!m_OpenDetail)
                    {
                        m_OpenDetail = true;
                        DisplayAnimation();
                    }
                    m_SelectExpert = value;
                    DisplaySelect();
                    DisplayDetail();
                }
            }
        }
 
        int selectActiveLevel = 0;
 
        List<int> datas = new List<int>();
 
        TreasureSkillModel model { get { return ModelCenter.Instance.GetModel<TreasureSkillModel>(); } }
        #region Built-in
        protected override void BindController()
        {
        }
 
        protected override void AddListeners()
        {
            //m_Controller.OnRefreshCell += OnRefreshCell;
            m_Select.AddListener(OnSelect);
            m_Close1.AddListener(CloseClick);
            m_Close2.AddListener(CloseClick);
            m_Active.AddListener(OnActiveSkill);
        }
 
        protected override void OnPreOpen()
        {
            m_PositionTween.SetStartState();
            m_AlphaTween.SetStartState();
 
            m_OpenDetail = false;
 
            m_CyclicScroll.enabled = false;
 
            Display();
 
            model.expertActiveRefresh += ExpertActiveRefresh;
        }
 
        protected override void OnAfterOpen()
        {
        }
 
        protected override void OnPreClose()
        {
            m_CyclicScroll.Dispose();
 
            StopAllCoroutines();
 
            model.expertActiveRefresh -= ExpertActiveRefresh;
        }
 
        protected override void OnAfterClose()
        {
        }
 
        void Display()
        {
            SetDefaultSelect();
 
            DisplayExperts();
            DisplaySelect();
            DisplayDetail();
        }
 
        void SetDefaultSelect()
        {
            m_SelectExpert = 0;
        }
 
        void DisplayExperts()
        {
            TreasureSkill skill;
            if (model.TryGetSkill(selectSkillId, out skill))
            {
                for (int i = 0; i < m_SkillExperts.Length; i++)
                {
                    var potential = skill.potentials[i];
                    m_SkillExperts[i].Display(potential.id, PlayerDatas.Instance.baseData.LV >= potential.limitLevel, OnSelect);
                }
            }
        }
 
        void DisplaySelect()
        {
            for (int i = 0; i < m_SkillExperts.Length; i++)
            {
                m_SkillExperts[i].SetSelect(selectExpert == m_SkillExperts[i].skillId);
            }
        }
 
        void DisplayDetail()
        {
            if (selectExpert != 0)
            {
                selectActiveLevel = 0;
                model.TryGetExpertActiveLevel(selectExpert, out selectActiveLevel);
 
                DisplayButtonState();
 
                var skillConfig = SkillConfig.Get(selectExpert);
 
                m_SkillIcon.SetSprite(skillConfig.IconName);
                m_SkillName.text = skillConfig.SkillName;
 
                var property = skillConfig.RequireProperty();
                var propertyConfig = PlayerPropertyConfig.Get(property);
                m_Reiki.text = propertyConfig.Name;
                m_Reiki.color = UIHelper.GetPropertyColor(property);
 
                m_ReikiPoint.text = string.Format("我的{0}灵根:{1}",
                    propertyConfig.Name, UIHelper.GetPropertyValue((PropertyType)property));
 
                datas.Clear();
                for (int i = 1; i <= skillConfig.SkillMaxLV; i++)
                {
                    if (i >= selectActiveLevel)
                    {
                        datas.Add(selectExpert * 100 + i);
                    }
                }
 
                //m_LayoutElement.preferredHeight = datas.Count > 2 ? 440 : 302;
 
                m_CyclicScroll.enabled = true;
 
                m_CyclicScroll.Dispose();
                m_CyclicScroll.Init(datas);
                StartCoroutine(Co_Arrange());
            }
        }
 
        IEnumerator Co_Arrange()
        {
            yield return null;
            m_CyclicScroll.ReArrange();
        }
 
        void DisplayButtonState()
        {
            TreasurePotential expert;
            if (model.TryGetPotential(selectExpert, out expert))
            {
                var satisfyActive = model.SatisfyActiveExpert(selectExpert);
                var activeLevel = 0;
                model.TryGetExpertActiveLevel(selectExpert, out activeLevel);
                m_Select.gameObject.SetActive(activeLevel > 0 && !satisfyActive);
                m_Active.gameObject.SetActive(satisfyActive);
            }
        }
 
        void DisplayAnimation()
        {
            m_PositionTween.Play();
            m_AlphaTween.Play();
        }
 
        private void OnSelect()
        {
            if (selectExpert != 0)
            {
                var pak = new CA516_tagCMSelectSkillElement();
                pak.SkillTypeID = (uint)selectExpert;
                GameNetSystem.Instance.SendInfo(pak);
            }
            CloseImmediately();
        }
 
        private void OnActiveSkill()
        {
            if (m_CyclicScroll.IsPlaying)
            {
                return;
            }
            var pak = new CA516_tagCMSelectSkillElement();
            pak.SkillTypeID = (uint)selectExpert;
            GameNetSystem.Instance.SendInfo(pak);
        }
 
        private void OnSelect(int skillId)
        {
            if (m_CyclicScroll.IsPlaying)
            {
                return;
            }
            selectExpert = skillId;
        }
 
        private void ExpertActiveRefresh(int id)
        {
            if (selectExpert == id)
            {
                var level = 0;
                if (model.TryGetExpertActiveLevel(selectExpert, out level))
                {
                    if (level > selectActiveLevel && level > 1)
                    {
                        m_CyclicScroll.DisplayAnimation(()=> 
                        {
                            DisplayDetail();
                        });
                    }
                }
                DisplayButtonState();
            }
        }
 
        #endregion
 
        [Serializable]
        public class SkillExpertWidget
        {
            [SerializeField] ImageEx m_Bottom;
            [SerializeField] ImageEx m_Icon;
            [SerializeField] Text m_SkillName;
            [SerializeField] ImageEx m_ReikiBottom;
            [SerializeField] Text m_Reiki;
            [SerializeField] Transform m_ContainerSelect;
            [SerializeField] Text m_Use;
            [SerializeField] Text m_Limit;
            [SerializeField] RedpointBehaviour m_Redpoint;
            [SerializeField] Button m_Select;
 
            public int skillId { get; private set; }
 
            TreasureSkillModel model { get { return ModelCenter.Instance.GetModel<TreasureSkillModel>(); } }
 
            public void Display(int skillId, bool unlock, Action<int> func)
            {
                this.skillId = skillId;
 
                var skillConfig = SkillConfig.Get(skillId);
 
                m_Icon.SetSprite(skillConfig.IconName);
                m_SkillName.text = skillConfig.SkillName;
 
                var property = skillConfig.RequireProperty();
                var propertyConfig = PlayerPropertyConfig.Get(property);
                m_Reiki.text = propertyConfig.Name;
                m_Reiki.color = unlock ? UIHelper.GetPropertyColor(property) : UIHelper.s_Gray;
 
                var selectExpertSkill = 0;
                model.TryGetExpertSkill(ExpertSkillSelectWin.selectSkillId, out selectExpertSkill);
                m_Use.gameObject.SetActive(selectExpertSkill == skillId);
 
                TreasurePotential expert;
                model.TryGetPotential(skillId, out expert);
 
                m_Limit.text = string.Format("{0}级可使用", expert.limitLevel);
 
                m_Limit.gameObject.SetActive(!unlock);
                m_Bottom.gray = !unlock;
                m_Icon.gray = !unlock;
                m_ReikiBottom.gray = !unlock;
 
                m_Redpoint.redpointId = expert.activeRedpoint.id;
 
                m_Select.SetListener(() =>
                {
                    if (func != null)
                    {
                        func(skillId);
                    }
                });
            }
 
            public void SetSelect(bool select)
            {
                m_ContainerSelect.gameObject.SetActive(select);
            }
        }
 
    }
 
}