少年修仙传客户端代码仓库
lcy
2024-12-16 a39c35fc6449430cd02bccb681c4a0a880e46cd9
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
using System.Collections.Generic;
using System.Linq;
using LitJson;
using System;
using UnityEngine;
namespace vnxbqy.UI
{
    public class BlessedLandModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk
    {
        #region 功能配置表相关变量
        public int refreshItemCount;                                                //每个福地刷新物品个数
        public int[] itemLevelMaxWorkersArr;                                        //物品等级可用的最大工人数列表  [1级最大人数, 2级, ...]
        public int[] workerFatigueStaminaArr;                                       //工人疲劳状态体力列表 [充沛体力, 正常, 虚弱, 枯竭],总体力=所有体力相加 状态值 0-充沛;1-正常;2-虚弱;3-枯竭
        public int hiredWorkerItemID;                                               //雇佣工人所需道具物品ID
        public int[] hiredWorkerItemQuantityArr;                                    //雇佣工人所需道具物品个数列表[第1个所需个数, ...]
        public Dictionary<int, List<int>> refreshTypeCostCurrencyValueDict;         //刷新类型消耗货币类型|货币值 {"刷新类型":[货币类型, 货币值], ...}
        public Dictionary<int, int> refreshTypeDailyLimitDict;                      //刷新类型每日次数上限,0不限 {"刷新类型":次数上限, ...}
        public int superRefreshDefaultSpecialItemOutputDurationSeconds;             //超级刷新默认产出1个特殊物品有效时长秒,时间到后没有采集则消失 特殊物品设定 - 满级物品,默认自己可采,取消后消失,时间到没采也消失
        public int surroundCooldownS;                                               //刷新周围福地CD,秒
        public int allyHelpCooldownS;                                               //仙盟摇人CD,秒
        public int friendHelpCooldownS;                                             //好友摇人CD,秒
        public int[][] rechargeIDListForActivatingTreasureBowlArr;                  //可激活聚宝盆充值ID列表 [[类型0充值ID], ...] ,配空[]的默认激活
        public int[][][] rewardForFullProgressInTreasureBowlArr;                    //聚宝盆满进度时对应奖励 [[[类型0奖励物品ID,个数,是否拍品], ...],   [[类型1奖励物品ID,个数,是否拍品], ...], ...]
        public Dictionary<int, string> TreasureBowlNameDict;                        //聚宝盆名称
        public int[] TreasureBowlSchedule;                                          //聚宝盆进度
        public int[] TreasureBowlRebate;                                            //聚宝盆返利
        public int maxHelpCount;                                                    //每日可获得帮助奖励次数
        public int[][] helpAwardArr;                                                //帮助成功奖励物品列表 [[物品ID,个数,是否拍品], ...]
        #endregion
        #region 封包相关变量
        //封包相关
        //B030玩家福地相关信息
        public int WorkerCount;                                                     // 已雇佣工人数
        public int EnergyUsed;                                                      // 今日已消耗体力
        public int RefreshCount;                                                    // 今日福地刷新物品次数 - 普通刷新
        public int RefreshCountSuper;                                               // 今日福地刷新物品次数 - 超级刷新
        public int TreasureCount;                                                   // 聚宝盆类型个数,对应类型 0~n
        public int[] TreasureState;                                                 // 聚宝盆是否已激活列表,[类型0是否已激活, ...]
        public int[] TreasureAward;                                                 // 聚宝盆奖励是否已领取列表,[类型0是否已领取, ...]
        public int[] TreasureProgress;                                              // 聚宝盆进度值列表,[类型0进度值, ...],满进度100
        public int HelpAwardCount;                                                  // 今日已帮助别人奖励次数
                                                                                    //B032 福地物品拉预览结果
        public uint PlayerID;                                                       // 福地所属玩家ID,0默认自己
        public byte ItemIndex;                                                      // 物品所在位置索引0~n
        public byte WorkerPreviewCount;                                             // 上工人预览人数
        public uint NeedSeconds;                                                    // 预计需要时间,秒
        //B033 福地详细信息
        //最新福地详细信息 玩家ID 福地详细信息
        public Dictionary<uint, MineAreaInfo> newAreaDataDict = new Dictionary<uint, MineAreaInfo>();
        //type :playerids
        public Dictionary<int, List<uint>> typeToPlayerIDs = new Dictionary<int, List<uint>>();
        //B034奖励结算相关信息
        public byte AwardType;                                                      // 0-通知有奖励,前端下次进入福地可请求进行结算;1-结算奖励结果通知
        public byte AwardLen;
        public string AwardInfo;                                                    //奖励信息 [物品ID,个数,是否拍品], ...]
                                                                                    //B035 福地记录信息
        public List<MineAreaRecord> mineAreaRecordList = new List<MineAreaRecord>();
        #endregion
 
        public uint showPlayerId;                                                   //当前展示福地的PlayerId 
        public int cornucopiaIndex = 0;                                             //当前展示的是哪个聚宝盆 默认展示第0个
        public byte detailsIndex = 0;                                               //显示指定index的资源详情
        public uint helpType = 0;                                                   //驱赶界面显示状态 0 自己主动驱逐 1 帮助别人驱逐
        public uint helpPlayerId;                                                   //要帮助谁
        public uint robPlayerId;                                                    //要驱赶谁
        public uint helpItemIndex;                                                  //帮助目标的物品索引
        public uint myPlayerId;                                                     //我的playerId
        public bool isWin = false;
        public bool isStart = false;
        public bool isSkipLv4Tip = false;                                           //本次登录是否跳过存在四级物品二次确认窗口
        public bool isSkipRefreshTip = false;                                       //本次登录是否跳过普通刷新二次确认窗口
        public int lastSurroundRefreshTime;                                         //上次点击寻觅刷新按钮的时间
        public int lastAllyHelpRefreshTime;                                         //上次点击仙盟摇人按钮的时间
        public int lastFriendHelpRefreshTime;                                       //上次点击好友摇人按钮的时间
        public event Action<List<uint>> UpdateNewAreaData;
        public event Action UpdateOtherAreaData;
        public event Action UpdateFellowAndSurroundAreaData;
        public event Action UpdateFindAreaData;
        public event Action UpdateRecordInfo;
        public event Action UpdatePullPreviewMine;
        public Action UpdateMineAreaData;
        public event Action UpdateTurnFightStateInfo;
        Redpoint mainRedPoint = new Redpoint(MainRedDot.FAIRY_REDPOINT_KEY2, MainRedDot.BlessedLandRedpoint);                                               //福地入口红点
        Redpoint manageRedPoint = new Redpoint(MainRedDot.BlessedLandRedpoint, MainRedDot.BlessedLandRedpoint * 10 + 1);     //管理按钮红点
        Redpoint employRedPoint = new Redpoint(MainRedDot.BlessedLandRedpoint * 10 + 1, MainRedDot.BlessedLandRedpoint * 10 + 2);     //雇佣按钮红点
        PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
        public override void Init()
        {
            #region 读取功能配置表中福地相关数据
            refreshItemCount = int.Parse(FuncConfigConfig.Get("MineAreaBase").Numerical1);
            itemLevelMaxWorkersArr = JsonMapper.ToObject<int[]>(FuncConfigConfig.Get("MineAreaBase").Numerical3);
            workerFatigueStaminaArr = JsonMapper.ToObject<int[]>(FuncConfigConfig.Get("MineAreaWorker").Numerical1);
            hiredWorkerItemID = int.Parse(FuncConfigConfig.Get("MineAreaWorker").Numerical2);
            hiredWorkerItemQuantityArr = JsonMapper.ToObject<int[]>(FuncConfigConfig.Get("MineAreaWorker").Numerical3);
            refreshTypeCostCurrencyValueDict = new Dictionary<int, List<int>>();
            refreshTypeDailyLimitDict = new Dictionary<int, int>();
            var jsonData = JsonMapper.ToObject(FuncConfigConfig.Get("MineAreaRefresh").Numerical1);
            List<string> keyList = jsonData.Keys.ToList();
            for (int i = 0; i < keyList.Count; i++)
            {
                refreshTypeCostCurrencyValueDict.Add(int.Parse(keyList[i]), JsonMapper.ToObject<List<int>>(jsonData[keyList[i]].ToJson()));
            }
            jsonData = JsonMapper.ToObject(FuncConfigConfig.Get("MineAreaRefresh").Numerical2);
            keyList = jsonData.Keys.ToList();
            for (int i = 0; i < keyList.Count; i++)
            {
                refreshTypeDailyLimitDict[int.Parse(keyList[i])] = int.Parse(jsonData[keyList[i]].ToString());
            }
            superRefreshDefaultSpecialItemOutputDurationSeconds = int.Parse(FuncConfigConfig.Get("MineAreaSuperItem").Numerical1);
            surroundCooldownS = int.Parse(FuncConfigConfig.Get("MineAreaRob").Numerical3);
            allyHelpCooldownS = int.Parse(FuncConfigConfig.Get("MineAreaRob").Numerical4);
            friendHelpCooldownS = int.Parse(FuncConfigConfig.Get("MineAreaRob").Numerical5);
            rechargeIDListForActivatingTreasureBowlArr = JsonMapper.ToObject<int[][]>(FuncConfigConfig.Get("MineAreaTreasure").Numerical1);
            rewardForFullProgressInTreasureBowlArr = JsonMapper.ToObject<int[][][]>(FuncConfigConfig.Get("MineAreaTreasure").Numerical3);
            jsonData = JsonMapper.ToObject(FuncConfigConfig.Get("MineAreaTreasure").Numerical4);
            keyList = jsonData.Keys.ToList();
            TreasureBowlNameDict = new Dictionary<int, string>();
            for (int i = 0; i < keyList.Count; i++)
            {
                TreasureBowlNameDict[int.Parse(keyList[i])] = jsonData[keyList[i]].ToString();
            }
            TreasureBowlSchedule = JsonMapper.ToObject<int[]>(FuncConfigConfig.Get("MineAreaTreasure").Numerical2);
            TreasureBowlRebate = JsonMapper.ToObject<int[]>(FuncConfigConfig.Get("MineAreaTreasure").Numerical5);
            maxHelpCount = int.Parse(FuncConfigConfig.Get("MineAreaHelp").Numerical1);
            helpAwardArr = JsonMapper.ToObject<int[][]>(FuncConfigConfig.Get("MineAreaHelp").Numerical2);
            #endregion
            packModel.refreshItemCountEvent += OnRefreshItem;
            RoleParticularModel.OnRevPackage += OnRevPackage;
        }
 
        public override void UnInit()
        {
            packModel.refreshItemCountEvent -= OnRefreshItem;
            RoleParticularModel.OnRevPackage -= OnRevPackage;
        }
 
        void OnRefreshItem(PackType packType, int index, int itemID)
        {
            if (packType == PackType.Item && itemID == hiredWorkerItemID)
            {
                UpdateRedpoint();
            }
        }
 
        void OnRevPackage(int viewType, int playerID, RoleParticularModel.ViewPlayerData data)
        {
            if (viewType != (int)ViewPlayerType.viewCrossPlayerDataBlessedLand)
            {
                return;
            }
 
            if (!WindowCenter.Instance.IsOpen<BlessedLandPKWin>())
            {
                WindowJumpMgr.Instance.WindowJumpToEx("BlessedLandPKWin");
            }
        }
 
        void UpdateRedpoint()
        {
            mainRedPoint.state = RedPointState.None;
            manageRedPoint.state = RedPointState.None;
            employRedPoint.state = RedPointState.None;
            int haveCount = packModel.GetItemCountByID(PackType.Item, hiredWorkerItemID);
            int needCount = WorkerCount > hiredWorkerItemQuantityArr.Length - 1 ? hiredWorkerItemQuantityArr.Length - 1 : hiredWorkerItemQuantityArr[WorkerCount];
            mainRedPoint.state = WorkerCount - GetWorkingCount() == 0 ? RedPointState.None : RedPointState.Simple;
            employRedPoint.state = WorkerCount >= hiredWorkerItemQuantityArr.Length ? RedPointState.None : haveCount >= needCount ? RedPointState.Simple : RedPointState.None;
        }
 
        //获得超级刷新还能用几次
        public int GetResdueSuperRefreshCount()
        {
            return refreshTypeDailyLimitDict[1] - RefreshCountSuper;
        }
 
        //将HB033转化为Dictionary<uint, MineAreaInfo>类型的字典 type 0 在先有字典上更新 1 重头生成
        public Dictionary<uint, MineAreaInfo> ProcessHB033(HB033_tagGCMineAreaInfo source, Dictionary<uint, MineAreaInfo> tempDict, int type)
        {
            for (int i = 0; i < source.AreaList.Length; i++)
            {
                var area = source.AreaList[i];
                // 检查是否已存在该PlayerID的MineAreaInfo
                if (tempDict.ContainsKey(area.PlayerID))
                {
                    // 更新现有的MineAreaInfo对象
                    var existingAreaInfo = tempDict[area.PlayerID];
                    existingAreaInfo.PlayerName = area.PlayerName;
                    existingAreaInfo.Job = area.Job;
                    existingAreaInfo.Face = area.Face;
                    existingAreaInfo.FacePic = area.FacePic;
                    existingAreaInfo.MineCount = area.MineCount;
 
                    // 更新字典的MineItems
                    for (int j = 0; j < area.MineItemList.Length; j++)
                    {
                        var item = area.MineItemList[j];
                        var itemInfo = new MineItemInfo
                        {
                            Index = item.Index,
                            MineID = item.MineID,
                            MineType = item.MineType,
                            UpdTime = item.UpdTime,
                            Position = item.Position,
                            MoveSpeed = item.MoveSpeed,
                            EndTime = item.EndTime,
                            WorkerCount = item.WorkerCount,
                            RobPlayerID = item.RobPlayerID,
                            RobWorkerCount = item.RobWorkerCount,
                            RobPlayerName = item.RobPlayerName,
                            RobFace = item.RobFace,
                            RobJob = item.RobJob,
                            RobFacePic = item.RobFacePic,
                        };
                        // 使用Index作为键值
                        existingAreaInfo.MineItems[item.Index] = itemInfo;
                    }
                }
                else
                {
                    // 创建新的MineAreaInfo对象
                    var newAreaInfo = new MineAreaInfo
                    {
                        PlayerID = area.PlayerID,
                        PlayerName = area.PlayerName,
                        Job = area.Job,
                        Face = area.Face,
                        FacePic = area.FacePic,
                        MineCount = area.MineCount,
                        MineItems = new Dictionary<int, MineItemInfo>()
                    };
 
                    for (int k = 0; k < area.MineItemList.Length; k++)
                    {
                        var item = area.MineItemList[k];
                        var itemInfo = new MineItemInfo
                        {
                            Index = item.Index,
                            MineID = item.MineID,
                            MineType = item.MineType,
                            UpdTime = item.UpdTime,
                            Position = item.Position,
                            MoveSpeed = item.MoveSpeed,
                            EndTime = item.EndTime,
                            WorkerCount = item.WorkerCount,
                            RobPlayerID = item.RobPlayerID,
                            RobWorkerCount = item.RobWorkerCount,
                            RobPlayerName = item.RobPlayerName,
                            RobFace = item.RobFace,
                            RobJob = item.RobJob,
                            RobFacePic = item.RobFacePic,
                        };
                        // 使用Index作为键值
                        newAreaInfo.MineItems.Add(item.Index, itemInfo);
                    }
                    tempDict.Add(area.PlayerID, newAreaInfo);
                }
            }
            return tempDict;
        }
 
 
        public List<uint> ProcessHB033PlayerIDs(HB033_tagGCMineAreaInfo source)
        {
            List<uint> tmpList = new List<uint>();
            for (int i = 0; i < source.AreaList.Length; i++)
            {
                var area = source.AreaList[i];
                tmpList.Add(area.PlayerID);
            }
            return tmpList;
        }
 
        //获得自己福地当前Cell的显示状态
        //0 无物品 1 有物品-超级物品-无人拉 2 有物品-超级物品-自己拉
        //3 有物品-普通物品-无人拉 4 有物品-普通物品-自己拉 5 有物品-普通物品-对方拉
        //6 有物品-普通物品-双方拉-向自己移动 7 有物品-普通物品-双方拉-向对方移动
        public int GetMyBlessedLandCellState(int index)
        {
            MineItemInfo mineItem = newAreaDataDict[myPlayerId].MineItems[index];
 
            if (mineItem.MineID == 0)   //没有物品
                return 0;
 
            if (mineItem.MineType == 1) //是超级物品
                return mineItem.WorkerCount > 0 ? 2 : 1; //自己是否拉取
 
            if (mineItem.WorkerCount > 0)   //自己有拉普通物品
            {
                if (mineItem.RobWorkerCount > 0)//有抢夺者
                {
                    return mineItem.WorkerCount >= mineItem.RobWorkerCount ? 6 : 7; //移动方向
                }
                else
                {
                    return 4;
                }
            }
            else
            {
                return mineItem.RobWorkerCount > 0 ? 5 : 3;
            }
        }
 
        //获得他人福地当前Cell的显示状态
        //0 无物品 1 有物品-超级物品-无人拉 2 有物品-超级物品-房主拉
        //3 有物品-普通物品-无人拉 4 有物品-普通物品-房主拉 5 有物品-普通物品-玩家拉 6 有物品-普通物品-别人拉
        //7 有物品-普通物品-房主和玩家抢-向房主移动 8 有物品-普通物品-房主和玩家抢-向玩家移动
        //9 有物品-普通物品-房主和别人抢-向房主移动 10 有物品-普通物品-房主和别人抢-向别人移动
        public int GetOtherBlessedLandCellState(int index)
        {
            MineItemInfo mineItems = newAreaDataDict[showPlayerId].MineItems[index];
            if (mineItems.MineID == 0)  // 无物品
                return 0;
            if (mineItems.MineType == 1)    //是超级物品
                return mineItems.WorkerCount > 0 ? 2 : 1;    //房主是否拉取
 
            if (mineItems.WorkerCount > 0)   //房主拉普通物品
            {
                if (mineItems.RobWorkerCount > 0)   //有抢夺者
                {
                    if (mineItems.RobPlayerID == myPlayerId)     //抢夺者是玩家
                    {
                        return mineItems.WorkerCount >= mineItems.RobWorkerCount ? 7 : 8;  //移动方向
                    }
                    else
                    {
                        return mineItems.WorkerCount >= mineItems.RobWorkerCount ? 9 : 10;
                    }
                }
                else
                {
                    return 4;
                }
            }
            else
            {
                if (mineItems.RobWorkerCount > 0)   //有抢夺者
                {
                    return mineItems.RobPlayerID == myPlayerId ? 5 : 6;//抢夺者是玩家
                }
                else
                {
                    return 3;
                }
            }
        }
 
        //获得福地管理当前Cell的显示状态 
        //1 自己福地-有超级物品-自己拉 2 自己福地-有普通物品-自己拉
        //3 自己福地-有普通物品-自己和其他玩家抢-向自己移动 4 自己福地-有普通物品-自己和其他玩家抢-向对方移动
        //5 别人福地-有普通物品-自己抢
        //6 别人福地-有普通物品-房主和玩家抢-向房主移动 7 别人福地-有普通物品-房主和玩家抢-向玩家移动 
        public int GetManageCellState(int playerId, int index)
        {
            var mineItems = newAreaDataDict[(uint)playerId].MineItems[index];
            if (playerId == myPlayerId)
            {
                if (mineItems.MineType == 1)
                    return 1;
 
                if (mineItems.RobWorkerCount > 0)//有抢夺者
                {
                    return mineItems.WorkerCount >= mineItems.RobWorkerCount ? 3 : 4; //移动方向
                }
                else
                {
                    return 2;
                }
            }
            else
            {
                if (mineItems.WorkerCount > 0)  //房主有防守
                {
                    return mineItems.WorkerCount >= mineItems.RobWorkerCount ? 6 : 7; //移动方向
                }
                else
                {
                    return 5;
                }
            }
        }
 
        //获得福地记录当前Cell的显示状态 0 自己拉自己的 1 自己拉别人的 2 别人抢我的
        public int GetRecordState(int index)
        {
            if (mineAreaRecordList[index].RecordType == 2)
                return 2;
            if (mineAreaRecordList[index].TagPlayerID == myPlayerId)
                return 0;
            return 1;
        }
 
        //获得当前聚宝盆的显示状态 0 未激活 1 已激活-不能领 2 已激活-可领取 3已激活-已领取  
        public int GetCornucopiaState()
        {
            if (TreasureState[cornucopiaIndex] == 1)    //是否激活
            {
                if (TreasureAward[cornucopiaIndex] == 1)  //是否获得
                {
                    return 3;
                }
                else
                {
                    return TreasureProgress[cornucopiaIndex] == 100 ? 2 : 1; //是否可领
                }
            }
            else
            {
                return 0;
            }
        }
 
        //自己的福地当前能否进行刷新 0普通刷新 1超级刷新
        public bool IsRefresh(int type)
        {
            if (type == 0)
            {
                //需要的货币不够
                if (UIHelper.GetMoneyCnt(refreshTypeCostCurrencyValueDict[0][0]) < (ulong)refreshTypeCostCurrencyValueDict[0][1])
                    return false;
                return true;
            }
            else
            {
                //超级刷新超出了每日刷新次数上限
                if (RefreshCountSuper >= refreshTypeDailyLimitDict[1])
                    return false;
 
                //需要的货币不够
                if (UIHelper.GetMoneyCnt(refreshTypeCostCurrencyValueDict[1][0]) < (ulong)refreshTypeCostCurrencyValueDict[1][1])
                    return false;
                return true;
            }
        }
 
        //得到冷却结束时间 0 寻觅刷新按钮 1 仙盟摇人按钮 2 好友摇人按钮
        public int GetCoolDownEndTime(int type)
        {
            DateTime overTime;
            if (type == 0)
            {
                if (lastSurroundRefreshTime == 0)
                    return 0;
                overTime = TimeUtility.GetTime((uint)(lastSurroundRefreshTime + surroundCooldownS));
            }
            else if (type == 1)
            {
                if (lastAllyHelpRefreshTime == 0)
                    return 0;
                overTime = TimeUtility.GetTime((uint)(lastAllyHelpRefreshTime + allyHelpCooldownS));
            }
            else if (type == 2)
            {
                if (lastFriendHelpRefreshTime == 0)
                    return 0;
                overTime = TimeUtility.GetTime((uint)(lastFriendHelpRefreshTime + friendHelpCooldownS));
            }
            else
            {
                return 0;
            }
            if (TimeUtility.ServerNow > overTime)
                return 0;
            return (int)(overTime - TimeUtility.ServerNow).TotalSeconds;
        }
        //记录时间显示 如果是当天的显示时:分 昨天的显示昨天 前天的显示前天 更早的显示x天前
        public string GetTimeDisplay(uint recordTime)
        {
            // 使用TimeUtility中定义的OriginalTime
            DateTime recordDateTime = TimeUtility.OriginalTime.AddSeconds(recordTime);
            TimeSpan timeDifference = TimeUtility.ServerNow.Date - recordDateTime.Date;
            int daysDifference = timeDifference.Days;
 
            if (daysDifference == 0) // 今天
            {
                return recordDateTime.ToString("H:mm"); // 显示时:分
            }
            else if (daysDifference == 1) // 昨天
            {
                return Language.Get("BlessedLand029");
            }
            else if (daysDifference == 2) // 前天
            {
                return Language.Get("BlessedLand030");
            }
            else // 更早
            {
                return Language.Get("BlessedLand031", daysDifference);
            }
        }
        //当前有多少工作中的工人
        public int GetWorkingCount()
        {
            int result = 0;
            List<uint> KeyList = newAreaDataDict.Keys.ToList();
            for (int i = 0; i < KeyList.Count; i++)
            {
                uint key = KeyList[i];
                MineAreaInfo originalMineAreaInfo = newAreaDataDict[key];
                if (originalMineAreaInfo.PlayerID == myPlayerId)
                {
                    List<int> itemKeys = originalMineAreaInfo.MineItems.Keys.ToList();
                    for (int j = 0; j < itemKeys.Count; j++)
                    {
                        int itemKey = itemKeys[j];
                        MineItemInfo originalMineItemInfo = originalMineAreaInfo.MineItems[itemKey];
                        result += originalMineItemInfo.WorkerCount;
                    }
                }
                else
                {
                    List<int> itemKeys = originalMineAreaInfo.MineItems.Keys.ToList();
                    for (int j = 0; j < itemKeys.Count; j++)
                    {
                        int itemKey = itemKeys[j];
                        MineItemInfo originalMineItemInfo = originalMineAreaInfo.MineItems[itemKey];
                        if (originalMineAreaInfo.MineItems[itemKey].RobPlayerID == myPlayerId)
                        {
                            result += originalMineItemInfo.RobWorkerCount;
                        }
                    }
                }
            }
            return result;
        }
 
        //当前福地的指定资源当前有多少派遣中的工人
        public int GetItemWorkingCount(uint playerId, int index)
        {
            if (playerId == myPlayerId)
            {
                return newAreaDataDict[playerId].MineItems[index].WorkerCount;
            }
            else
            {
                if (newAreaDataDict[playerId].MineItems[index].RobPlayerID == myPlayerId)
                {
                    return newAreaDataDict[playerId].MineItems[index].RobWorkerCount;
                }
                else
                {
                    return 0;
                }
            }
        }
 
        //在当前这个人福地是否除了当前选中的资源以外是否有在当前这个人其他资源
        public bool IsSnatchItem()
        {
            var mineItems = newAreaDataDict[showPlayerId].MineItems;
            for (int i = 0; i < mineItems.Count; i++)
            {
                if (mineItems[i].RobPlayerID == myPlayerId)
                {
                    if (mineItems[i].Index == detailsIndex)
                        continue;
                    return true;
                }
            }
            return false;
        }
 
        //将byte[]转成int[]
        int[] ConvertByteArrayToIntArray(byte[] byteArray)
        {
            int[] intArray = new int[byteArray.Length];
            for (int i = 0; i < byteArray.Length; i++)
            {
                intArray[i] = byteArray[i];
            }
            return intArray;
        }
 
        //返回假人名字
        public string GetNameForPlayerId(int playerId)
        {
            if (playerId == 0)
                return StringUtility.Contact(RandomNameConfig.Get(1).RandomName1, RandomNameConfig.Get(1).RandomName2);
            return StringUtility.Contact(RandomNameConfig.Get(playerId % 797).RandomName1, RandomNameConfig.Get(playerId % 1793).RandomName2);
        }
 
        //返回假人头像
        public AvatarModel GetModelForPlayerId(int playerId)
        {
            int[] numbers = { 1, 2 };
            return AvatarHelper.GetDefaultAvatarModel(numbers[playerId % 2]);
        }
 
        //获得工人体力一共有多少
        public int GetTotalEnergy()
        {
            int totalEnergy = 0;
            for (int i = 0; i < workerFatigueStaminaArr.Length; i++)
            {
                totalEnergy += workerFatigueStaminaArr[i];
            }
            return totalEnergy;
        }
 
        //检查当前我的福地上是否存在大于等于4级的物品且没有被我方拉取
        public bool IsGreaterLv4Item()
        {
            if (!newAreaDataDict.ContainsKey(myPlayerId))
                return false;
            var MineItems = newAreaDataDict[myPlayerId].MineItems;
            var keyList = MineItems.Keys.ToList();
            for (int i = 0; i < keyList.Count; i++)
            {
 
                int mineID = MineItems[keyList[i]].MineID;
                if (mineID == 0 || !MineAreaItemConfig.GetKeys().Contains(mineID.ToString()))
                    continue;
                int itemLV = MineAreaItemConfig.Get(mineID).ItemLV;
                if (itemLV >= 4)
                {
                    if (MineItems[keyList[i]].WorkerCount > 0 && MineItems[keyList[i]].WorkerCount >= MineItems[keyList[i]].RobWorkerCount)
                        return false;
                    return true;
                }
 
            }
            return false;
        }
 
        public void SendCA504Pack(byte rewardType, uint dataEx, byte dataExStrLen = 0, string dataExStr = "")
        {
            var pack = new CA504_tagCMPlayerGetReward()
            {
                RewardType = rewardType,
                DataEx = dataEx,
                DataExStrLen = dataExStrLen,
                DataExStr = dataExStr
            };
            GameNetSystem.Instance.SendInfo(pack);
        }
 
        public void SendCB030Pack(uint playerId, byte itemIndex, byte workerCount, byte isPreview)
        {
            var pak = new CB030_tagCMMineItemPull
            {
                PlayerID = playerId,
                ItemIndex = itemIndex,
                WorkerCount = workerCount,
                IsPreview = isPreview
            };
            GameNetSystem.Instance.SendInfo(pak);
        }
 
        public void SendCB031Pack(byte isSuper)
        {
            var pack = new CB031_tagCMMineItemRefresh()
            {
                IsSuper = isSuper
            };
            GameNetSystem.Instance.SendInfo(pack);
        }
 
        public void SendCB032Pack()
        {
            var pack = new CB032_tagCMMineWorkerEmploy();
            GameNetSystem.Instance.SendInfo(pack);
        }
 
        public void SendCB033Pack(byte queryType, uint queryValue = 0)
        {
            var pack = new CB033_tagCGMineAreaView()
            {
                QueryType = queryType,
                QueryValue = queryValue
            };
            GameNetSystem.Instance.SendInfo(pack);
        }
 
        public void SendCB034Pack()
        {
            var pack = new CB034_tagCGMineAreaAwardGet();
            GameNetSystem.Instance.SendInfo(pack);
        }
 
        public void SendCB410Pack(uint mapID, ushort funcLineID, byte tagType, uint tagID, uint[] valueList)
        {
            var pack = new CB410_tagCMTurnFight();
            pack.MapID = mapID;
            pack.FuncLineID = funcLineID;
            pack.TagType = tagType;
            pack.TagID = tagID;
            pack.ValueCount = (byte)valueList.Length;
            pack.ValueList = valueList;
            GameNetSystem.Instance.SendInfo(pack);
            //TurnFightModel.Instance.StartTurnFight((int)mapID, funcLineID, 1, (int)playerID, valueList);
        }
 
        public void UpdateDetailedBlessedLandPullPreviewRet(HB032_tagGCMineItemPullPreviewRet vNetData)
        {
            PlayerID = vNetData.PlayerID;
            ItemIndex = vNetData.ItemIndex;
            WorkerPreviewCount = vNetData.WorkerCount;
            NeedSeconds = vNetData.NeedSeconds;
            UpdatePullPreviewMine?.Invoke();
        }
 
        public void UpdateMineAreaRecordInfo(HB035_tagGCMineAreaRecordInfo vNetData)
        {
            mineAreaRecordList.Clear();
            var vNetList = vNetData.AreaRecordList;
            for (int i = 0; i < vNetList.Length; i++)
            {
                MineAreaRecord tempMineAreaRecord = new MineAreaRecord();
                tempMineAreaRecord.RecordType = vNetList[i].RecordType;
                tempMineAreaRecord.TagPlayerID = vNetList[i].TagPlayerID;
                tempMineAreaRecord.RecordTime = vNetList[i].RecordTime;
                tempMineAreaRecord.MineID = vNetList[i].MineID;
                tempMineAreaRecord.TagPlayerName = vNetList[i].TagPlayerName;
                tempMineAreaRecord.TagJob = vNetList[i].TagJob;
                tempMineAreaRecord.TagFace = vNetList[i].TagFace;
                tempMineAreaRecord.TagFacePic = vNetList[i].TagFacePic;
                mineAreaRecordList.Add(tempMineAreaRecord);
            }
            UpdateRecordInfo?.Invoke();
 
        }
 
        public void UpdateMineAreaAwardInfo(HB034_tagGCMineAreaAwardInfo vNetData)
        {
            AwardType = vNetData.AwardType;
            AwardLen = vNetData.AwardLen;
            AwardInfo = vNetData.AwardInfo;
 
            if (AwardType == 0)
            {
                //必须在任意福地窗口打开的前提下才能领取奖励
                if (WindowCenter.Instance.IsOpen<BlessedLandCornucopiaWin>() || WindowCenter.Instance.IsOpen<BlessedLandDetailsWin>() ||
                    WindowCenter.Instance.IsOpen<BlessedLandManageWin>() || WindowCenter.Instance.IsOpen<BlessedLandOtherWin>() ||
                    WindowCenter.Instance.IsOpen<BlessedLandPKWin>() || WindowCenter.Instance.IsOpen<BlessedLandRecordWin>() ||
                    WindowCenter.Instance.IsOpen<BlessedLandSeekWin>() || WindowCenter.Instance.IsOpen<BlessedLandWin>())
                {
                    SendCB034Pack();
                }
            }
            else if (AwardType == 1)
            {
                List<Item> itemList = new List<Item>();
                int[][] AwardArr = JsonMapper.ToObject<int[][]>(vNetData.AwardInfo);
                if (AwardArr.IsNullOrEmpty())
                    return;
                itemList.Clear();
                for (int i = 0; i < AwardArr.Length; i++)
                {
                    itemList.Add(new Item(AwardArr[i][0], AwardArr[i][1]));
                }
                ItemLogicUtility.Instance.ShowGetItem(itemList, "", 5, "", () =>
                {
                    LimitedTimeLuxuryGiftModel.Instance.IsItemIdShow(28, hiredWorkerItemID, hiredWorkerItemQuantityArr[Mathf.Min(WorkerCount, hiredWorkerItemQuantityArr.Length - 1)], 1, 0);
                }, true);
            }
 
        }
 
        public void UpdatePlayerTerritoryBlessedLandInformation(HB030_tagMCPlayerMineAreaInfo info)
        {
            WorkerCount = info.WorkerCount;
            EnergyUsed = info.EnergyUsed;
            RefreshCount = (int)info.RefreshCount;
            RefreshCountSuper = info.RefreshCountSuper;
            TreasureCount = info.TreasureCount;
            TreasureState = ConvertByteArrayToIntArray(info.TreasureState);
            TreasureAward = ConvertByteArrayToIntArray(info.TreasureAward);
            TreasureProgress = ConvertByteArrayToIntArray(info.TreasureProgress);
            HelpAwardCount = info.HelpAwardCount;
            UpdateMineAreaData?.Invoke();
            UpdateRedpoint();
        }
 
        public void UpdateDetailedBlessedLandInformation(HB033_tagGCMineAreaInfo source)
        {
            int QueryType = source.QueryType;
            List<uint> playerIdList = new List<uint>();
            for (int i = 0; i < source.AreaList.Length; i++)
            {
                uint playerId = source.AreaList[i].PlayerID;
                if (!playerIdList.Contains(playerId))
                {
                    playerIdList.Add(playerId);
                }
            }
 
            newAreaDataDict = ProcessHB033(source, newAreaDataDict, 0);
 
            switch (source.QueryType)
            {
                case 0:
                    UpdateNewAreaData?.Invoke(playerIdList);
                    UpdateRedpoint();
                    break;
                case 1:
                    UpdateNewAreaData?.Invoke(playerIdList);
                    UpdateFindAreaData?.Invoke();
                    break;
                case 2:
                    typeToPlayerIDs[2] = ProcessHB033PlayerIDs(source);
                    UpdateFellowAndSurroundAreaData?.Invoke();
                    break;
                case 3:
                    typeToPlayerIDs[3] = ProcessHB033PlayerIDs(source);
                    UpdateFellowAndSurroundAreaData?.Invoke();
                    break;
            }
        }
 
        //0 寻觅刷新按钮 1 仙盟摇人按钮 2 好友摇人按钮
        public void SetTime(int type)
        {
            if (type == 0)
            {
                lastSurroundRefreshTime = TimeUtility.AllSeconds;
            }
            else if (type == 1)
            {
                lastAllyHelpRefreshTime = TimeUtility.AllSeconds;
            }
            else if (type == 2)
            {
                lastFriendHelpRefreshTime = TimeUtility.AllSeconds;
            }
        }
 
        public void SaveAllTime()
        {
            int[] arr = new int[3];
            arr[0] = lastSurroundRefreshTime;
            arr[1] = lastAllyHelpRefreshTime;
            arr[2] = lastFriendHelpRefreshTime;
            LocalSave.SetIntArray(StringUtility.Contact("xshl_", myPlayerId), arr);
        }
 
        public void LoadAllTime()
        {
            int[] arr = LocalSave.GetIntArray(StringUtility.Contact("xshl_", myPlayerId));
            if (arr != null && arr.Length == 3)
            {
                lastSurroundRefreshTime = arr[0];
                lastAllyHelpRefreshTime = arr[1];
                lastFriendHelpRefreshTime = arr[2];
            }
            else
            {
                lastSurroundRefreshTime = 0;
                lastAllyHelpRefreshTime = 0;
                lastFriendHelpRefreshTime = 0;
            }
        }
 
        public void OnBeforePlayerDataInitialize()
        {
            WorkerCount = 0;
            EnergyUsed = 0;
            RefreshCount = 0;
            RefreshCountSuper = 0;
            TreasureCount = 0;
            TreasureState = null;
            TreasureAward = null;
            TreasureProgress = null;
            HelpAwardCount = 0;
            PlayerID = 0;
            ItemIndex = 0;
            WorkerPreviewCount = 0;
            NeedSeconds = 0;
            newAreaDataDict.Clear();
            typeToPlayerIDs.Clear();
 
            AwardType = 0;
            AwardLen = 0;
            AwardInfo = null;
            mineAreaRecordList.Clear();
        }
 
        public void OnPlayerLoginOk()
        {
            myPlayerId = PlayerDatas.Instance.PlayerId;
            showPlayerId = myPlayerId;
            LoadAllTime();
        }
 
        public void UpdateTurnFightState(HB420_tagMCTurnFightState vNetData)
        {
            if (vNetData.MapID == 1 && vNetData.TagType == 1 && vNetData.TagID == robPlayerId && vNetData.State == 4)
            {
                JsonData Data = JsonMapper.ToObject(vNetData.Msg);
                isWin = int.Parse(Data["isWin"].ToString()) == 1;
                UpdateTurnFightStateInfo?.Invoke();
            }
        }
    }
}
 
 
public class MineItemInfo
{
    public byte Index;              // 矿物所在福地位置索引,0~n
    public ushort MineID;           // 矿物ID,对应福地采集表中ID,0代表该索引位置没有矿物
    public byte MineType;           // 矿物类型:0-常规;1-超级
    public uint UpdTime;            // 最后一次更新时间戳
    public byte PosLen;
    public string Position;         // 最后一次更新时所在位置百分比,0~100,支持小数,下0上100,可认为分为100格,速度为 x格/秒
    public byte SpeedLen;
    public string MoveSpeed;        // 移动速度,x格/秒,支持小数
    public uint EndTime;            // 拉取结束时间戳
    public byte WorkerCount;        // 工人个数,为0时代表福地玩家没有使用工人拉回
    public uint RobPlayerID;        // 抢夺玩家ID,为0时代表没人抢夺
    public byte RobWorkerCount;     // 抢夺工人个数
    public string RobPlayerName;
    public byte RobJob;
    public uint RobFace;
    public uint RobFacePic;
}
public class MineAreaInfo
{
    public uint PlayerID;            // 福地所属玩家ID,可能是自己或其他玩家ID,当ID小于10000时为假人
    public string PlayerName;        // 可能为空,如自己或假人
    public byte Job;
    public uint Face;
    public uint FacePic;
    public byte MineCount;
    public Dictionary<int, MineItemInfo> MineItems = new Dictionary<int, MineItemInfo>();
}
 
public class MineAreaRecord
{
    public byte RecordType;         // 记录类型;1-自己拉物品;2-物品被人抢
    public uint TagPlayerID;        // 目标玩家ID,等于自己玩家ID时代表拉自己的,反之为抢别人的
    public uint RecordTime;         // 记录时间戳
    public ushort MineID;           // 矿物ID,对应福地采集表中ID
    public string TagPlayerName;
    public byte TagJob;
    public uint TagFace;
    public uint TagFacePic;
}