少年修仙传客户端代码仓库
hch
2025-06-12 204ef05a831c9484e2abc561d27ecbff7c797453
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
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
using System.Text;
 
namespace vnxbqy.UI
{
    [DisallowMultipleComponent]
    public class PopUpNum : MonoBehaviour
    {
 
        [SerializeField] Text m_Text;
        [SerializeField] TweenCurve m_AlphaCurve;
        [SerializeField] Animation m_Animation;
        new public Animation animation { get { return m_Animation; } }
        [SerializeField] FollowTargetIgnoreY m_FollowTarget;
        [SerializeField] ScreenDiffuseMove m_DiffuseMove;
 
        Pattern m_Pattern = Pattern.EnemyAttack;
        public Pattern pattern {
            get { return m_Pattern; }
            set { m_Pattern = value; }
        }
 
        float hideTime = 0f;
        float startTimeStep2 = 0f;
        float durationStep1 = 0f;
        float durationStep2 = 0f;
 
        static StringBuilder stringBuild = new StringBuilder();
        static int popupQueueMax = 20;
        static Queue<PopupInfo> m_PopupInfoQueue = new Queue<PopupInfo>();
        public static Queue<PopupInfo> popupInfoQueue {
            get { return m_PopupInfoQueue; }
        }
 
        public static void RecordPopup(PopupInfo _popupInfo)
        {
            if (_popupInfo.isPlayer)
            {
                while (popupInfoQueue.Count >= popupQueueMax)
                {
                    popupInfoQueue.Dequeue();
                }
 
                popupInfoQueue.Enqueue(
                    new PopupInfo()
                    {
                        pattern = _popupInfo.pattern,
                        num = _popupInfo.num,
                        camera = _popupInfo.camera,
                        target = _popupInfo.target,
                        direction = _popupInfo.direction,
                        isPlayer = _popupInfo.isPlayer,
                        realmSuppress = _popupInfo.realmSuppress,
                    }
                    );
            }
            else
            {
                Popup(_popupInfo);
            }
        }
 
        public static void Popup(PopupInfo _popupInfo)
        {
            var groups = WindowCenter.Instance.uiRoot.fightCanvasGroup.damageNumGroups;
            if (groups == null || groups.Length == 0)
            {
                return;
            }
 
            if (_popupInfo.target==null || _popupInfo.camera==null)
            {
                return;
            }
 
            var popupNum = PopUpNumPool.Require(_popupInfo.pattern);
            if (popupNum == null)
            {
                return;
            }
 
            var uiPosition = CameraUtility.ConvertToUIPosition(_popupInfo.camera, _popupInfo.target.position);
            var targetGroup = groups[groups.Length - 1];
            for (int i = 0; i < groups.Length; i++)
            {
                var group = groups[i];
                if (group.childCount < 20)
                {
                    targetGroup = group;
                    break;
                }
            }
 
            popupNum.transform.SetParent(targetGroup);
            popupNum.transform.position = uiPosition;
            popupNum.transform.localPosition = popupNum.transform.localPosition.SetZ(0);
            popupNum.transform.localScale = Vector3.one;
            popupNum.PopUp(_popupInfo);
        }
 
        public void PopUp(PopupInfo _popupInfo)
        {
            stringBuild.Remove(0, stringBuild.Length);
 
            if (_popupInfo.realmSuppress)
            {
                var realmSuppressKey = GetRealmSuppressKey(_popupInfo.pattern);
                if (realmSuppressKey > 0)
                {
                    stringBuild.Append((char)realmSuppressKey);
                }
            }
 
            var prefixKey = GetPrefiexKey(_popupInfo.pattern);
            if (prefixKey > 0)
            {
                stringBuild.Append((char)prefixKey);
            }
 
            var symbolKey = GetSymbolKey(_popupInfo.pattern);
            if (symbolKey > 0)
            {
                stringBuild.Append((char)symbolKey);
            }
 
            switch (_popupInfo.pattern)
            {
                case Pattern.PlayerMiss:
                case Pattern.PetMiss:
                case Pattern.EnemyMiss:
                case Pattern.PlayerImmune:
                case Pattern.PetImmune:
                case Pattern.EnemyImmune:
                case Pattern.EnemyZhanSha:
                case Pattern.PetZhanSha:
                case Pattern.PlayerZhanSha:
                    break;
                default:
                    var chars = UIHelper.ReplaceLargeArtNum(_popupInfo.num);
                    for (var i = 0; i < chars.Length; i++)
                    {
                        var numChar = GetNumKey(_popupInfo.pattern, chars[i]);
                        if (numChar > 0)
                        {
                            stringBuild.Append((char)numChar);
                        }
                    }
                    break;
            }
 
            m_Text.text = stringBuild.ToString();
            m_Text.color = m_Text.color.SetA(1f);
            this.SetActive(true);
 
            if (m_FollowTarget != null)
            {
                if (m_DiffuseMove != null)
                {
                    switch (m_DiffuseMove.moveType)
                    {
                        case ScreenDiffuseMove.DiffuseType.RelativePosition:
                        case ScreenDiffuseMove.DiffuseType.ReversalRelativePosition:
                            m_FollowTarget.enabled = false;
                            break;
                        default:
                            m_FollowTarget.Follow(_popupInfo.target, _popupInfo.camera);
                            m_FollowTarget.enabled = true;
                            break;
                    }
                }
                else
                {
                    m_FollowTarget.Follow(_popupInfo.target, _popupInfo.camera);
                    m_FollowTarget.enabled = true;
                }
            }
 
            if (animation != null)
            {
                animation.enabled = true;
                animation.Play();
                var clip = animation.clip;
                if (clip != null)
                {
                    durationStep1 = clip.length;
                }
            }
            else
            {
                durationStep1 = 0f;
            }
 
            if (m_DiffuseMove != null)
            {
                m_DiffuseMove.delay = 0f;
                durationStep2 = m_DiffuseMove.duration;
                m_DiffuseMove.Begin(_popupInfo.direction, true);
                m_DiffuseMove.transform.localPosition = Vector3.zero;
            }
 
            durationStep1 = 0f;
            startTimeStep2 = Time.time + durationStep1;
            hideTime = Time.time + durationStep1 + durationStep2;
 
            PopUpNumPool.recycleAllEvent -= OnReycleAll;
            PopUpNumPool.recycleAllEvent += OnReycleAll;
        }
 
        public void SetEnable(bool _enable)
        {
            m_Animation.enabled = _enable;
            m_FollowTarget.enabled = _enable;
            m_DiffuseMove.enabled = _enable;
            this.enabled = _enable;
        }
 
        int GetRealmSuppressKey(Pattern _pattern)
        {
            var config = DamageNumConfig.Get(_pattern.ToString());
            return config.realm;
        }
 
        int GetPrefiexKey(Pattern _pattern)
        {
            var config = DamageNumConfig.Get(_pattern.ToString());
            return config.prefix;
        }
 
        int GetSymbolKey(Pattern _pattern)
        {
            var config = DamageNumConfig.Get(_pattern.ToString());
            switch (_pattern)
            {
                case Pattern.EnemyRecovery:
                case Pattern.PlayerRecovery:
                case Pattern.PetRecovery:
                case Pattern.BuffAddDefense:
                case Pattern.BuffAddAttack:
                case Pattern.BuffAddAttackSpeed:
                case Pattern.BuffAddAccurate:
                case Pattern.BuffAddDodge:
                case Pattern.BuffAddMaxHp:
                case Pattern.BuffAddMoveSpeed:
                    return config.plus;
                default:
                    return config.minus;
            }
        }
 
        int GetNumKey(Pattern _pattern, int _num)
        {
            var key = string.Empty;
            var config = DamageNumConfig.Get(_pattern.ToString());
 
            //.的ASCII码是46
            if (_num == 46)
            {
                return config.nums[10];
            }
            //k的ASCII码是107
            else if (_num == 107)
            {
                return config.nums[11];
            }
            //m的ASCII码是109
            else if (_num == 109)
            {
                return config.nums[12];
            }
            //b的ASCII码是98
            else if (_num == 98)
            {
                return config.nums[13];
            }
            //t的ASCII码是116
            else if (_num == 116)
            {
                return config.nums[14];
            }
            return config.nums[_num - 48];
        }
 
        void LateUpdate()
        {
            if (Time.time > hideTime)
            {
                PopUpNumPool.Recycle(this);
            }
            else if (Time.time > startTimeStep2)
            {
                if (m_AlphaCurve != null)
                {
                    var t = (Time.time - startTimeStep2) / durationStep2 * m_AlphaCurve.totalTime;
                    m_Text.color = m_Text.color.SetA(1 - m_AlphaCurve.Evaluate(t));
                }
            }
        }
 
        private void OnReycleAll()
        {
            PopUpNumPool.recycleAllEvent -= OnReycleAll;
            PopUpNumPool.Recycle(this);
        }
 
        public enum Pattern
        {
            PlayerAttack = 1,                 //玩家攻击,受击对象为敌对怪物或玩家
            PetAttack = 2,                       //宠物攻击,受击对象为敌对怪物或玩家
            EnemyAttack = 3,                 //敌对怪物或玩家攻击,受击对象为玩家及友方单位
 
            PlayerRecovery = 4,               //玩家回复
            PetRecovery = 5,                   //宠物回复
            EnemyRecovery = 6,              //敌人回复
 
            PlayerTurnTheBlade = 7,        //玩家反弹,受击对象为敌对怪物或玩家
            PetTurnTheBlade = 8,             //宠物反弹,受击对象为敌对怪物或玩家
            EnemyTurnTheBlade = 9,       //敌人反弹,受击对象为玩家及友方单位
 
            PlayerBleed = 10,                    //玩家流血
            PetBleed = 11,                          //宠物流血
            EnemyBleed = 12,                    //敌人流血
 
            PlayerParry = 13,                     //玩家格挡
            PetParry = 14,                         //宠物格挡
            EnemyParry = 15,                    //敌人格挡
 
            PlayerDoubleHit = 16,             //玩家连击
            PetDoubleHit = 17,                  //宠物连击                          
            EnemyDoubleHit = 18,             //敌人连击             
 
            PlayerCrit = 19,                         //玩家暴击             
            PetCrit = 20,                             //宠物暴击               
            EnemyCrit = 21,                        //敌人暴击
 
            PlayerHuiXin = 22,                    //玩家会心一击
            PetHuiXin = 23,                        //宠物会心一击                          
            EnemyHuiXin = 24,                   //敌人会心一击
 
            PlayerMiss = 25,                    //玩家Miss
            PetMiss = 26,                        //宠物Miss                      
            EnemyMiss = 27,                   //敌人Miss
 
            PlayerImmune = 28,                    //玩家免疫
            PetImmune = 29,                        //宠物免疫                      
            EnemyImmune = 30,                   //敌人免疫
 
            PlayerZhanSha = 34,                    //玩家斩杀
            PetZhanSha = 35,                        //宠物斩杀                      
            EnemyZhanSha = 36,                   //敌人斩杀
 
            PlayerZhuXian = 37,                    //玩家诛仙
            PetZhuXian = 38,                        //宠物诛仙                      
            EnemyZhuXian = 39,                   //敌人诛仙
 
            PlayerDeadlyHit = 43,                    //玩家致死一击
            PetDeadlyHit = 44,                        //宠物致死一击                      
            EnemyDeadlyHit = 45,                   //敌人致死一击
 
            PlayerThumpHit = 46,                    //玩家重击
            PetThumpHit = 47,                        //宠物重击                      
            EnemyThumpHit = 48,                   //敌人重击
 
            PlayerYinji = 49,                    //玩家印记
            PetYinji = 50,                        //宠物印记                      
            EnemyYinji = 51,                   //敌人印记
 
            PlayerBurning = 52,                    //玩家灼烧
            PetBurning = 53,                        //宠物灼烧                      
            EnemyBurning = 54,                   //敌人灼烧
 
            BuffAddDefense = 101,//+防御buff
            BuffAddAttack = 102,//+攻击buff
            BuffAddAttackSpeed = 103,//+攻速buff
            BuffAddAccurate = 104,//+命中buff
            BuffAddDodge = 105,//+闪避Buff
            BuffAddMaxHp = 106,//+血量上限buff
            BuffAddMoveSpeed = 107,//+移动速度buff
 
            BuffReduceDefense = 201,//-防御buff
            BuffReduceAttack = 202,//-攻击buff
            BuffReduceAttackSpeed = 203,//-攻速buff
            BuffReduceAccurate = 204,//-命中buff
            BuffReduceDodge = 205,//-闪避Buff
            BuffReduceMaxHp = 206,//-血量上限buff
            BuffReduceMoveSpeed = 207,//-移动速度buff
 
        }
 
        public enum AttackObject
        {
            Player,
            Pet,
            Enemy,
        }
 
        public struct PopupInfo
        {
            public Pattern pattern;
            public ulong num;
            public Camera camera;
            public Transform target;
            public Vector3 direction;
            public bool realmSuppress;
            public bool isPlayer;
        }
 
 
 
    }
 
}