yyl
2025-05-19 b118ece3db250a5a257b60713da92234d8d5a57a
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
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
using System;
using System.Text;
using UnityEngine;
using System.Linq;
using System.Xml.Linq;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
 
using System.Text.RegularExpressions;
using System.IO;
using LitJson;
 
/// <summary>
/// UI辅助类
/// </summary>
 
public static class UIHelper
{
 
    public static readonly string no_breaking_space = "\u00A0"; //Text文本框输入空格自动换行问题 替换编码
 
 
    //不需要提取翻译的文本
    private static readonly string[] numbers = new string[] { "零", "一", "二", "三", "四", "五", "六", "七", "八", "九" };
    private static readonly string[] units = new string[] { "十", "百", "千", "万" };
 
    //数字转中文(只做小数字),海外版本调用改函数切换版本请直接返回数字
    public static string ChineseNumber(int number)
    {
        if (number == 0)
            return numbers[0];
 
        string result = "";
        int unitPlace = 1; // 位数,1 表示十位,2 表示百位,3 表示千位,4 表示万位
        bool needZero = false; // 是否需要添加 '零'
 
        while (number > 0)
        {
            int part = number % 10;
            if (part != 0)
            {
                if (needZero)
                    result = StringUtility.Contact(numbers[0] + result);
 
                result = numbers[part] + (unitPlace == 1 ? "" : units[unitPlace - 2]) + result; // 单位只在十、百、千、万内部使用
                needZero = false;
            }
            else
            {
                needZero = true;
            }
 
            number /= 10;
            unitPlace++;
        }
        if (result.StartsWith("一十"))
        {
            result = result.Substring(1);
        }
        if (result.EndsWith("零"))
        {
            result = result.Replace("零", "");
        }
 
        return result;
    }
 
 
    #region UI通用
    public static void SetIconWithMoneyType(this Image _image, int moneyType)
    {
        if (_image == null) return;
        string iconKey = StringUtility.Contact("Money_Type_", moneyType);
        _image.SetSprite(iconKey);
    }
 
    public static void SetSmallIconWithMoneyType(this Image _image, int moneyType)
    {
        if (_image == null) return;
        string iconKey = StringUtility.Contact("SmallMoney", moneyType);
        _image.SetSprite(iconKey);
    }
 
    /// <summary>
    /// 分离字符串插入空格
    /// </summary>
    public static string GetSuitNameByName(string attrName)
    {
        string suitStr = "";
        for (int i = 0; i < attrName.Length; i++)
        {
            if (i != attrName.Length - 1)
            {
                if (attrName.Length == 2)
                {
                    suitStr = StringUtility.Contact(suitStr, attrName[i], "        ");
                }
                else if (attrName.Length == 3)
                {
                    suitStr = StringUtility.Contact(suitStr, attrName[i], "  ");
                }
                else
                {
                    suitStr = StringUtility.Contact(suitStr, attrName[i]);
                }
            }
            else
            {
                suitStr = StringUtility.Contact(suitStr, attrName[i]);
            }
        }
        return suitStr;
 
    }
 
    // 基于itemColor 下,ColorEx做二级区分
    public static void SetItemBackGround(this Image _image, int itemColor, int ColorEx = 0)
    {
        if (_image == null)
        {
            return;
        }
        _image.SetSprite(string.Format("Common_Public_ItemColor{0}{1}", itemColor, ColorEx));
    }
    /// <summary>
    /// 剩余时间
    /// </summary>
    /// <param name="startTime">格式 年-月-日 小时:分钟:秒</param>
    /// <param name="ownTime">毫秒</param>
    /// <returns></returns>
    private static Regex TimeRegex = new Regex(@"([0-9]+)-([0-9]+)-([0-9]+) ([0-9]+):([0-9]+):([0-9]+)", RegexOptions.Singleline);
    public static int GetSurplusSeconds(string startTime, int seconds)
    {
        string start = GetTime(startTime);
        if (start.Equals(string.Empty))
        {
            return 0;
        }
        DateTime s = Convert.ToDateTime(start);
        DateTime t = s.AddTicks(seconds * TimeSpan.TicksPerSecond);
        DateTime n = TimeUtility.ServerNow;
        TimeSpan span = t - n;
        return Mathf.Max(0, (int)span.TotalSeconds);
    }
 
    public static string GetTime(string startTime)
    {
        if (!TimeRegex.IsMatch(startTime))
        {
            return string.Empty;
        }
        Match match = TimeRegex.Match(startTime);
        int year = int.Parse(match.Groups[1].Value);
        int month = int.Parse(match.Groups[2].Value);
        int day = int.Parse(match.Groups[3].Value);
        int h = int.Parse(match.Groups[4].Value);
        int mi = int.Parse(match.Groups[5].Value);
        int sc = int.Parse(match.Groups[6].Value);
 
        return string.Format("{0}-{1}-{2} {3}:{4}:{5}", year, month, day, h, mi, sc);
 
    }
    /// <summary>
    /// 获取消逝的时间
    /// </summary>
    /// <param name="lastTime"></param>
    /// <returns></returns>
    public static string GetFadeTime(uint lastTime)
    {
        DateTime n = TimeUtility.ServerNow;
        TimeSpan span = n - TimeUtility.GetTime(lastTime);
        if (span.TotalDays > 1) return Math.Floor(span.TotalDays) + Language.Get("L1074");
        else if (span.TotalHours > 1) return Math.Floor(span.TotalHours) + Language.Get("L1072");
        else if (span.TotalMinutes > 1) return Math.Floor(span.TotalMinutes) + Language.Get("L1073");
        else return 1 + Language.Get("L1073");
    }
    /// <summary>
    /// 根据属性获取玩家数据
    /// </summary>
    /// <param name="type"></param>
    /// <returns></returns>
    public static ulong GetPropertyValue(PropertyType type)
    {
        switch (type)
        {
            case PropertyType.LV:
                return PlayerDatas.Instance.baseData.LV;
            case PropertyType.POWER:
                return (ulong)PlayerDatas.Instance.baseData.STR;
            case PropertyType.AGILITY:
                return (ulong)PlayerDatas.Instance.baseData.PHY;
            case PropertyType.PHYSIQUE:
                return (ulong)PlayerDatas.Instance.baseData.CON;
            case PropertyType.MENTALITY:
                return (ulong)PlayerDatas.Instance.baseData.PNE;
            case PropertyType.HP:
                return PlayerDatas.Instance.extersion.MaxHP;
            case PropertyType.ATK:
                return (ulong)PlayerDatas.Instance.extersion.MAXATK;
            case PropertyType.DEF:
                return (ulong)PlayerDatas.Instance.extersion.DEF;
            case PropertyType.HIT:
                return (ulong)PlayerDatas.Instance.extersion.HIT;
            case PropertyType.MISS:
                return (ulong)PlayerDatas.Instance.extersion.Miss;
            case PropertyType.ATKSPEED:
                return (ulong)PlayerDatas.Instance.extersion.battleValEx1;
            case PropertyType.CritChance:
                return (ulong)PlayerDatas.Instance.extersion.SuperHitRate;
            case PropertyType.CritHurt:
                return (ulong)PlayerDatas.Instance.extersion.SuperHit;
            case PropertyType.CritResis:
                return (ulong)PlayerDatas.Instance.extersion.SuperHitReduce;
            case PropertyType.HeartHit:
                return (ulong)PlayerDatas.Instance.extersion.luckHitRate;
            case PropertyType.HeartHurt:
                return (ulong)PlayerDatas.Instance.extersion.luckHitVal;
            case PropertyType.HeartResis:
                return (ulong)PlayerDatas.Instance.extersion.LuckyHitRateReduce;
            case PropertyType.SkillHurt:
                return (ulong)PlayerDatas.Instance.extersion.SkillAtkRate;
            case PropertyType.PVPAddHurt:
                return (ulong)PlayerDatas.Instance.extersion.DamagePVP;
            case PropertyType.PVPReduceHurt:
                return PlayerDatas.Instance.GetPlayerDataByType((PlayerDataType)191);
            case PropertyType.LifeReply:
                return (ulong)PlayerDatas.Instance.extersion.HPRestorePer;
            case PropertyType.HurtReflect:
                return (ulong)PlayerDatas.Instance.extersion.DamageBackRate;
            case PropertyType.MoveSpeed:
                return (ulong)PlayerDatas.Instance.extersion.SpeedValue;
            case PropertyType.PetAddHurt:
                return (ulong)PlayerDatas.Instance.extersion.PetDamPer;
            case PropertyType.RealHurt:
                return (ulong)PlayerDatas.Instance.extersion.realATK;
            case PropertyType.RealResis:
                return (ulong)PlayerDatas.Instance.extersion.realDEF;
            case PropertyType.DefyDef:
                return (ulong)PlayerDatas.Instance.extersion.IgnoreDefRate;
            case PropertyType.DefyDefResis:
                return (ulong)PlayerDatas.Instance.extersion.IgnoreDefRateReduce;
            case PropertyType.DefChance:
                return (ulong)PlayerDatas.Instance.extersion.DamChanceDef;
            case PropertyType.BloodHurt:
                return (ulong)PlayerDatas.Instance.extersion.BleedDamage;
            case PropertyType.AktReplyBlood:
                return (ulong)PlayerDatas.Instance.extersion.BattleValEx2;
            case PropertyType.Stun:
                return (ulong)PlayerDatas.Instance.extersion.FaintRate;
            case PropertyType.CtrlResis:
                return (ulong)PlayerDatas.Instance.extersion.FaintDefRate;
            case PropertyType.AddFinalHurt:
                return (ulong)PlayerDatas.Instance.extersion.FinalHurt;
            case PropertyType.ReduceFinalHurt:
                return (ulong)PlayerDatas.Instance.extersion.FinalHurtReduce;
            case PropertyType.PVPAddHurtPer:
                return (ulong)PlayerDatas.Instance.extersion.DamagePerPVP;
            case PropertyType.PVPReduceHurtPer:
                return (ulong)PlayerDatas.Instance.extersion.DamagePerPVPReduce;
            case PropertyType.DleHitChance:
                return (ulong)PlayerDatas.Instance.extersion.ComboDamPerRate;
            case PropertyType.DleHurt:
                return (ulong)PlayerDatas.Instance.extersion.ComboDamPer;
            case PropertyType.ReduceSkillHurtPercent:
                return (ulong)PlayerDatas.Instance.extersion.skillAtkRateReduce;
            case PropertyType.NpcHurtAddPer:
                return (ulong)PlayerDatas.Instance.extersion.NpcHurtAddPer;
            case PropertyType.Luck:
                return (ulong)PlayerDatas.Instance.extersion.luckValue;
            case PropertyType.Mater:
                return (ulong)PlayerDatas.Instance.baseData.mater;
            case PropertyType.Wood:
                return (ulong)PlayerDatas.Instance.baseData.wood;
            case PropertyType.Water:
                return (ulong)PlayerDatas.Instance.baseData.water;
            case PropertyType.Fire:
                return (ulong)PlayerDatas.Instance.baseData.fire;
            case PropertyType.Earth:
                return (ulong)PlayerDatas.Instance.baseData.earth;
            case PropertyType.ReduceCrit:
                return (ulong)PlayerDatas.Instance.baseData.reduceCrit;
            case PropertyType.ReduceHeartHurtPer:
                return (ulong)PlayerDatas.Instance.baseData.reduceHeartHurt;
            case PropertyType.ReduceFinalHurtPer:
                return (ulong)PlayerDatas.Instance.baseData.reduceFinalHurt;
            case PropertyType.AtkPercent:
            case PropertyType.CritHurtPercent:
            case PropertyType.DodgePercent:
                // return (ulong)ModelCenter.Instance.GetModel<ReikiRootModel>().GetReikiPropertyValue((int)type);
                // TODO YYL
                return 0ul;
            case PropertyType.SkillAddPerA:
                return (ulong)PlayerDatas.Instance.baseData.skillAddPerA;
            case PropertyType.SkillAddPerB:
                return (ulong)PlayerDatas.Instance.baseData.skillAddPerB;
            case PropertyType.SkillAddPerC:
                return (ulong)PlayerDatas.Instance.baseData.skillAddPerC;
            case PropertyType.SkillAddPerD:
                return (ulong)PlayerDatas.Instance.baseData.skillAddPerD;
            case PropertyType.SkillAddPerE:
                return (ulong)PlayerDatas.Instance.baseData.skillAddPerE;
            case PropertyType.SkillAddPerF:
                return (ulong)PlayerDatas.Instance.baseData.skillAddPerF;
            case PropertyType.SkillAddPerG:
                return (ulong)PlayerDatas.Instance.baseData.skillAddPerG;
            case PropertyType.SkillReducePerA:
                return (ulong)PlayerDatas.Instance.baseData.skillReducePerA;
            case PropertyType.SkillReducePerB:
                return (ulong)PlayerDatas.Instance.baseData.skillReducePerB;
            case PropertyType.SkillReducePerC:
                return (ulong)PlayerDatas.Instance.baseData.skillReducePerC;
            case PropertyType.SkillReducePerD:
                return (ulong)PlayerDatas.Instance.baseData.skillReducePerD;
            case PropertyType.SkillReducePerE:
                return (ulong)PlayerDatas.Instance.baseData.skillReducePerE;
            case PropertyType.SkillReducePerF:
                return (ulong)PlayerDatas.Instance.baseData.skillReducePerF;
            case PropertyType.SkillReducePerG:
                return (ulong)PlayerDatas.Instance.baseData.skillReducePerG;
            case PropertyType.ReduceSkillCDPer:
                return (ulong)PlayerDatas.Instance.extersion.battleValEx3;
            case PropertyType.AddFinalHurtPer:
                return (ulong)PlayerDatas.Instance.extersion.FunalHurtPer;
            case PropertyType.AddNormalHurt:
                return (ulong)PlayerDatas.Instance.baseData.NormalHurt;
            case PropertyType.AddNormalHurtPer:
                return (ulong)PlayerDatas.Instance.baseData.NormalHurtPer;
            case PropertyType.AddSkillHurt:
                return (ulong)PlayerDatas.Instance.baseData.FabaoHurt;
            case PropertyType.AddSkillHurtPer:
                return (ulong)PlayerDatas.Instance.baseData.FabaoHurtPer;
            case PropertyType.AddPVEHurt:
                return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.DamagePVE);
        }
        return 0;
    }
 
 
    /// <summary>
    /// 换行
    /// </summary>
    /// <param name="val"></param>
    /// <returns></returns>
    private static Regex NewLineRegex = new Regex(@"</r>", RegexOptions.Singleline);
    public static string ReplaceNewLine(string val)
    {
        return val.Replace(@"</r>", "\n");
    }
 
    public static double numto2Decimals(double value)
    {
        //为什么要value * 1000/10 这么写,特殊的数字会有问题,比如36.80000,会(int)(value * 100)被计算为3679
        //测试下只有30几点8000的才会这样
        return (int)(value * 1000 / 10) / 100.00;
    }
 
    /// <summary>
    /// 大数值转化 格式 最多两个小数
    /// K -千,M -百萬,B-十億,T -萬億
    /// 不四舍五入,不用Math.Round,因为当玩家只有23.3456,但是Math.Round会显示23.35, 当购买价格为23.35时无法购买的
    /// </summary>
    public static string ReplaceLargeNum(double num)
    {
        const long K = 10000;    //国内为万,海外为千
        const long M = K * 10000;
        const long B = M * 10000;
        const long T = B * 10000;
 
        if (num >= T)
        {
            return  StringUtility.Contact(numto2Decimals(num / T).ToString("0.##"), Language.Get("L1070_0"));
        }
        else if (num >= B)
        {
            return StringUtility.Contact(numto2Decimals(num / B).ToString("0.##"), Language.Get("L1070_1"));
        }
        else if (num >= M)
        {
            return StringUtility.Contact(numto2Decimals(num / M).ToString("0.##"), Language.Get("L1070"));
        }
        else if (num >= K)
        {
            return StringUtility.Contact(numto2Decimals(num / K).ToString("0.##"), Language.Get("L1071"));
        }
        else
        {
            return numto2Decimals(num).ToString("0.##");
        }
    }
 
    //用于美术字 统一用字母KMBT代表使用,小数点用.
    public static string ReplaceLargeArtNum(double num)
    {
        const long K = 10000;    //国内为万,海外为千
        const long M = K * 10000;
        const long B = M * 10000;
        const long T = B * 10000;
 
        if (num >= T)
        {
            return StringUtility.Contact(numto2Decimals(num / T).ToString("0.##"), "t");
        }
        else if (num >= B)
        {
            return StringUtility.Contact(numto2Decimals(num / B).ToString("0.##"), "b");
        }
        else if (num >= M)
        {
            return StringUtility.Contact(numto2Decimals(num / M).ToString("0.##"),"m");
        }
        else if (num >= K)
        {
            return StringUtility.Contact(numto2Decimals(num / K).ToString("0.##"), "k");
        }
        else
        {
            return numto2Decimals(num).ToString("0.##");
        }
    }
 
    // 转化大数值带单位的显示,如果小于200000则显示原值,否则显示大数值
    public static string ReplaceLargeNumEx(double num)
    {
        if (num < 200000)
        {
            //根据界面的显示假定值 200000,可根据实际情况调整
            return GetNumFormat(num);
        }
        else
        {
            return ReplaceLargeNum(num);
        }
    }
 
    //显示最多两位小数,并按地区显示格式
    // 如中文用F2 显示 1111.34,英文用N2 显示 1,111.34(带逗号)
    public static string GetNumFormat(double num)
    {
        if (num == (int)num)
        {
            return num.ToString("F0");
        }
        return num.ToString("F2").TrimEnd('0').TrimEnd('.');
    }
 
 
    public static float ReplacePercentage(float num, int isPer, int decimals = 1)
    {
        if (isPer == 1 || isPer == 2)
        {
            return (float)Math.Round(num / 100, decimals);
        }
        else
        {
            return (int)num;
        }
    }
 
    static Regex s_SpecialCharacterRegex = new Regex("[()()@!#$%^&*[]|_]");
    static Regex s_AsciiCharacterRegex = new Regex("[\x00-\x1F]|[\x21-\x2F]|[\x3A-\x40]|[\x5B-\x60]|[\x7B-\x7E]");
    public static bool HasSpecialCharac(string str)
    {
        if (s_SpecialCharacterRegex.IsMatch(str))
        {
            return true;
        }
        if (s_AsciiCharacterRegex.IsMatch(str))
        {
            return true;
        }
        return false;
    }
 
    public static string GetColorNameByItemColor(int itemColor)
    {
        switch (itemColor)
        {
            case 1:
                return Language.Get("Market_Text_42");
            case 2:
                return Language.Get("Market_Text_43");
            case 3:
                return Language.Get("Market_Text_44");
            case 4:
                return Language.Get("Market_Text_45");
            case 5:
                return Language.Get("Market_Text_46");
            case 6:
            case 7:
            case 8:
                return Language.Get("Market_Text_47");
            case 9:
                return Language.Get("Market_Text_471");
        }
        return "";
    }
 
    #endregion
 
    #region 文字色值
    public static readonly Color s_BrightPinkColor = new Color32(246, 64, 141, 255);
    public static readonly Color s_BrightRedColor = new Color32(255, 3, 3, 255);
    public static readonly Color s_BrightPurpleColor = new Color32(218, 72, 213, 255);
    public static readonly Color s_BrightBlueColor = new Color32(0, 107, 227, 255); //006BE3FF
    public static readonly Color s_BrightOrangeColor = new Color32(255, 103, 1, 255); //FF6701FF
    public static readonly Color s_BrightWhiteColor = new Color32(104, 104, 104, 255); //686868
    public static readonly Color s_BrightGreenColor = new Color32(16, 157, 6, 255); //109d06
 
    public static readonly Color s_DarkPinkColor = new Color32(255, 124, 124, 255);
    public static readonly Color s_DarkRedColor = new Color32(250, 1, 1, 255);
    public static readonly Color s_DarkPurpleColor = new Color32(236, 75, 246, 255);
    public static readonly Color s_DarkBlueColor = new Color32(49, 206, 251, 255);//31cefb
    public static readonly Color s_DarkOrangeColor = new Color32(248, 152, 59, 255);
    public static readonly Color s_DarkWhiteColor = new Color32(247, 247, 247, 255);
    public static readonly Color s_DarkGreenColor = new Color32(53, 225, 34, 255); //35e122
 
    public static readonly Color s_NavyBrown = new Color32(64, 28, 6, 255);//401c06
    public static readonly Color s_Black = new Color32(0, 0, 0, 255);
    public static readonly Color s_NavyYellow = new Color32(255, 239, 71, 255);
    public static readonly Color s_LightGreen = new Color32(141, 220, 17, 255);//8ddc11
    public static readonly Color s_LightYellow = new Color32(255, 244, 205, 255); //fff4cd
    public static readonly Color s_Gray = new Color32(204, 204, 204, 255);
    public static readonly Color s_Gold = new Color32(255, 239, 71, 255);//ffef47
    public static readonly Color s_EarthYellow = new Color32(248, 152, 59, 255);//f8983b
 
    public static readonly Color s_BrightDanLV0 = new Color32(102, 102, 102, 255); //666666
    public static readonly Color s_BrightDanLV1 = new Color32(148, 96, 255, 255); //9460ff
    public static readonly Color s_BrightDanLV2 = new Color32(0, 102, 255, 255); //0066ff
    public static readonly Color s_BrightDanLV3 = new Color32(0, 179, 55, 255); //00b337
    public static readonly Color s_BrightDanLV4 = new Color32(255, 102, 0, 255); //ff6600
    public static readonly Color s_BrightDanLV5 = new Color32(255, 0, 0, 255); //ff0000
    public static readonly Color s_BrightDanLV6 = new Color32(255, 0, 246, 255); //ff00f6
 
    public static readonly Color s_GrayDanLV0 = new Color32(221, 221, 221, 255); //dddddd
    public static readonly Color s_GrayDanLV1 = new Color32(121, 153, 255, 255); //7999ff
    public static readonly Color s_GrayDanLV2 = new Color32(0, 198, 255, 255); //00c6ff
    public static readonly Color s_GrayDanLV3 = new Color32(102, 255, 0, 255); //66ff00
    public static readonly Color s_GrayDanLV4 = new Color32(255, 144, 0, 255); //ff9000
    public static readonly Color s_GrayDanLV5 = new Color32(255, 0, 0, 255); //ff0000
    public static readonly Color s_GrayDanLV6 = new Color32(240, 0, 255, 255); //f000ff
 
    // public static Color GetDanLVColor(int danLv, bool bright = false)
    // {
    //     var crossDanLVConfig = CrossServerArenaConfig.Get(danLv);
    //     if (crossDanLVConfig != null)
    //     {
    //         switch (crossDanLVConfig.DanType)
    //         {
    //             case 0:
    //                 return bright ? s_BrightDanLV0 : s_GrayDanLV0;
    //             case 1:
    //                 return bright ? s_BrightDanLV1 : s_GrayDanLV1;
    //             case 2:
    //                 return bright ? s_BrightDanLV2 : s_GrayDanLV2;
    //             case 3:
    //                 return bright ? s_BrightDanLV3 : s_GrayDanLV3;
    //             case 4:
    //                 return bright ? s_BrightDanLV4 : s_GrayDanLV4;
    //             case 5:
    //                 return bright ? s_BrightDanLV5 : s_GrayDanLV5;
    //             case 6:
    //                 return bright ? s_BrightDanLV6 : s_GrayDanLV6;
    //         }
    //     }
    //     return Color.white;
    // }
 
    // public static string AppendDanLVNameColor(int danLv, bool bright = false)
    // {
    //     var crossDanLVConfig = CrossServerArenaConfig.Get(danLv);
    //     if (crossDanLVConfig == null)
    //     {
    //         return string.Empty;
    //     }
    //     var name = crossDanLVConfig.Name;
    //     switch (crossDanLVConfig.DanType)
    //     {
    //         case 0:
    //             return StringUtility.Contact("<color=#", bright ? "666666" : "dddddd", ">", name, "</color>");
    //         case 1:
    //             return StringUtility.Contact("<color=#", bright ? "9460ff" : "7999ff", ">", name, "</color>");
    //         case 2:
    //             return StringUtility.Contact("<color=#", bright ? "0066ff" : "00c6ff", ">", name, "</color>");
    //         case 3:
    //             return StringUtility.Contact("<color=#", bright ? "00b337" : "66ff00", ">", name, "</color>");
    //         case 4:
    //             return StringUtility.Contact("<color=#", bright ? "ff6600" : "ff9000", ">", name, "</color>");
    //         case 5:
    //             return StringUtility.Contact("<color=#", bright ? "ff0000" : "ff0000", ">", name, "</color>");
    //         case 6:
    //             return StringUtility.Contact("<color=#", bright ? "ff00f6" : "f000ff", ">", name, "</color>");
    //     }
    //     return name;
    // }
 
    public static Color GetUIColor(int itemColor, bool bright = false)
    {
        switch (itemColor)
        {
            case 0:
                return GetUIColor(TextColType.White, bright);
            case 1:
                return GetUIColor(TextColType.White, bright);
            case 2:
                return GetUIColor(TextColType.Blue, bright);
            case 3:
                return GetUIColor(TextColType.Purple, bright);
            case 4:
                return GetUIColor(TextColType.Orange, bright);
            case 5:
                return GetUIColor(TextColType.Red, bright);
            case 6:
            case 7:
            case 8:
                return GetUIColor(TextColType.Pink, bright);
            case 9:
                return GetUIColor(TextColType.Green, bright);
        }
        return GetUIColor(TextColType.White, bright);
    }
 
    public static Color GetUIColor(TextColType type, bool bright = false)
    {
        switch (type)
        {
            case TextColType.None:
            case TextColType.White:
                return bright ? s_BrightWhiteColor : s_DarkWhiteColor;  // s_BrightWhiteColor 是亮底灰色
            case TextColType.Blue:
                return bright ? s_BrightBlueColor : s_DarkBlueColor;
            case TextColType.Purple:
                return bright ? s_BrightPurpleColor : s_DarkPurpleColor;
            case TextColType.Orange:
                return bright ? s_BrightOrangeColor : s_DarkOrangeColor;
            case TextColType.Red:
                return bright ? s_BrightRedColor : s_DarkRedColor;
            case TextColType.Pink:
                return bright ? s_BrightPinkColor : s_DarkPinkColor;
            case TextColType.Green:
                return bright ? s_BrightGreenColor : s_DarkGreenColor;
            case TextColType.NavyBrown:
                return s_NavyBrown;
            case TextColType.DarkGreen:
                return s_BrightGreenColor;
            case TextColType.Black:
                return s_Black;
            case TextColType.NavyYellow:
                return s_NavyYellow;
            case TextColType.LightGreen:
                return s_LightGreen;
            case TextColType.LightYellow:
                return s_LightYellow;
            case TextColType.Gray:
                return s_Gray;
        }
        return bright ? s_BrightWhiteColor : s_DarkWhiteColor;
    }
 
    private static Regex m_TextColorRegex = new Regex("<color=#[0-9a-zA-Z]+>(.*)</color>", RegexOptions.Singleline);
 
    public static string AppendColor(TextColType type, string msg, bool bright = false)
    {
        if (m_TextColorRegex.IsMatch(msg) && msg.ToLower().StartsWith("<color=#")
            && msg.ToLower().EndsWith("</color>"))
        {
            Match match = m_TextColorRegex.Match(msg);
            msg = match.Groups[1].Value;
        }
        switch (type)
        {
            case TextColType.None:
            case TextColType.White:
                return StringUtility.Contact("<color=#", bright ? "686868" : "f7f7f7", ">", msg, "</color>");
            case TextColType.Blue:
                return StringUtility.Contact("<color=#", bright ? "006be3" : "31cefb", ">", msg, "</color>");
            case TextColType.Purple:
                return StringUtility.Contact("<color=#", bright ? "da48d5" : "ec4bf6", ">", msg, "</color>");
            case TextColType.Orange:
                return StringUtility.Contact("<color=#", bright ? "ff6701" : "f8983b", ">", msg, "</color>");
            case TextColType.Red:
                return StringUtility.Contact("<color=#", bright ? "ff0303" : "ff0101", ">", msg, "</color>");
            case TextColType.Pink:
                return StringUtility.Contact("<color=#", bright ? "f6408d" : "ff7c7c", ">", msg, "</color>");
            case TextColType.Green:
                return StringUtility.Contact("<color=#", bright ? "109d06" : "35e122", ">", msg, "</color>");
            case TextColType.NavyBrown:
                return StringUtility.Contact("<color=#", "401c06", ">", msg, "</color>");
            case TextColType.DarkGreen:
                return StringUtility.Contact("<color=#", "109d06", ">", msg, "</color>");
            case TextColType.Black:
                return StringUtility.Contact("<color=#", "000000", ">", msg, "</color>");
            case TextColType.LightYellow:
                return StringUtility.Contact("<color=#", "fff4cd", ">", msg, "</color>");
            case TextColType.LightGreen:
                return StringUtility.Contact("<color=#", "8ddc11", ">", msg, "</color>");
            case TextColType.Gray:
                return StringUtility.Contact("<color=#", "686868", ">", msg, "</color>");
        }
        return msg;
    }
 
    //needName 指境界0是否需要名称
    // public static string GetRealmName(int realmLv, bool bright = false, bool needName = false)
    // {
    //     if (realmLv <= 0 && !needName)
    //     {
    //         return string.Empty;
    //     }
    //     var config = RealmConfig.Get(realmLv);
    //     if (config == null)
    //     {
    //         return string.Empty;
    //     }
    //     return GetRealmColorByLv(realmLv, config.Name, bright);
    // }
 
    //strFormat附加 境界名以外的文字
    //needName 指境界0是否需要名称
    // public static string GetRealmNameEx(int realmLv, string strFormat, bool bright = false, bool needName = false)
    // {
    //     if (realmLv <= 0 && !needName)
    //     {
    //         return string.Empty;
    //     }
    //     var config = RealmConfig.Get(realmLv);
    //     if (config == null)
    //     {
    //         return string.Empty;
    //     }
    //     return GetRealmColorByLv(realmLv, string.Format(strFormat, config.Name), bright);
    // }
 
    // public static string GetRealmColorByLv(int realmLv, string msg, bool bright = false)
    // {
    //     var config = RealmConfig.Get(realmLv);
    //     if (config == null)
    //     {
    //         return string.Empty;
    //     }
    //     switch (config.Quality)
    //     {
    //         case 1:
    //             return StringUtility.Contact("<color=#", bright ? "666666" : "dddddd", ">", msg, "</color>");
    //         case 2:
    //             return StringUtility.Contact("<color=#", bright ? "00b337" : "66ff00", ">", msg, "</color>");
    //         case 3:
    //             return StringUtility.Contact("<color=#", bright ? "0066ff" : "00c6ff", ">", msg, "</color>");
    //         case 4:
    //             return StringUtility.Contact("<color=#", bright ? "ff00f6" : "f000ff", ">", msg, "</color>");
    //         case 5:
    //             return StringUtility.Contact("<color=#", bright ? "ff6600" : "ff9000", ">", msg, "</color>");
    //         case 6:
    //             return StringUtility.Contact("<color=#", bright ? "ff0000" : "ff0000", ">", msg, "</color>");
    //         default:
    //             return msg;
    //     }
    // }
 
    public static string AppendColor(int itemColor, string msg, bool bright = false)
    {
        switch (itemColor)
        {
            case 0:
            case 1:
                return AppendColor(TextColType.White, msg, bright);
            case 2:
                return AppendColor(TextColType.Blue, msg, bright);
            case 3:
                return AppendColor(TextColType.Purple, msg, bright);
            case 4:
                return AppendColor(TextColType.Orange, msg, bright);
            case 5:
                return AppendColor(TextColType.Red, msg, bright);
            case 6:
            case 7:
            case 8:
                return AppendColor(TextColType.Pink, msg, bright);
            case 9:
                return AppendColor(TextColType.Green, msg, bright);
        }
        return msg;
    }
 
    // public static int GetItemColor(int _id, Dictionary<int, List<int>> _dict = null)
    // {
    //     int _itemColor = 0;
    //     var _itemCfg = ItemConfig.Get(_id);
    //     if (_itemCfg != null)
    //     {
    //         _itemColor = _itemCfg.ItemColor;
    //         if (_itemCfg.Type == 113 && _dict != null)
    //         {
    //             _itemColor = ItemLogicUtility.Instance.GetItemQuality(_itemCfg.ID, _dict);
    //         }
    //     }
    //     return _itemColor;
    // }
 
    public static Color GetPropertyColor(int property)
    {
        switch ((PropertyType)property)
        {
            case PropertyType.Mater:
                return s_Gold;
            case PropertyType.Wood:
                return s_LightGreen;
            case PropertyType.Water:
                return s_DarkBlueColor;
            case PropertyType.Fire:
                return s_GrayDanLV5;
            case PropertyType.Earth:
                return s_EarthYellow;
        }
        return s_NavyBrown;
    }
    #endregion
 
    #region 计算战斗力
    public static readonly string FightPowerFormula = "FightpowerFormula";
 
    // public static int GetFightPower(Dictionary<int, int> _propertyDict)
    // {
    //     Equation.Instance.Clear();
    //     if (_propertyDict == null || _propertyDict.Count == 0)
    //     {
    //         return 0;
    //     }
 
    //     foreach (var _key in _propertyDict.Keys)
    //     {
    //         PlayerPropertyConfig cfg = PlayerPropertyConfig.Get(_key);
    //         if (cfg != null)
    //         {
    //             if (_key == 7)
    //             {
    //                 Equation.Instance.AddKeyValue("MinAtk", _propertyDict[_key]);
    //                 Equation.Instance.AddKeyValue("MaxAtk", _propertyDict[_key]);
    //             }
    //             else if (_key == 24)
    //             {
    //                 Equation.Instance.AddKeyValue("PetMinAtk", _propertyDict[_key]);
    //                 Equation.Instance.AddKeyValue("PetMaxAtk", _propertyDict[_key]);
    //             }
    //             else
    //             {
    //                 ulong attrValue = (ulong)_propertyDict[_key];
    //                 var fightParm = GetFightPowerParmByAttrId(_key);
    //                 if (_key == 11)
    //                 {
    //                     var playerLv = PlayerDatas.Instance.baseData.LV;
    //                     var paramConfig = FightPowerParamConfig.Get(playerLv);
    //                     Equation.Instance.AddKeyValue("AtkSpeedParameter", paramConfig.AtkSpeedParameter);
    //                 }
    //                 else
    //                 {
    //                     if (fightParm != 0)
    //                     {
    //                         attrValue = attrValue * (ulong)fightParm;
    //                     }
    //                 }
    //                 Equation.Instance.AddKeyValue(cfg.Parameter, attrValue);
    //             }
    //         }
 
    //     }
    //     FuncConfigConfig funcCfg = FuncConfigConfig.Get(FightPowerFormula);
    //     return Equation.Instance.Eval<int>(funcCfg.Numerical1);
    // }
 
    // public static int GetFightPowerParmByAttrId(int attrId)
    // {
    //     int playerLv = PlayerDatas.Instance.baseData.LV;
    //     FightPowerParamConfig paramConfig = FightPowerParamConfig.Get(playerLv);
    //     PlayerPropertyConfig cfg = PlayerPropertyConfig.Get(attrId);
    //     if (paramConfig == null || cfg == null) return 0;
 
    //     switch (cfg.Parameter)
    //     {
    //         case "Hit":
    //             return paramConfig.Hit;
    //         case "Miss":
    //             return paramConfig.Miss;
    //         case "IgnoreDefRate":
    //             return paramConfig.IgnoreDefRate;
    //         case "DamChanceDef":
    //             return paramConfig.DamChanceDef;
    //         case "FaintRate":
    //             return paramConfig.FaintRate;
    //         case "LuckyHitRateReduce":
    //             return paramConfig.LuckyHitRateReduce;
    //         case "SkillAtkRate":
    //             return paramConfig.SkillAtkRate;
    //         case "SkillAtkRateReduce":
    //             return paramConfig.SkillAtkRateReduce;
    //         case "DamagePerPVP":
    //             return paramConfig.DamagePerPVP;
    //         case "DamagePerPVPReduce":
    //             return paramConfig.DamagePerPVPReduce;
    //         case "DamBackPer":
    //             return paramConfig.DamBackPer;
    //         case "IgnoreDefRateReduce":
    //             return paramConfig.IgnoreDefRateReduce;
    //         case "FaintDefRate":
    //             return paramConfig.FaintDefRate;
    //         case "AtkSpeedParameter":
    //             return paramConfig.AtkSpeedParameter;
    //         case "JobAHurtAddPer":
    //             return paramConfig.JobAHurtAddPer;
    //         case "JobBHurtAddPer":
    //             return paramConfig.JobBHurtAddPer;
    //         case "JobCHurtAddPer":
    //             return paramConfig.JobCHurtAddPer;
    //         case "JobAAtkReducePer":
    //             return paramConfig.JobAAtkReducePer;
    //         case "JobBAtkReducePer":
    //             return paramConfig.JobBAtkReducePer;
    //         case "JobCAtkReducePer":
    //             return paramConfig.JobCAtkReducePer;
    //         case "SuperHitRate":
    //             return paramConfig.SuperHitRate;
    //         case "LuckyHitRate":
    //             return paramConfig.LuckyHitRate;
    //         case "SuperHitRateReduce":
    //             return paramConfig.SuperHitRateReduce;
    //         case "FinalHurtPer":
    //             return paramConfig.FinalHurtPer;
    //         case "FinalHurtReducePer":
    //             return paramConfig.FinalHurtReducePer;
    //         case "NPCHurtAddPer":
    //             return paramConfig.NPCHurtAddPer;
    //         case "NormalHurtPer":
    //             return paramConfig.NormalHurtPer;
    //         case "FabaoHurtPer":
    //             return paramConfig.FabaoHurtPer;
    //         case "AffairSpeedPer":
    //             return paramConfig.AffairSpeedPer;
    //         case "FamilyBossHurtPer":
    //             return paramConfig.FamilyBossHurtPer;
    //         case "FamilyWarHPPer":
    //             return paramConfig.FamilyWarHPPer;
    //         case "FamilyWarAtkPer":
    //             return paramConfig.FamilyWarAtkPer;
    //         case "FamilySitExpPer":
    //             return paramConfig.FamilySitExpPer;
    //         case "BossFinalHurtPer":
    //             return paramConfig.BossFinalHurtPer;
    //     }
 
    //     return 0;
    // }
 
    #endregion
 
    #region 得到金钱数量根据金钱类型
 
 
    //货币单位的显示,海外显示逗号, 国内不加逗号
    public static string GetMoneyFormat(double money)
    {
        if (money == (int)money)
        {
            return money.ToString("F0");
        }
        return money.ToString("F2").TrimEnd('0').TrimEnd('.');
        //return money.ToString();
    }
 
    //仅用于显示 仙玉和灵石的特殊处理,存在负数情况,如GM惩罚扣除货币
    public static int GetMoneyCntEx(int moneyType)
    {
        switch (moneyType)
        {
            case 1:
                {
                    return (int)(PlayerDatas.Instance.baseData.diamond - PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default5));
                }
            case 2:
                {
                    return (int)(PlayerDatas.Instance.baseData.bindDiamond - PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default6));
                }
        }
        return 0;
    }
 
 
    public static ulong GetMoneyCnt(int moneyType)
    {
        switch (moneyType)
        {
            case 1:
                {
                    return PlayerDatas.Instance.baseData.diamond;
                }
            case 2:
                {
                    return PlayerDatas.Instance.baseData.bindDiamond;
                }
            case 3:
                {
                    return PlayerDatas.Instance.baseData.allCopper;
                }
            case 18:
                {
                    return (ulong)PlayerDatas.Instance.extersion.honorValue;
                }
            case 25:
                {
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.CDBPlayerRefresh_TreasureScore);
                    //return (ulong)ModelCenter.Instance.GetModel<StoreModel>().GetTCBPlayerData(PlayerDataType.CDBPlayerRefresh_TreasureScore);
                }
            case 24:
                {
                    return (ulong)PlayerDatas.Instance.extersion.runeChip;
                }
            case 15:
                {
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.UnionLiven);
                    //return (ulong)ModelCenter.Instance.GetModel<StoreModel>().GetTCBPlayerData(PlayerDataType.UnionLiven);
                }
            case 17:
                {
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.FBHelpPoint);
                    //return (ulong)ModelCenter.Instance.GetModel<StoreModel>().GetTCBPlayerData(PlayerDataType.FBHelpPoint);
                }
            case 27:
                {
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.CDBPlayerRefresh_Danjing);
                    //return (ulong)ModelCenter.Instance.GetModel<StoreModel>().GetTCBPlayerData(PlayerDataType.CDBPlayerRefresh_Danjing);
                }
            case 28:
                {
                    return PlayerDatas.Instance.extersion.soulDust; //废弃了用44
                }
            case 29:
                {
                    return PlayerDatas.Instance.extersion.soulSplinters;
                }
            case 30:
                {
                    return PlayerDatas.Instance.extersion.soulCore;
                }
            case 32:
                {
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default4);
                }
            case 34:
                {
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default13);
                }
            case 35:
                {
                    //功德点
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default14);
                }
            case 37:
                {
                    //机缘点
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default17);
                }
            case 39:
                {
                    //成就积分
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default19);
                }
            case 40:
                {
                    //万界积分
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default20);
                }
            case 41:
                {
                    //符印精华
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.RuneSplinters);
                }
            case 43:
                {
                    //凭证积分
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default34);
                }
            case 44:
                {
                    //聚魂精华
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default35);
                }
            case 45:
                {
                    //骑宠积分
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default37);
                }
            case 46:
                {
                    //古宝养成货币
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default38);
                }
            case 47:
                {
                    //天道币
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default39);
                }
            case 49:
                {
                    //仙缘积分
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default42);
                }
            case 50:
                {
                    //幻境阁积分
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default43);
                }
            case 98:
                {
                    //过期型代金券
                    return PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.default41);
                }
            case 99:
                {
                    //代金券
                    return PlayerDatas.Instance.baseData.ExAttr11;
                }
        }
        return 0;
    }
 
    public static int GetAllVourcher()
    {
        return (int)GetMoneyCnt(98) + (int)GetMoneyCnt(99);
    }
 
    #endregion
 
    #region 得到装备位对应的部位名称
    public static string GetEquipPlaceName(int place)
    {
        if (GeneralDefine.equipPlaceNameDict.ContainsKey(place))
        {
            return GeneralDefine.equipPlaceNameDict[place];
        }
        return "";
    }
    #endregion
 
    #region 服务端发过来文字显示不出来问题
    public static string ServerStringTrim(string str)
    {
        if (!string.IsNullOrEmpty(str))
        {
            str = str.Replace("\0", "");
            str = str.Replace("\x00", "");
            return str;
        }
        else
        {
            return string.Empty;
        }
    }
    #endregion
 
    //账号:706907@1@hyyngame@s30,服务器ID:30
    public static int GetServerIDByAccount(string account)
    {
        string[] strArray = account.Split('@');
        if (strArray.Length < 2)
        {
            //判断长度2不是一个实际长度,一般都是大于2
            return 0;
        }
        if (strArray[strArray.Length - 1].Length < 2)
            return 0;
        int id = 0;
        int.TryParse(strArray[strArray.Length - 1].Substring(1), out id);
        return id;
    }
 
 
    #region 获取间隔奖励
    public static int GetIntervalAward(ICollection<int> _keys, int _present)
    {
        foreach (var _key in _keys)
        {
            if (_present <= _key)
            {
                return _key;
            }
        }
        return _keys.Last();
    }
    #endregion
 
    public static string GetGrade(int _star)
    {
        switch (_star)
        {
            case 5:
                return "S";
            case 4:
                return "A";
            case 3:
                return "B";
            case 2:
                return "C";
            case 1:
                return "D";
        }
        return "D";
    }
 
    public static string TrimContentToServer(string content)
    {
        content = WordAnalysis.Color_Start_Regex.Replace(content, string.Empty);
        content = WordAnalysis.Color_End_Regex.Replace(content, string.Empty);
        content = content.Replace("=", string.Empty);
        content = content.Replace(" ", string.Empty);
        return content;
    }
 
    public static bool SatisfyNameLength(string name, out int error)
    {
        error = 0;
        //bool pureChinese = Regex.IsMatch(name, "^[\u4e00-\u9fa5]+$");
        //var chsCount = GetChsCount(name);
        int length = Encoding.Default.GetBytes(name).Length;
        var maxlength = 20;
        var minlength = 3;
        if (length > maxlength)
        {
            error = 1;
        }
        else if (length < minlength)
        {
            error = 2;
        }
        return error == 0;
    }
 
    public static int GetChsCount(string name)
    {
        var count = 0;
        for (int i = 0; i < name.Length; i++)
        {
            if (Regex.IsMatch(name[i].ToString(), "[\u4e00-\u9fa5]"))
            {
                count++;
            }
        }
        return count;
    }
 
    // public static string GetEquipSuitName(int itemId, bool bright = false)
    // {
    //     if (ItemLogicUtility.Instance.IsSuitEquip(itemId))
    //     {
    //         var itemConfig = ItemConfig.Get(itemId);
    //         return AppendColor(TextColType.Green, EquipModel.GetSuitName(itemConfig.LV), bright);
    //     }
    //     return string.Empty;
    // }
 
    // public static string GetItemName(int itmeId, bool bright = false)
    // {
    //     var itemConfig = ItemConfig.Get(itmeId);
    //     if (itemConfig == null)
    //     {
    //         return string.Empty;
    //     }
    //     return StringUtility.Contact(GetEquipSuitName(itmeId, bright), itemConfig.ItemName);
    // }
 
    public static string GetStar(int star)
    {
        switch (star)
        {
            case 5:
                return "S";
            case 4:
                return "A";
            case 3:
                return "B";
            case 2:
                return "C";
            case 1:
                return "D";
        }
        return string.Empty;
    }
 
 
    //转为s1,s2,s3格式
    public static string GetServers(string serverIDRangeInfo)
    {
        var serverList = new List<string>();
        if (string.IsNullOrEmpty(serverIDRangeInfo) || serverIDRangeInfo == "[]")
        {
            return "all";
        }
 
        var serverArray = JsonMapper.ToObject<int[][]>(serverIDRangeInfo);
 
        for (int i = 0; i < serverArray.Length; i++)
        {
            int startID = serverArray[i][0];
            int endID = serverArray[i][1];
            for (int j = startID; j <= endID; j++)
            {
                var serverName = ServerListCenter.Instance.GetServerName(j);
                serverList.Add(serverName);
                //太长会导致界面顶点数超过65000
                if (serverList.Count > 1000)
                    return string.Join(", ", serverList.ToArray());
            }
        }
        return string.Join(", ", serverList.ToArray());
    }
 
    //不同版本现金的单位不一样,比如越南盾是整数,下发是原值;美元和RMB是小数,下发是原值的100
    public static float GetRealCoin(int money, float scale = 100.0f)
    {
        return money / scale;
    }
 
}