少年修仙传客户端代码仓库
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
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Friday, October 27, 2017
//--------------------------------------------------------
 
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
using System.Text;
 
namespace Snxxz.UI
{
 
    public class AttributePromoteShowWin : Window
    {
        const int MAX_GROUP = 5;
 
        [SerializeField]
        float m_Interval;
 
        [SerializeField]
        AttributePromoteBehaviour[] m_PromoteBehaviours;
 
        [SerializeField]
        Transform[] m_ShowPoints;
 
        [SerializeField]
        Transform m_StartPoint;
        [SerializeField]
        Transform m_EndPoint;
 
        float nextShowTime = 0f;
        List<AttributePromote> attributePromoteList = new List<AttributePromote>();
 
        #region Built-in
        protected override void BindController()
        {
        }
 
        protected override void AddListeners()
        {
        }
 
        protected override void OnPreOpen()
        {
            for (int i = 0; i < m_PromoteBehaviours.Length; i++)
            {
                m_PromoteBehaviours[i].transform.localPosition = m_StartPoint.localPosition;
                m_PromoteBehaviours[i].gameObject.SetActive(false);
            }
 
            PlayerDatas.Instance.attributePromoteEvent += OnAttributePromote;
        }
 
        protected override void OnAfterOpen()
        {
        }
 
        protected override void OnPreClose()
        {
            PlayerDatas.Instance.attributePromoteEvent -= OnAttributePromote;
        }
 
        protected override void OnAfterClose()
        {
 
        }
 
        protected override void LateUpdate()
        {
            base.LateUpdate();
 
            if (nextShowTime < Time.time && attributePromoteList.Count > 0)
            {
 
                var buffMin = new AttributePromote();
                var findMin = false;
                for (int i = attributePromoteList.Count - 1; i >= 0; i--)
                {
                    if (attributePromoteList[i].type == PlayerDataType.MINATK)
                    {
                        buffMin = attributePromoteList[i];
                        findMin = true;
                        break;
                    }
                }
 
                var buffMax = new AttributePromote();
                var findMax = false;
                if (findMin)
                {
                    for (int i = attributePromoteList.Count - 1; i >= 0; i--)
                    {
                        if (attributePromoteList[i].type == PlayerDataType.MAXATK)
                        {
                            buffMax = attributePromoteList[i];
                            findMax = true;
                            break;
                        }
                    }
                }
 
                for (int i = attributePromoteList.Count - 1; i >= 0; i--)
                {
                    if (attributePromoteList[i].type == PlayerDataType.MAXATK
                        || attributePromoteList[i].type == PlayerDataType.MINATK)
                    {
                        attributePromoteList.RemoveAt(i);
                    }
                }
 
                if (findMax && findMin)
                {
                    attributePromoteList.Add(new AttributePromote(PlayerDataType.MAXATK, buffMin.value1, buffMax.value1));
                }
 
                for (int i = 0; i < attributePromoteList.Count && i < MAX_GROUP; i++)
                {
                    var from = m_ShowPoints[i].localPosition;
                    var to = m_EndPoint.localPosition;
                    m_PromoteBehaviours[i].transform.localPosition = m_StartPoint.localPosition;
                    m_PromoteBehaviours[i].gameObject.SetActive(true);
                    m_PromoteBehaviours[i].Display(attributePromoteList[i].ToString(), from, to, 0.35f * i, OnPromoteShowEnd);
                }
 
                attributePromoteList.Clear();
                nextShowTime = Time.time + m_Interval;
            }
        }
 
        #endregion
 
        private void OnPromoteShowEnd(Transform _transform)
        {
            _transform.localPosition = m_StartPoint.localPosition;
            _transform.gameObject.SetActive(false);
        }
 
        private void OnAttributePromote(PlayerDataType _type, int _value)
        {
            attributePromoteList.Add(new AttributePromote(_type, _value));
        }
 
        struct AttributePromote
        {
            public PlayerDataType type;
            public int value1;
            public int value2;
 
            public AttributePromote(PlayerDataType _type, int _value)
            {
                this.type = _type;
                this.value1 = _value;
                this.value2 = 0;
            }
 
            public AttributePromote(PlayerDataType _type, int _value1, int _value2)
            {
                this.type = _type;
                this.value1 = _value1;
                this.value2 = _value2;
            }
 
            string ConvertToArtFont(string _key, int _num)
            {
                var config = DamageNumConfig.Get(_key);
                var stringBuild = new StringBuilder();
                stringBuild.Append((char)config.plus);
                stringBuild.Append((char)config.prefix);
 
                var chars = _num.ToString();
                for (var i = 0; i < chars.Length; i++)
                {
                    var numChar = config.nums[(int)chars[i] - 48];
                    if (numChar > 0)
                    {
                        stringBuild.Append((char)numChar);
                    }
                }
 
                return stringBuild.ToString();
            }
 
            string ConvertToArtFont(string _key, float _num)
            {
                var config = DamageNumConfig.Get(_key);
                var stringBuild = new StringBuilder();
                stringBuild.Append((char)config.plus);
                stringBuild.Append((char)config.prefix);
 
                var chars = _num.ToString("f1");
                for (var i = 0; i < chars.Length; i++)
                {
                    int numChar = 0;
                    if (chars[i] == '.')
                    {
                        numChar = config.nums[10];
                    }
                    else
                    {
                        numChar = config.nums[(int)chars[i] - 48];
                    }
 
                    if (numChar > 0)
                    {
                        stringBuild.Append((char)numChar);
                    }
                }
 
                return stringBuild.ToString();
            }
 
 
            string ConvertToArtFont(string _key, int _num1, int _num2)
            {
                var config = DamageNumConfig.Get(_key);
                var stringBuild = new StringBuilder();
                stringBuild.Append((char)config.plus);
                stringBuild.Append((char)config.prefix);
 
                var chars = _num1.ToString();
                for (var i = 0; i < chars.Length; i++)
                {
                    var numChar = config.nums[(int)chars[i] - 48];
                    if (numChar > 0)
                    {
                        stringBuild.Append((char)numChar);
                    }
                }
 
                stringBuild.Append((char)config.minus);
 
                chars = _num2.ToString();
                for (var i = 0; i < chars.Length; i++)
                {
                    var numChar = config.nums[(int)chars[i] - 48];
                    if (numChar > 0)
                    {
                        stringBuild.Append((char)numChar);
                    }
                }
 
                return stringBuild.ToString();
            }
 
            public override string ToString()
            {
                switch (type)
                {
                    case PlayerDataType.MaxHP:
                        return ConvertToArtFont("BuffAddMaxHp", value1);
                    case PlayerDataType.MAXATK:
                    case PlayerDataType.MINATK:
                        return ConvertToArtFont("BuffAddAttack", value1, value2);
                    case PlayerDataType.DEF:
                        return ConvertToArtFont("BuffAddDefense", value1);
                    case PlayerDataType.HIT:
                        return ConvertToArtFont("BuffAddAccurate", value1 );
                    case PlayerDataType.Miss:
                        return ConvertToArtFont("BuffAddDodge", value1);
                    case PlayerDataType.BattleValEx1:
                        return ConvertToArtFont("BuffAddAttackSpeed", value1 * 0.01f);
                    case PlayerDataType.Speed:
                        return ConvertToArtFont("BuffAddMoveSpeed", value1);
                    default:
                        return "";
                }
            }
 
        }
 
    }
 
}