少年修仙传客户端代码仓库
hch
2025-04-03 c154ac0832fe4379a00d3e1cda700e7d2a7383c7
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
using vnxbqy.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
using LitJson;
 
class WeddingModel : ILModel<WeddingModel>
{
 
    Dictionary<uint, uint> couples = new Dictionary<uint, uint>(); //所有伴侣信息
 
    //自己的伴侣信息
    public uint m_CoupleID;    // 伴侣玩家ID,一定是好友,社交信息从好友系统中获取
    public string m_CoupleName;
    public uint m_NewMarryTime;    // 新婚时间戳, 秒,计算结婚天数按该时间计算
    public uint m_MarryTime;    // 最近一次提亲成功时间戳, 秒,计算可离婚时间按该时间计算
    public List<int> m_BridePriceState = new List<int>();    // 聘礼状态,按位存储已购买次数,如205代表ID1买了5次,ID2买了0次,ID3买了2次,最高9次
    public uint m_BreakRequestID;    // 当前请求中的和离时间戳 - 请求方ID,0代表没人发起请求
    public uint m_BreakRequestTime;    // 当前请求中的和离时间戳, 秒,用于计算和离回应有效期
    public uint m_PlayerBreakRequestTime;    // 玩家最近一次和离请求时间戳, 秒,用于计算自身的请求和离CD
 
    public int waitTime = 10;
    public int marryCloseCnt; //结婚所需亲密度
    public int freeCandyCnt;  //表 喜糖免费次数
    public int candyMoneyType;
    public int candyMoneyValue;
    public int maxEatCandyCount;
    public int onceFireCandyCnt; //表 购买烟花赠送喜糖次数
    public int serverBuyFireTimes; //全服可购买次数
    public int fireMoneyType;
    public int fireMoneyValue;
 
    public int divorceCD;  //提亲成功后多久可离婚
    public int divorceReqCD; //可再次提离婚的时间
    public int autoDivorceCD; //自动强制离婚的时间
    public int forceDivorceMoney;
    public int forceDivorceMoneyType;
 
    public const int FuncID = 205;
    public int qyLimitLV = 0;
 
    PackModel packModel { get { return ModelCenter.Instance.GetModelEx<PackModel>(); } }
    FriendsModel friendsModel { get { return ModelCenter.Instance.GetModelEx<FriendsModel>(); } }
 
    EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
    RoleParticularModel rolePModel { get { return ModelCenter.Instance.GetModel<RoleParticularModel>(); } }
    DungeonModel fbModel { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
 
    public event Action OnSelectPlayer;  //选择提前对象
    SelectPlayer m_SelectPlayer;
    public SelectPlayer selectPlayer
    {
        get
        {
            return m_SelectPlayer;
        }
        set
        {
            m_SelectPlayer = value;
            OnSelectPlayer?.Invoke();
        }
    }
 
    protected override void Init()
    {
        GameEvent.afterPlayerDataInitializeEvent += OnAfterPlayerDataInitializeEvent;
        GameEvent.playerLoginOkEvent += OnPlayerLoginOk;
        WindowCenter.Instance.windowAfterOpenEvent += OnAfterWindowOpen;
        packModel.refreshItemCountEvent += RefreshItemCount;
        fbModel.updateDungeonBuyCnt += UpdateDungeonTimes;
        fbModel.dungeonRecordChangeEvent += OnDungeonRecordUpdate;
        ParseConfig();
    }
 
    protected override void UnInit()
    {
        GameEvent.afterPlayerDataInitializeEvent -= OnAfterPlayerDataInitializeEvent;
        WindowCenter.Instance.windowAfterOpenEvent += OnAfterWindowOpen;
        packModel.refreshItemCountEvent -= RefreshItemCount;
        GameEvent.playerLoginOkEvent -= OnPlayerLoginOk;
        fbModel.updateDungeonBuyCnt += UpdateDungeonTimes;
        fbModel.dungeonRecordChangeEvent += OnDungeonRecordUpdate;
    }
 
    void ParseConfig()
    {
        var loveMarry = FuncConfigConfig.Get("LoveMarry");
        waitTime = int.Parse(loveMarry.Numerical1);
        marryCloseCnt = int.Parse(loveMarry.Numerical2);
 
        var loveCandy = FuncConfigConfig.Get("LoveCandy");
        freeCandyCnt = int.Parse(loveCandy.Numerical1);
        maxEatCandyCount = int.Parse(loveCandy.Numerical4);
        var arr = loveCandy.Numerical2.Split('|');
        candyMoneyType = int.Parse(arr[0]);
        candyMoneyValue = int.Parse(arr[1]);
        var loveFire = FuncConfigConfig.Get("LoveCandyFire");
        serverBuyFireTimes = int.Parse(loveFire.Numerical1);
        arr = loveFire.Numerical2.Split('|');
        fireMoneyType = int.Parse(arr[0]);
        fireMoneyValue = int.Parse(arr[1]);
        onceFireCandyCnt = int.Parse(loveFire.Numerical3);
        var divorceConfig = FuncConfigConfig.Get("LoveMarryBreak");
        divorceCD = int.Parse(divorceConfig.Numerical1);
        divorceReqCD = int.Parse(divorceConfig.Numerical2);
        arr = divorceConfig.Numerical3.Split('|');
        forceDivorceMoneyType = int.Parse(arr[0]);
        forceDivorceMoney = int.Parse(arr[1]);
        autoDivorceCD = int.Parse(divorceConfig.Numerical5);
 
        var ringConfig = FuncConfigConfig.Get("LoveRing");
        unLockRingItemID = int.Parse(ringConfig.Numerical1);
        ringLVUPItemID = int.Parse(ringConfig.Numerical2);
 
        var loveFB = FuncConfigConfig.Get("LoveFB");
        isTeamTwo = int.Parse(loveFB.Numerical1);
        fbShowItems = JsonMapper.ToObject<int[][]>(loveFB.Numerical4);
 
        qyLimitLV = FuncOpenLVConfig.Get(FuncID).LimitLV;
    }
 
    void OnAfterPlayerDataInitializeEvent()
    {
        couples.Clear();
        candyInfoList.Clear();
        if (marryPlayerID != PlayerDatas.Instance.baseData.PlayerID)
        {
            //换号清除
            MarryReqDict.Clear();
        }
    }
 
    public void UpdateCouples(IL_HB314_tagGCSocialCouples netPack)
    {
        for (int i = 0; i < netPack.Count; i++)
        {
            if (netPack.Player[i].CoupleID == 0 && couples.ContainsKey(netPack.Player[i].PlayerID))
            {
                //离婚
                couples.Remove(netPack.Player[i].PlayerID);
            }
            else
            { 
                couples[netPack.Player[i].PlayerID] = netPack.Player[i].CoupleID;
            }
        }
    }
 
    public event Action OnCoupleInfo;  //收到结婚信息
 
    public void UpdateMyCouple(IL_HB326_tagGCCoupleInfo netPack)
    {
        if (m_CoupleID > 0 && LocalSave.GetInt("PlayerCouple" + PlayerDatas.Instance.baseData.PlayerID) == 0)
        {
            ynmbxxjUtil.Instance.TraceEvent("getmarried", "", false);
            LocalSave.SetInt("PlayerCouple" + PlayerDatas.Instance.baseData.PlayerID, 1);
        }
        m_CoupleID = netPack.CoupleID;
        m_CoupleName = netPack.CoupleName.Trim().Replace("\0", "");
        m_NewMarryTime = netPack.NewMarryTime;
        m_MarryTime = netPack.MarryTime;
        m_BreakRequestID = netPack.BreakRequestID;
        m_BreakRequestTime = netPack.BreakRequestTime;
        m_PlayerBreakRequestTime = netPack.PlayerBreakRequestTime;
        m_BridePriceState.Clear();
        m_BridePriceState.Add((int)netPack.BridePriceState % 10);
        m_BridePriceState.Add((int)netPack.BridePriceState / 10 % 10);
        m_BridePriceState.Add((int)netPack.BridePriceState / 100 % 10);
        OnCoupleInfo?.Invoke();
    }
 
    //显示自己的模型
    public void ShowPlayer(RawImage rawImage)
    {
        var apperance = equipModel.GetAppearance();
        var data = new UI3DPlayerExhibitionData
        {
            job = PlayerDatas.Instance.baseData.Job,
            fashionClothesId = apperance.fashionClothes,
            fashionWeaponId = apperance.fashionWeapon,
            fashionSecondaryId = apperance.fashionSecondary,
            clothesId = apperance.clothes,
            weaponId = apperance.weapon,
            secondaryId = apperance.secondary,
            wingsId = 0,
            suitLevel = apperance.isSuit ? 1 : 0,
            reikiRootEffectId = 0,
            isDialogue = false,
            equipLevel = PlayerDatas.Instance.baseData.suitLevel,
            titleID = PlayerDatas.Instance.baseData.TitleID,
        };
        UI3DModelExhibition.Instance.ShowPlayer(rawImage, data);
        rawImage.raycastTarget = false;
    }
 
    //显示情侣模型
    public void ShowCouple(RawImage rawImage)
    {
        var viewPlayerData = rolePModel.GetViewPlayerData((int)m_CoupleID);
 
        if (viewPlayerData != null)
        {
 
            int _suitLevel = (int)(viewPlayerData.rolePropData.EquipShowSwitch % 10);
            int clothes = viewPlayerData.GetItemId(RoleEquipType.Clothes);
            int weapon = viewPlayerData.GetItemId(RoleEquipType.Weapon);
            int weapon2 = viewPlayerData.GetItemId(RoleEquipType.Weapon2);
            int fashionClothes = viewPlayerData.GetItemId(RoleEquipType.FashionClothes);
            int fashionWeapon = viewPlayerData.GetItemId(RoleEquipType.FashionWeapon);
            int fashionWeapon2 = viewPlayerData.GetItemId(RoleEquipType.FashionWeapon2);
 
            var data = new UI3DPlayerExhibitionData
            {
                job = viewPlayerData.rolePropData.Job,
                fashionClothesId = fashionClothes,
                fashionWeaponId = fashionWeapon,
                fashionSecondaryId = fashionWeapon2,
                clothesId = clothes,
                suitLevel = _suitLevel,
                weaponId = weapon,
                wingsId = 0,
                secondaryId = weapon2,
                reikiRootEffectId = 0,
                isDialogue = false,
                equipLevel = (int)viewPlayerData.rolePropData.EquipShowSwitch / 10 % 100,
                titleID = viewPlayerData.rolePropData.TitleID,
            };
 
            rawImage.SetActiveIL(true);
            UI3DModelExhibition.InstanceClone1.ShowPlayer(rawImage, data);
            rawImage.raycastTarget = false;
        }
    }
 
    #region 提亲
 
    public List<SelectPlayer> playerList = new List<SelectPlayer>();
    public void GetPlayerList()
    {
        playerList.Clear();
        var friendDict = friendsModel.GetFriendDictByType(2);
        if (friendDict != null)
        { 
            var keyList = friendDict.Keys.ToList();
            for (int i = 0; i < keyList.Count; i++)
            {
                uint playerID = keyList[i];
                var playerInfo = friendsModel.GetFirendInfo(playerID, 2);
                if (playerInfo == null)
                    continue;
                if (couples.ContainsKey(playerID))
                    continue;
                if (playerInfo.OnlineType != 1)
                    continue;
                if (playerInfo.LV < qyLimitLV)
                    continue;
 
                var player = new SelectPlayer
                {
                    playerID = (int)playerID,
                    name = playerInfo.PlayerName.Trim().Replace("\0", ""),
                    closeCnt = FlowerGiftModel.Instance.GetCloseCnt((int)playerID),
                    job = playerInfo.Job,
                    online = playerInfo.OnlineType == 1 ? 1 : 0,
                    face = playerInfo.Face,
                    facePic = playerInfo.FacePic,
                };
                playerList.Add(player);
            }
        }
 
        var fairy = PlayerDatas.Instance.fairyData.fairy;
        if (fairy != null)
        {
            for (int i = 0; i < fairy.Member.Count; i++)
            {
                if (fairy.Member[i].PlayerID == PlayerDatas.Instance.baseData.PlayerID)
                    continue;
                if (couples.ContainsKey(fairy.Member[i].PlayerID))
                    continue;
                if (fairy.Member[i].LV < qyLimitLV)
                    continue;
 
                var player = new SelectPlayer
                {
                    playerID = (int)fairy.Member[i].PlayerID,
                    name = fairy.Member[i].Name.Trim().Replace("\0", ""),
                    closeCnt = FlowerGiftModel.Instance.GetCloseCnt((int)fairy.Member[i].PlayerID),
                    job = fairy.Member[i].Job,
                    online = fairy.Member[i].Exattr2 == 0 ? 1 : 0,
                    face = (int)fairy.Member[i].Face,
                    facePic = (int)fairy.Member[i].FacePic,
                };
                playerList.Add(player);
            }
 
        }
        playerList.Sort(SortPlayer);
    }
 
    int SortPlayer(SelectPlayer friendA, SelectPlayer friendB)
    {
        if (friendA.online != friendB.online)
        {
            return friendB.online.CompareTo(friendA.online);
        }
        return friendB.closeCnt.CompareTo(friendA.closeCnt);
    }
 
    public struct SelectPlayer
    {
        public int playerID;
        public string name;
        public int closeCnt; //亲密度
        public int job;
        public int online; //0 不在线,1在线
        public int face;
        public int facePic;
    }
 
    public event Action OnMarryReqOKEvent;
    public float marryReqOkTime;
    //提亲发送成功,等待对方响应
    public void UpdateMarryReqOK(IL_HB321_tagGCMarryReqOK netPack)
    {
        marryReqOkTime = Time.time;
        OnMarryReqOKEvent?.Invoke();
    }
 
    public uint marryPlayerID = 0; //记录提亲玩家ID,为了区分重连还是切换角色,同角色重连不清数据
    //===接收方收到数据
    public Dictionary<int, MarryReqInfo> MarryReqDict = new Dictionary<int, MarryReqInfo>();
    public int requestID = 0;
    //===请求方收到数据
    public string resultName;
    public int result;
 
 
    public void UpdateMarryReqInfo(IL_HB322_tagGCMarryReqInfo netPack)
    {
        marryPlayerID = PlayerDatas.Instance.baseData.PlayerID;
        MarryReqDict[(int)netPack.PlayerID] = new MarryReqInfo()
        {
            name = netPack.PlayerName.Trim().Replace("\0", ""),
            BridePriceID = netPack.BridePriceID,
            startTime = Time.time,
        };
 
        if (WindowCenter.Instance.IsOpen("WeddingAnswerWin"))
            WindowCenter.Instance.CloseImmediately("WeddingAnswerWin");
 
        GetMarryReqPlayerID();
        //立即打开,取当前封包
        requestID = (int)netPack.PlayerID;
        WindowCenter.Instance.OpenIL<WeddingAnswerWin>();
 
    }
 
    public struct MarryReqInfo
    { 
        public string name;
        public int BridePriceID;
        public float startTime;
    }
 
    public void AnswerMarry(int isOK)
    {
        var pack = new IL_CB312_tagCGMarryResponse();
        pack.ReqPlayerID = (uint)requestID;
        pack.IsOK = (byte)isOK;
 
        GameNetSystem.Instance.SendInfo(pack);
        MarryReqDict.Remove(requestID);
    }
 
    public int GetMarryReqPlayerID()
    {
        List<int> removeIDs = new List<int>();
        var keyList = MarryReqDict.Keys.ToList();
        int getPlayerID = 0;
        for (int i = 0; i < keyList.Count; i++)
        {
            if (Time.time - MarryReqDict[keyList[i]].startTime > waitTime)
            {
                removeIDs.Add(keyList[i]);
            }
            if (getPlayerID == 0)
            {
                getPlayerID = keyList[i];
            }
        }
 
        for (int i = 0; i < removeIDs.Count; i++)
        {
            if (MarryReqDict.ContainsKey(removeIDs[i]))
            {
                MarryReqDict.Remove(removeIDs[i]);
            }
        }
        return getPlayerID;
    }
    
    //提亲回复
    public void UpdateMarryResponseRet(IL_HB323_tagGCMarryResponseRet netPack)
    {
        if (netPack.PlayerIDA != PlayerDatas.Instance.baseData.PlayerID)
            return;
        resultName = netPack.PlayerNameB.Trim().Replace("\0", "");
        result = netPack.IsOK;
        WindowCenter.Instance.OpenIL<WeddingAnswerWin>(false, 3);
        marryReqOkTime = 0;
    }
 
    private void OnAfterWindowOpen(Window _window)
    {
        if (_window.name == "MainInterfaceWin")
        {
            requestID = GetMarryReqPlayerID();
            if (requestID == 0) return;
 
            WindowCenter.Instance.OpenIL<WeddingAnswerWin>();
        }
    }
    #endregion
 
    #region 喜宴
    public event Action OnSelectCandyBanquet;  //选择喜宴
    CandyInfo m_SelectCandyBanquet;
    public CandyInfo selectCandyBanquet
    {
        get
        {
            return m_SelectCandyBanquet;
        }
        set
        {
            m_SelectCandyBanquet = value;
            OnSelectCandyBanquet?.Invoke();
        }
    }
 
    public Redpoint sugarRedPoint = new Redpoint(MainRedPoint.SugarRedPoint);
    public bool candyToggle = false;
    public bool fireToggle = false;
 
    public bool isClickCandyList = false;
 
    public event Action<int, int> OnUpdateCandy;
    public List<CandyInfo> candyInfoList = new List<CandyInfo>();
    uint playerAID;
    uint playerBID;
    //喜糖
    public void UpdateCandyList(IL_HB324_tagGCCandyList netPack)
    {
        for (int i = 0; i < netPack.CandyCount; i++)
        {
            playerAID = netPack.CandyInfoList[i].PlayerIDA;
            playerBID = netPack.CandyInfoList[i].PlayerIDB;
            int index = candyInfoList.FindIndex(FindCandyOwner); //FindCandyOwner(playerAID, playerBID);
            var candy = new CandyInfo() {
                PlayerIDA = playerAID,
                PlayerNameA = netPack.CandyInfoList[i].PlayerNameA,
                PlayerIDB = playerBID,
                PlayerNameB = netPack.CandyInfoList[i].PlayerNameB,
                BridePriceID = netPack.CandyInfoList[i].BridePriceID,
                EndTime = netPack.CandyInfoList[i].EndTime,
                Prosperity = netPack.CandyInfoList[i].Prosperity,
                FireworksPlayerBuyCount = netPack.CandyInfoList[i].FireworksPlayerBuyCount,
                FireworksTotalBuyCount = netPack.CandyInfoList[i].FireworksTotalBuyCount,
                FreeEatCandyCount = (byte)(freeCandyCnt + onceFireCandyCnt* netPack.CandyInfoList[i].FireworksPlayerBuyCount - netPack.CandyInfoList[i].PlayerFreeEatCandyCount),
            };
 
            if (index == -1)
            {
                candyInfoList.Add(candy);
            }
            else
            {
                candyInfoList[index] = candy;
            }
            RefreshCandyList(false);
            OnUpdateCandy?.Invoke((int)playerAID, (int)playerBID);
            UpdateSugarRedpoint();
        }
 
    }
 
    //AB 和BA 可能是同一对仙侣,每对仙侣只能同时存在一个喜宴,在查找前需要过滤过期
    //int FindCandyOwner(uint playerAID, uint playerBID)
    //{
    //    for (int i = 0; i < candyInfoList.Count; i++)
    //    {
    //        if (candyInfoList[i].PlayerIDA == playerAID && candyInfoList[i].PlayerIDB == playerBID)
    //        {
    //            return i;
    //        }
    //    }
    //    return -1;
    //}
    bool FindCandyOwner(CandyInfo candy)
    {
        if (candy.PlayerIDA == playerAID && candy.PlayerIDB == playerBID)
            return true;
 
        return false;
    }
 
    public struct CandyInfo
    {
        public uint PlayerIDA;        // 玩家ID - 请求方
        public string PlayerNameA;
        public uint PlayerIDB;        // 玩家ID - 接受方
        public string PlayerNameB;
        public byte BridePriceID;        // 聘礼ID
        public uint EndTime;        // 结束时间戳,秒
        public uint Prosperity;        // 当前繁荣度
        public byte FireworksTotalBuyCount;        // 烟花总已购买次数
        public byte FireworksPlayerBuyCount;        // 烟花玩家已购买次数
        public byte FreeEatCandyCount;        // 还剩免费次数
    }
 
    public void RefreshCandyList(bool needSort = true)
    {
        List<int> delIndexs = new List<int>();
        int nowTime = TimeUtility.AllSeconds;
        for (int i = 0; i < candyInfoList.Count; i++)
        {
            int id = candyInfoList[i].BridePriceID;
            if (candyInfoList[i].EndTime <= nowTime)
            {
                delIndexs.Add(i);
            }
        }
 
        delIndexs.Reverse();
        for (int i = 0; i < delIndexs.Count; i++)
        {
            candyInfoList.RemoveAt(delIndexs[i]);
        }
 
        if (needSort)
        { 
            candyInfoList.Sort(SortCandyList);
        }
    }
 
    // 有免费次数>高级类别>结束时间
    public int SortCandyList(CandyInfo candyA, CandyInfo candyB)
    {
        bool hasFreeCntA = candyA.FreeEatCandyCount > 0;
        bool hasFreeCntB = candyB.FreeEatCandyCount > 0;
 
        if (hasFreeCntA != hasFreeCntB)
        {
            return hasFreeCntB.CompareTo(hasFreeCntA);
        }
 
        if (candyA.BridePriceID != candyB.BridePriceID)
        {
            return candyB.BridePriceID.CompareTo(candyA.BridePriceID);
        }
 
        return candyA.EndTime.CompareTo(candyB.EndTime);
 
    }
 
    void UpdateSugarRedpoint()
    {
        sugarRedPoint.state = RedPointState.None;
        for (int i = 0; i < candyInfoList.Count; i++)
        {
            if (candyInfoList[i].FreeEatCandyCount > 0)
            {
                sugarRedPoint.state = RedPointState.Simple;
                return;
            }
        }
    }
 
    public CandyInfo GetCandyInfoByPlayerID(uint playerIDA, uint playerIDB)
    {
        for (int i = 0; i < candyInfoList.Count; i++)
        {
            if (candyInfoList[i].PlayerIDA == playerIDA && candyInfoList[i].PlayerIDB == playerIDB)
            {
                return candyInfoList[i];
            }
        }
        return new CandyInfo();
    }
 
    public int eatCandyToday;
    public event Action EatCandyTodayEvent;
    public void UpdateLoveInfo(IL_HB330_tagMCLoveInfo netPack)
    {
        eatCandyToday = (int)netPack.EatCandyToday;
        EatCandyTodayEvent?.Invoke();
    }
 
    #endregion
 
    #region 情戒
    public byte m_ClassLV;    // 阶
    public byte m_StarLV;    // 星
    public uint m_EatCount;    // 本星已淬炼道具数
    public event Action OnLoveRingEvent;
    public event Action OnLoveRingStarUPEvent;
 
    public int unLockRingItemID;
    public int ringLVUPItemID;
    public Dictionary<int, int> ringLVUPAttr = new Dictionary<int, int>();
 
    public void UpdateLoveRing(IL_HB327_tagMCLoveRingInfo netPack)
    {
        bool islvup = false;
        if (m_StarLV != netPack.StarLV)
        {
            islvup = true;
        }
        m_ClassLV = netPack.ClassLV;
        m_StarLV = netPack.StarLV;
        m_EatCount = netPack.EatCount;
 
        OnLoveRingEvent?.Invoke();
        if (islvup) OnLoveRingStarUPEvent?.Invoke();
    }
 
    public void RefreshRingUPAttr()
    {
        ringLVUPAttr.Clear();
        int index = ILLoveRingConfig.GetIndex(m_ClassLV, m_StarLV);
        //丹经验属性
        for (int i = 1; i <= index; i++)
        {
            var config = ILLoveRingConfig.Get(i);
            AddLVUPAttr(config);
            var eatCnt = 0;
            if (config.useCnt == 0)
            {
                //最高级不计算
                continue;
            }
            else if (i == index)
            {
                //当前等级取封包数量
                eatCnt = (int)m_EatCount / config.useCnt;
            }
            else
            {
                eatCnt = config.NeedEatCount / config.useCnt;
            }
 
            for (int j = 0; j < config.UpItemAttrType.Length; j++)
            {
                var upKey = config.UpItemAttrType[j];
                if (!ringLVUPAttr.ContainsKey(upKey))
                {
                    ringLVUPAttr[upKey] = 0;
                }
 
                ringLVUPAttr[upKey] = ringLVUPAttr[upKey] + eatCnt * config.UpItemAttrValue[j];
            }
        }
    }
 
    //升阶属性
    void AddLVUPAttr(ILLoveRingConfig config)
    {
        for (int i = 0; i < config.StarAttrType.Length; i++)
        {
            var upKey = config.StarAttrType[i];
            if (!ringLVUPAttr.ContainsKey(upKey))
            {
                ringLVUPAttr[upKey] = 0;
            }
 
            ringLVUPAttr[upKey] = ringLVUPAttr[upKey] + config.StarAttrValue[i];
        }
 
        if (m_CoupleID != 0)
        { 
            for (int i = 0; i < config.CoupleAttrType.Length; i++)
            {
                var upKey = config.CoupleAttrType[i];
                if (!ringLVUPAttr.ContainsKey(upKey))
                {
                    ringLVUPAttr[upKey] = 0;
                }
 
                ringLVUPAttr[upKey] = ringLVUPAttr[upKey] + config.CoupleAttrValue[i];
            }
        }
    }
 
    //增加属性预览
    public Dictionary<int, int> GetNextTrainAttr()
    {
        int index = ILLoveRingConfig.GetIndex(m_ClassLV, m_StarLV);
        Dictionary<int, int> nextTrainAttr = new Dictionary<int, int>();
        var config = ILLoveRingConfig.Get(index);
        var NextTrainCount = config == null ? 1 : config.useCnt;
        var NeedEatCount = config == null ? 1 : config.NeedEatCount;
        if (NextTrainCount == 0)
        {
            return nextTrainAttr;
        }
        if (index != 0)
        { 
            for (int i = 0; i < config.UpItemAttrType.Length; i++)
            {
                nextTrainAttr[config.UpItemAttrType[i]] = config.UpItemAttrValue[i];
            }
        }
 
        if (m_EatCount + NextTrainCount >= NeedEatCount)
        {
            //有升阶的情况
            var Nextconfig = ILLoveRingConfig.Get(index + 1);
 
            for (int i = 0; i < Nextconfig.StarAttrType.Length; i++)
            {
                if (!nextTrainAttr.ContainsKey(Nextconfig.StarAttrType[i]))
                {
                    nextTrainAttr[Nextconfig.StarAttrType[i]] = 0;
                }
                nextTrainAttr[Nextconfig.StarAttrType[i]] = nextTrainAttr[Nextconfig.StarAttrType[i]] + Nextconfig.StarAttrValue[i];
            }
 
            if (m_CoupleID != 0)
            { 
                for (int i = 0; i < Nextconfig.CoupleAttrType.Length; i++)
                {
                    if (!nextTrainAttr.ContainsKey(Nextconfig.CoupleAttrType[i]))
                    {
                        nextTrainAttr[Nextconfig.CoupleAttrType[i]] = 0;
                    }
                    nextTrainAttr[Nextconfig.CoupleAttrType[i]] = nextTrainAttr[Nextconfig.CoupleAttrType[i]] + Nextconfig.CoupleAttrValue[i];
                }
            }
        }
 
        return nextTrainAttr;
    }
 
    public int GetTrainCount()
    {
        var config = ILLoveRingConfig.GetRingConfigByLVStar(m_ClassLV, m_StarLV);
        if (config == null)
        {
            return 0;
        }
 
        return config.useCnt;
    }
 
    public Redpoint weddingRedPoint = new Redpoint(MainRedDot.RedPoint_key, MainRedPoint.QYRedPoint);
    public Redpoint ringRedPoint = new Redpoint(MainRedPoint.QYRedPoint, MainRedPoint.QYRedPoint * 100 + 1);
 
    void UpdateRingRedPoint()
    {
        ringRedPoint.state = RedPointState.None;
        var count = packModel.GetItemCountByID(PackType.Item, ringLVUPItemID);
        var useCnt = GetTrainCount();
        if (useCnt != 0 && count >= GetTrainCount())
        {
            ringRedPoint.state = RedPointState.Simple;
        }
    }
 
    private void RefreshItemCount(PackType type, int index, int id)
    {
        if (id == ringLVUPItemID)
        {
            UpdateRingRedPoint();
        }
    }
 
    public void OnPlayerLoginOk()
    {
        UpdateRingRedPoint();
    }
    #endregion
 
    #region 情缘副本
    public const int qyFBID = 31300;
    public int isTeamTwo = 0;
    public int[][] fbShowItems;
    //日常修行,此处不关联外层
    public Redpoint fbRedPoint = new Redpoint(MainRedPoint.QYRedPoint * 100 + 2);
    void UpdateFBRedpoint()
    {
        fbRedPoint.state = RedPointState.None;
        var enterTimes = fbModel.GetEnterTimes(qyFBID);
        var totalTimes = fbModel.GetTotalTimes(qyFBID);
        if (enterTimes < totalTimes)
        {
            fbRedPoint.state = RedPointState.Simple;
        }
    }
 
    private void UpdateDungeonTimes()
    {
        UpdateFBRedpoint();
    }
 
    private void OnDungeonRecordUpdate(int _dataMapId)
    {
        UpdateDungeonTimes();
    }
 
    #endregion
}