少年修仙传客户端代码仓库
client_Wu Xijin
2019-06-13 033958214c0b16d7e7b93cc821b018c295251867
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
//--------------------------------------------------------
//    [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] Image m_SkillIcon;
        [SerializeField] Text m_SkillName;
        [SerializeField] Image m_ReikiIcon;
        [SerializeField] Text m_ReikiPoint;
        [SerializeField] ExpertSkillCyclicScroll m_CyclicScroll;
        [SerializeField] Button m_Active;
        [SerializeField] Text m_ActiveLabel;
        [SerializeField] UIEffect m_ActiveEffect;
        [SerializeField] Button m_Close2;
 
        public static int skillId = 0;
 
        int m_CacheExpertLevel = 0;
 
        List<int> datas = new List<int>();
 
        Coroutine m_CacheCoroutine;
 
        TreasureSkillModel model { get { return ModelCenter.Instance.GetModel<TreasureSkillModel>(); } }
        ReikiRootModel reikiRootModel { get { return ModelCenter.Instance.GetModel<ReikiRootModel>(); } }
        #region Built-in
        protected override void BindController()
        {
        }
 
        protected override void AddListeners()
        {
            m_Close2.AddListener(CloseClick);
            m_Active.AddListener(OnActiveSkill);
        }
 
        protected override void OnPreOpen()
        {
            model.expertActiveRefresh += ExpertActiveRefresh;
        }
 
        protected override void OnActived()
        {
            base.OnActived();
            Display();
        }
 
        protected override void OnAfterOpen()
        {
 
        }
 
        protected override void OnPreClose()
        {
            m_CyclicScroll.Dispose();
 
            StopAllCoroutines();
 
            m_CacheCoroutine = null;
 
            model.expertActiveRefresh -= ExpertActiveRefresh;
        }
 
        protected override void OnAfterClose()
        {
        }
 
        void Display()
        {
            DisplayDetail();
        }
 
        void DisplayDetail()
        {
            if (m_CacheCoroutine != null)
            {
                StopCoroutine(m_CacheCoroutine);
                m_CacheCoroutine = null;
            }
 
            m_CacheExpertLevel = 0;
            model.TryGetExpertActiveLevel(skillId, out m_CacheExpertLevel);
 
            DisplayButtonState();
 
            var skillConfig = SkillConfig.Get(skillId);
 
            m_SkillIcon.SetSprite(skillConfig.IconName);
            m_SkillName.text = skillConfig.SkillName;
 
            var property = skillConfig.RequireProperty();
            var propertyConfig = PlayerPropertyConfig.Get(property);
            m_ReikiIcon.SetSprite("XT_LG_" + property);
 
            var propertyValueLabel = UIHelper.AppendColor(TextColType.Green, UIHelper.GetPropertyValue((PropertyType)property).ToString());
            m_ReikiPoint.text = string.Format("我的{0}:{1}",
                propertyConfig.Name, propertyValueLabel);
 
            datas.Clear();
 
            for (int i = 1; i <= skillConfig.SkillMaxLV; i++)
            {
                datas.Add(skillId * 100 + i);
            }
 
            m_CyclicScroll.Dispose();
            m_CyclicScroll.Display(skillId, skillConfig.SkillMaxLV);
 
            if (m_CacheExpertLevel >= 2)
            {
                m_CacheCoroutine = StartCoroutine(Co_MoveToCenter2(m_CacheExpertLevel));
            }
        }
 
        void DisplayButtonState()
        {
            TreasurePotential expert;
            if (model.TryGetPotential(skillId, out expert))
            {
                var error = 0;
                var satisfyActive = model.SatisfyActiveExpert(skillId, out error);
 
                m_Active.gameObject.SetActive(satisfyActive || error == 3);
 
                if (satisfyActive || error == 3)
                {
                    if (satisfyActive && !m_ActiveEffect.IsPlaying)
                    {
                        m_ActiveEffect.Play();
                    }
                    else if (!satisfyActive && m_ActiveEffect.IsPlaying)
                    {
                        m_ActiveEffect.StopImediatly();
                    }
                }
            }
        }
 
        private void OnActiveSkill()
        {
            var error = 0;
            var satisfyActive = model.SatisfyActiveExpert(skillId, out error);
            if (!satisfyActive)
            {
                ExpertSkillActiveRemindWin.skillId = skillId;
                WindowCenter.Instance.Open<ExpertSkillActiveRemindWin>();
                return;
            }
            var pak = new CA516_tagCMSelectSkillElement();
            pak.SkillTypeID = (uint)skillId;
            pak.DoType = 0;
            GameNetSystem.Instance.SendInfo(pak);
        }
 
        private void ExpertActiveRefresh(int id)
        {
            if (skillId == id)
            {
                var level = 0;
                if (model.TryGetExpertActiveLevel(id, out level))
                {
                    if (level > m_CacheExpertLevel && level >= 2)
                    {
                        if (m_CacheCoroutine != null)
                        {
                            StopCoroutine(m_CacheCoroutine);
                            m_CacheCoroutine = null;
                        }
                        m_CacheCoroutine = StartCoroutine(Co_MoveToCenter1(level));
                    }
                }
 
                DisplayButtonState();
            }
        }
 
        IEnumerator Co_MoveToCenter2(int level)
        {
            yield return null;
            m_CyclicScroll.MoveToCenter(level);
        }
 
        IEnumerator Co_MoveToCenter1(int level)
        {
            yield return WaitingForSecondConst.WaitMS500;
            m_CyclicScroll.MoveToCenter(level);
        }
        #endregion
    }
 
}