少年修仙传客户端代码仓库
leonard Wu
2018-08-03 c2d2d5d3a840bf50968b3f95e304929bc62a7b70
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
using Snxxz.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using TableConfig;
using UnityEngine;
using LitJson;
 
public class BuyShopItemLimit
{
    public uint ItemIndex;
    public ushort BuyCnt;        // 今日已购买次数
    public int isReset;         //是否属于每月重置  0 不重置 1重置
}
 
public struct ShopItemInfo
{
    public int itemId;
    public int count;
    public int isBind;
 
    public ShopItemInfo(int id,int count,int isBind)
    {
        this.itemId = id;
        this.count = count;
        this.isBind = isBind;
    }
}
 
public class StoreModel : Model,IBeforePlayerDataInitialize,IAfterPlayerDataInitialize,IPlayerLoginOk
{
    public int[] normalBuyCoinsTypes { get; private set; }
    public string UNIONSTORESAVE_KEY { get; private set; }
    public string StoreEffectRecord_Key { get; private set; }
    public List<StoreConfig> shoplist;
 
    public Dictionary<int,Dictionary<int,int>> JobReplaceIdDict = new Dictionary<int, Dictionary<int, int>>();
    public Dictionary<int, string> resetTimeDict { get; private set; }
    public Dictionary<int, int> showCoinsUIDict { get; private set; }
    public override void Init()
    {
        FuncConfigConfig buyItemHinit = ConfigManager.Instance.GetTemplate<FuncConfigConfig>("BuyItemHinit");
        normalBuyCoinsTypes = ConfigParse.GetMultipleStr<int>(buyItemHinit.Numerical1);
        FuncConfigConfig restTimeConfig = ConfigManager.Instance.GetTemplate<FuncConfigConfig>("RefreshText");
        resetTimeDict = ConfigParse.GetDic<int, string>(restTimeConfig.Numerical1);
        FuncConfigConfig mallCurrency = ConfigManager.Instance.GetTemplate<FuncConfigConfig>("MallCurrency");
        showCoinsUIDict = ConfigParse.GetDic<int, int>(mallCurrency.Numerical1);
    }
 
    public void OnBeforePlayerDataInitialize()
    {
        shopItemlimitDict.Clear();
        tagTowerModel = null;
        storeFuncType = StoreFunc.WeekStore;
        tcbRefreshDict.Clear();
     
    }
 
    public void OnAfterPlayerDataInitialize()
    {
        UNIONSTORESAVE_KEY = StringUtility.Contact(PlayerDatas.Instance.baseData.PlayerID, LocalSaveStoreType.UnionStore);
        StoreEffectRecord_Key = StringUtility.Contact(PlayerDatas.Instance.baseData.PlayerID, "StoreEffectRecord");
    }
 
    public void OnPlayerLoginOk()
    {
        PlayerDatas.Instance.fairyData.OnRefreshFairyInfo -= RefreshFamilyLv;
        PlayerDatas.Instance.fairyData.OnRefreshFairyInfo += RefreshFamilyLv;
        FuncOpen.Instance.OnFuncStateChangeEvent -= FuncStateChange;
        FuncOpen.Instance.OnFuncStateChangeEvent += FuncStateChange;
        PlayerDatas.Instance.PlayerDataRefreshInfoEvent -= RefreshPlayerLv;
        PlayerDatas.Instance.PlayerDataRefreshInfoEvent += RefreshPlayerLv;
        TimeMgr.Instance.OnHourEvent -= RefreshServerHour;
        TimeMgr.Instance.OnHourEvent += RefreshServerHour;
        shoplist = null;
        CheckWeekStoreIsShopBuy(out shoplist);
        ControllerRedPoint();
        SetShopRedpoint();
        CheckShopRedpoint();
        SetJobReplaceIDDict();
    }
 
    public string GetStoreRefreshTimeByType(int type)
    {
        if (resetTimeDict == null || !resetTimeDict.ContainsKey(type)) return string.Empty;
 
        switch(type)
        {
            case 7:
                int willRefreshTime = GetWillRefreshTime();
                if(willRefreshTime == 0)
                {
                    return Language.Get("StoreWin201");
                }
                else
                {
                    return Language.Get(resetTimeDict[type],willRefreshTime);
                }
            default:
                return Language.Get(resetTimeDict[type]);
        }
    }
 
    private int GetWillRefreshTime()
    {
       int willRefresh = (3 - TimeUtility.OpenDay % 3);
       if(willRefresh == 3)
        {
            if(TimeUtility.ServerNow.Hour < 5)
            {
                willRefresh = 0;
            }
        }
        return willRefresh;
    }
 
    private void RefreshPlayerLv(PlayerDataRefresh type)
    {
        if (type != PlayerDataRefresh.LV && type != PlayerDataRefresh.VIPLv) return;
 
        CheckShopRedpoint();
    }
 
    public override void UnInit()
    {
     
    }
 
    ItemTipsModel _itemTipsModel;
    ItemTipsModel itemTipsModel
    {
        get
        {
            return _itemTipsModel ?? (_itemTipsModel = ModelCenter.Instance.GetModel<ItemTipsModel>());
        }
    }
 
    #region 职业替换商品逻辑处理
    public void SetJobReplaceIDDict()
    {
        JobReplaceIdDict.Clear();
        List<StoreConfig> storeConfigs = ConfigManager.Instance.GetAllValues<StoreConfig>();
        for(int i = 0; i < storeConfigs.Count; i++)
        {
            Dictionary<int, int> replaceItemDict = new Dictionary<int, int>();
            JobReplaceIdDict.Add(storeConfigs[i].ID,replaceItemDict);
            AnalysisJobReplace(storeConfigs[i]);
            List<ShopItemInfo> shopItems = GetShopItemlistByIndex(storeConfigs[i]);
            for(int j = 0; j < shopItems.Count; j++)
            {
                foreach (var index in jobReplaceDic.Keys)
                {
                    if (jobReplaceDic[index].Contains(shopItems[j].itemId))
                    {
                        int replaceIndex = PlayerDatas.Instance.baseData.Job - 1;
                        int replaceId = jobReplaceDic[index][replaceIndex];
                        replaceItemDict.Add(shopItems[j].itemId,replaceId);
                        break;
                    }
                }
            }
        }
    }
 
    Dictionary<int, List<int>> jobReplaceDic = new Dictionary<int, List<int>>();
    private void AnalysisJobReplace(StoreConfig storeConfig)
    {
        jobReplaceDic.Clear();
        JsonData jsonData = JsonMapper.ToObject(storeConfig.JobItem);
        if (jsonData.IsArray)
        {
            for (int i = 0; i < jsonData.Count; i++)
            {
                List<int> idlist = new List<int>();
                jobReplaceDic.Add(i, idlist);
                if (jsonData[i].IsArray)
                {
                    for (int j = 0; j < jsonData[i].Count; j++)
                    {
                        int itemId = int.Parse(jsonData[i][j].ToString());
                        idlist.Add(itemId);
                    }
                }
            }
        }
    }
 
    public int ReplaceItemIdByJob(int storeId,int itemId)
    {
       if(JobReplaceIdDict.ContainsKey(storeId))
        {
            if(JobReplaceIdDict[storeId].ContainsKey(itemId))
            {
                return JobReplaceIdDict[storeId][itemId];
            }
        }
 
        return itemId;
    }
    #endregion
 
    private void RefreshFamilyLv()
    {
        int familyLv = PlayerDatas.Instance.fairyData.fairy.FamilyLV;
        if(familyLv > GetSaveFairyLV())
        {
            ControllerRedPoint();
        }
    }
 
    private void RefreshServerHour()
    {
        ControllerRedPoint();
    }
 
    public Action RefreshBuyShopLimitEvent;
 
    public StoreFunc storeFuncType = StoreFunc.WeekStore;
    private Dictionary<uint, BuyShopItemLimit> shopItemlimitDict = new Dictionary<uint, BuyShopItemLimit>();
    private Dictionary<string, RuneTowerFloorConfig> tagTowerModel;
 
    /// <summary>
    /// 得到物品购买次数
    /// </summary>
    /// <param name="buylimit"></param>
    public void RefreshBuyShopLimitModel(HA802_tagMCShopItemDayBuyCntInfo buylimit)
    {
        DesignDebug.Log("RefreshBuyShopLimitModel" + buylimit.Count);
        if (buylimit.Count > 0)
        {
            int i = 0;
            for (i = 0; i < buylimit.Count; i++)
            {
                if (!shopItemlimitDict.ContainsKey(buylimit.DayBuyCntList[i].ItemIndex))
                {
                    BuyShopItemLimit shopItemLimit = new BuyShopItemLimit();
                    shopItemLimit.ItemIndex = buylimit.DayBuyCntList[i].ItemIndex;
                    shopItemLimit.BuyCnt = buylimit.DayBuyCntList[i].BuyCnt;
                    shopItemLimit.isReset = buylimit.DayBuyCntList[i].IsReset;
                    shopItemlimitDict.Add(shopItemLimit.ItemIndex, shopItemLimit);
                }
                else
                {
                    shopItemlimitDict[buylimit.DayBuyCntList[i].ItemIndex].BuyCnt = buylimit.DayBuyCntList[i].BuyCnt;
                    shopItemlimitDict[buylimit.DayBuyCntList[i].ItemIndex]. isReset = buylimit.DayBuyCntList[i].IsReset;
                }
            }
 
        }
        CheckShopRedpoint();
        if (RefreshBuyShopLimitEvent != null)
            RefreshBuyShopLimitEvent();
    }
 
    public BuyShopItemLimit GetBuyShopLimit(uint itemIndex)
    {
        if (shopItemlimitDict.ContainsKey(itemIndex))
        {
            return shopItemlimitDict[itemIndex];
        }
        return null;
    }
 
    private RuneConfig _tagRuneModel = null;
 
    public RuneTowerFloorConfig SetRuneSource(int itemId)
    {
        _tagRuneModel = ConfigManager.Instance.GetTemplate<RuneConfig>(itemId);
        if (_tagRuneModel == null)
            return null;
        var _tagRuneTowerModel = ConfigManager.Instance.GetTemplate<RuneTowerFloorConfig>(_tagRuneModel.TowerID);
        return _tagRuneTowerModel;
    }
 
    List<ShopItemInfo> shopItemlist = new List<ShopItemInfo>();
   public List<ShopItemInfo> GetShopItemlistByIndex(StoreConfig storeConfig)
    {
        if (storeConfig == null) return null;
 
        shopItemlist.Clear();
        ShopItemInfo shopItem = new ShopItemInfo(storeConfig.ItemID, storeConfig.ItemCnt, storeConfig.IsBind);
        shopItemlist.Add(shopItem);
        JsonData extraItem = JsonMapper.ToObject(storeConfig.ItemListEx);
        if (extraItem.IsArray)
        {
            for (int i = 0; i < extraItem.Count; i++)
            {
                if (extraItem[i].IsArray)
                {
                    if (extraItem[i].Count > 0)
                    {
                        ShopItemInfo shop = new ShopItemInfo(int.Parse(extraItem[i][0].ToString()), int.Parse(extraItem[i][1].ToString()), int.Parse(extraItem[i][2].ToString()));
                        shopItemlist.Add(shop);
                    }
                }
            }
        }
        return shopItemlist;
    }
 
    public bool TryGetShopItemInfo(StoreFunc _type, int _id, out List<ShopItemInfo> _shopItems)
    {
        _shopItems = null;
        var _list = StoreConfig.GetTypeStoreModel((int)_type, true);
        var _index = _list.FindIndex((x) =>
        {
            return x.ID == _id;
        });
        if (_index == -1)
        {
            return false;
        }
        _shopItems = GetShopItemlistByIndex(_list[_index]);
        return _shopItems != null;
    }
 
    #region 0418 数据处理
    private Dictionary<PlayerDataRefresh, int> tcbRefreshDict = new Dictionary<PlayerDataRefresh, int>();
    public event Action<PlayerDataRefresh> RefreshTCBPlayerDataEvent;
    public void RefreshTCBPlayerData(H0418_tagObjInfoRefresh info)
    {
        if(!tcbRefreshDict.ContainsKey((PlayerDataRefresh)info.RefreshType))
        {
            tcbRefreshDict.Add((PlayerDataRefresh)info.RefreshType,(int)info.Value);
        }
        else
        {
            tcbRefreshDict[(PlayerDataRefresh)info.RefreshType] = (int)info.Value;
        }
 
        if(RefreshTCBPlayerDataEvent != null)
        {
            RefreshTCBPlayerDataEvent((PlayerDataRefresh)info.RefreshType);
        }
    }
 
    public int GetTCBPlayerData(PlayerDataRefresh tCDBPlayer)
    {
        int value = 0;
        tcbRefreshDict.TryGetValue(tCDBPlayer,out value);
        return value;
    }
 
    #endregion
 
    #region 点击商店物品逻辑
    public void OnClickShopCell(StoreConfig shopInfo)
    {
        BuyItemPopModel.Instance.SetModel(shopInfo.ID);
        //SetOpenBuyType(chinModel);
        ItemAttrData attrData = new ItemAttrData(ReplaceItemIdByJob(shopInfo.ID,shopInfo.ItemID),true, (ulong)shopInfo.ItemCnt,-1,shopInfo.IsBind,true,PackType.rptDeleted
            ,"",null,ItemTipChildType.Buy);
        itemTipsModel.SetItemTipsModel(attrData);
    }
 
    #endregion
 
    private ulong _price;
    public void SendBuyShopItem(StoreConfig model, int count)
    {
        if ((StoreFunc)model.ShopType == StoreFunc.RuneStore)
        {
            _tagRuneModel = ConfigManager.Instance.GetTemplate<RuneConfig>(model.ItemID);
            if (_tagRuneModel != null)
            {
                if (!IsCanBuyItem(_tagRuneModel.TowerID))
                {
                    MessageWin.Inst.ShowFixedTip(Language.Get("Store101"));
                    return;
                }
            }
        }
 
        _price = (ulong)(model.MoneyNumber * count);
        if (MoneyIsEnough(model.MoneyType, _price))
        {
            C0803_tagCBuyItemList buyShop = new C0803_tagCBuyItemList();
            buyShop.NPCID = 0;
            buyShop.BuyItemIndex = (ushort)model.ID;
            buyShop.BuyCount = (ushort)count;
            GameNetSystem.Instance.SendInfo(buyShop);
 
        }
        else
        {
            switch(model.MoneyType)
            {
                case 1:
                    if (VersionConfig.Get().isBanShu)
                    {
                        SysNotifyMgr.Instance.ShowTip("GoldErr");
                        return;
                    }
                    WindowCenter.Instance.Open<RechargeTipWin>();
                    break;
                case 25:
                    SysNotifyMgr.Instance.ShowTip("LackXBMoney", model.MoneyType);
                    break;
                default:
                    SysNotifyMgr.Instance.ShowTip("LackMoney", model.MoneyType);
                    break;
            }
        }
 
    }
 
    public event Action<int> RefreshBuyResultEvent;
 
    public void GetBuyResult(HA811_tagMCShoppingResult result)
    {
        DesignDebug.Log("GetBuyResult");
        StoreConfig tagStore = ConfigManager.Instance.GetTemplate<StoreConfig>((int)result.ItemIndex);
        if (tagStore != null)
        {
            ItemConfig chinModel = ConfigManager.Instance.GetTemplate<ItemConfig>(ReplaceItemIdByJob(tagStore.ID, tagStore.ItemID));
            if (!normalBuyCoinsTypes.Contains(tagStore.MoneyType))
            {
                if (tagStore.RemindSuccess == 0)
                {
                    return;
                }
                BuySuccessModel.Instance.SetBuySuccessModel(chinModel.ID, (int)result.ItemCnt, tagStore.IsBind);
                if (!WindowCenter.Instance.CheckOpen<BuySuccessWin>())
                {
                    WindowCenter.Instance.Open<BuySuccessWin>();
                }
            }
            else
            {
                float costMoney = tagStore.MoneyNumber;
                SysNotifyMgr.Instance.ShowTip("BuyItemHinit",costMoney,tagStore.MoneyType, chinModel.ItemName);
            }
           
            if (RefreshBuyResultEvent != null)
            {
                RefreshBuyResultEvent(chinModel.ID);
            }
        }
    }
 
    /// <summary>
    /// 用于判断符文塔兑换是否满足条件
    /// </summary>
    /// <param name="limitTower"></param>
    /// <returns></returns>
    public bool IsCanBuyItem(int limitTower)
    {
        int playerTower = (int)ModelCenter.Instance.GetModel<RuneModel>().RuneTowerOpenLV;
        int offset = playerTower - limitTower;
        if (offset >= 0)
            return true;
        else
            return false;
    }
 
    public bool MoneyIsEnough(int moneyType, ulong money)
    {
        if (UIHelper.GetMoneyCnt(moneyType) < money)
        {
            return false;
        }
        else
        {
            return true;
        }
    }
 
    public int jumpToItemId { get;set;}
    public void SetJumpToModel(int itemId)
    {
        jumpToItemId = itemId;
    }
 
   #region 仙盟商店逻辑处理
    
    #region 仙盟红点逻辑处理
 
    private bool CheckIsBuyNewItem(int fairyLv)
    {
        if(fairyLv > GetSaveFairyLV())
        {
            if (StoreConfig.GetCanBuyShopModel((int)StoreFunc.ToolStore, fairyLv).Count > 0
              || StoreConfig.GetCanBuyShopModel((int)StoreFunc.MountStoneStore, fairyLv).Count > 0
               || StoreConfig.GetCanBuyShopModel((int)StoreFunc.MountSkillBookStore, fairyLv).Count > 0)
            {
                return true;
            }
        }
 
        return false;
    }
 
    private bool CheckIsNewMonth()
    {
        GetSaveDateTime();
        if(datelist.Count > 0)
        {
            if(TimeUtility.ServerNow.Month == datelist[0])
            {
                if(TimeUtility.ServerNow.Day >= 1
                    && TimeUtility.ServerNow.Hour >= 5
                    && datelist[1] <= 1 && datelist[2] < 5)
                {
                    return true;
                }
            }
            else
            {
                if(TimeUtility.ServerNow.Day >= 1
                    && TimeUtility.ServerNow.Hour >= 5)
                {
                    return true;
                }
            }
        }
        else
        {
            return true;
        }
         
        return false;
    }
 
    List<int> datelist = new List<int>();
    public List<int> GetSaveDateTime()
    {
        datelist.Clear();
        int[] unionArray = LocalSave.GetIntArray(UNIONSTORESAVE_KEY);
        if (unionArray != null && unionArray.Length >= 4)
        {
            datelist.Add(unionArray[1]);
            datelist.Add(unionArray[2]);
            datelist.Add(unionArray[3]);
        }
        return datelist;
    }
 
    public int GetSaveFairyLV()
    {
        int[] unionArray = LocalSave.GetIntArray(UNIONSTORESAVE_KEY);
        int fairyLv = 0;
        if(unionArray != null)
        {
            return unionArray[0];
        }
        return fairyLv;
    }
 
 
    //1仙盟等级 2 月份 3 号 4 几点
    public void SetStoreLocalSave(LocalSaveStoreType saveStoreType,params int[] infos)
    {
        string key = StringUtility.Contact(PlayerDatas.Instance.baseData.PlayerID, saveStoreType);
        LocalSave.SetIntArray(key,infos);
    }
 
    public void ControllerRedPoint(bool isLook = false)
    {
        MainRedDot.Instance.fairyStoreRedPoint.state = RedPointState.None;
        if(!ModelCenter.Instance.GetModel<FairyModel>().fairyStoreOpen)
        {
            return;
        }
 
        int familyLv = PlayerDatas.Instance.fairyData.fairy.FamilyLV;
        if(!isLook)
        {
            if (CheckIsBuyNewItem(familyLv))
            {
                MainRedDot.Instance.fairyStoreRedPoint.state = RedPointState.Simple;
                return;
            }
 
            if (CheckIsNewMonth())
            {
                MainRedDot.Instance.fairyStoreRedPoint.state = RedPointState.Simple;
                return;
            }
        }
 
        SetStoreLocalSave(LocalSaveStoreType.UnionStore, familyLv, TimeUtility.ServerNow.Month,
                TimeUtility.ServerNow.Day, TimeUtility.ServerNow.Hour);
    }
 
    #endregion
 
    #endregion
 
    public event Action StoreFuncOpenAct;
 
    private void FuncStateChange(int funcId)
    {
        if (funcId != (int)FuncOpenEnum.Store) return;
 
        shoplist = null;
        CheckWeekStoreIsShopBuy(out shoplist);
        if(shoplist.Count > 0)
        {
            if (StoreFuncOpenAct != null)
            {
                StoreFuncOpenAct();
            }
        }
        SetShopRedpoint();
        CheckShopRedpoint();
    }
 
    public bool CheckWeekStoreIsShopBuy(out List<StoreConfig> buylist)
    {
        buylist = new List<StoreConfig>();
        if (!IsNewDay()) return false;
 
        List<StoreConfig> shoplist = StoreConfig.GetTypeStoreModel((int)StoreFunc.WeekStore);
        for(int i = 0; i < shoplist.Count; i++)
        {
            int canBuyCnt = 0;
            int addBuyCnt = 0;
            bool isLimitBuy = BuyItemPopModel.Instance.CheckIsLimitBuyCnt(shoplist[i], out canBuyCnt, out addBuyCnt);
            BuyShopItemLimit shopItemLimit = GetBuyShopLimit((uint)shoplist[i].ID);
            if (isLimitBuy)
            {
                int remainNum = canBuyCnt;
                if (shopItemLimit != null)
                {
                    remainNum = canBuyCnt - shopItemLimit.BuyCnt;
                }
 
                if (remainNum > 0)
                {
                    buylist.Add(shoplist[i]);
                }
            }
            else
            {
                buylist.Add(shoplist[i]);
            }
        }
 
        if(buylist.Count > 0)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
 
    private bool IsNewDay()
    {
        if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Store)) return false;
   
        if (PlayerPrefs.HasKey(StoreEffectRecord_Key))
        {
            int day = LocalSave.GetInt(StoreEffectRecord_Key);
            if(day != TimeUtility.ServerNow.Day)
            {
                LocalSave.SetInt(StoreEffectRecord_Key,TimeUtility.ServerNow.Day);
                return true;
            }
            else
            {
                return false;
            }
        }
        else
        {
            LocalSave.SetInt(StoreEffectRecord_Key, TimeUtility.ServerNow.Day);
            return true;
        }
    }
 
    /// <summary>
    /// 检测唯一商品是否已售罄
    /// </summary>
    /// <param name="shopIndex"></param>
    /// <param name="isTheOnlyShop"></param>
    /// <returns></returns>
    public bool CheckTheOnlyShopSellOut(int shopIndex,out bool isTheOnlyShop)
    {
        StoreConfig storeConfig = ConfigManager.Instance.GetTemplate<StoreConfig>(shopIndex);
        isTheOnlyShop = false;
        if (storeConfig == null) return false;
 
        if(storeConfig.TheOnlyShop == 1)
        {
            if(StoreConfig.GetTheOnlyShopDict().ContainsKey(storeConfig.ItemID))
            {
                List<StoreConfig> storelist = StoreConfig.GetTheOnlyShopDict()[storeConfig.ItemID];
                for(int i = 0; i < storelist.Count; i++)
                {
                    BuyShopItemLimit shoplimit = GetBuyShopLimit((uint)storelist[i].ID);
                    if(shoplimit != null && shoplimit.BuyCnt >= storelist[i].PurchaseNumber[0])
                    {
                        return true;
                    }
                }
            }
        }
        return false;
    }
 
    #region 商城红点
    public const int StoreFunc_RedKey = 22;
    public const int StoreFunc1_RedKey = 2201;
    public const int StoreFunc2_RedKey = 2202;
    public const int StoreFunc3_RedKey = 2203;
    public const int StoreFunc4_RedKey = 2204;
    public const int StoreFunc5_RedKey = 2205;
    public Redpoint storeFuncPoint = new Redpoint(MainRedDot.RedPoint_UpFuncBase,StoreFunc_RedKey);
    public Redpoint storeFunc1Point = new Redpoint(StoreFunc_RedKey,StoreFunc1_RedKey);
    public Redpoint storeFunc2Point = new Redpoint(StoreFunc_RedKey,StoreFunc2_RedKey);
    public Redpoint storeFunc3Point = new Redpoint(StoreFunc_RedKey,StoreFunc3_RedKey);
    public Redpoint storeFunc4Point = new Redpoint(StoreFunc_RedKey,StoreFunc4_RedKey);
    public Redpoint storeFunc5Point = new Redpoint(StoreFunc_RedKey,StoreFunc5_RedKey);
    public Dictionary<int, Redpoint> shopRedDict = new Dictionary<int, Redpoint>();
    public void SetShopRedpoint()
    {
        shopRedDict.Clear();
        if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Store)) return;
 
        List<StoreConfig> storelist = StoreConfig.GetAllShoplist();
        for(int i = 0; i < storelist.Count; i++)
        {
            StoreConfig storeConfig = storelist[i];
            int redKey = 0;
            Redpoint redpoint = null;
            switch (storeConfig.ShopType)
            {
                case 1:
                    redKey = StoreFunc1_RedKey*10000 + storeConfig.ID;
                    redpoint = new Redpoint(StoreFunc1_RedKey,redKey);
                    break;
                case 2:
                    redKey = StoreFunc2_RedKey * 10000 + storeConfig.ID;
                    redpoint = new Redpoint(StoreFunc2_RedKey, redKey);
                    break;
                case 3:
                    redKey = StoreFunc3_RedKey * 10000 + storeConfig.ID;
                    redpoint = new Redpoint(StoreFunc3_RedKey, redKey);
                    break;
                case 4:
                    redKey = StoreFunc4_RedKey * 10000 + storeConfig.ID;
                    redpoint = new Redpoint(StoreFunc4_RedKey, redKey);
                    break;
                case 5:
                    redKey = StoreFunc5_RedKey * 10000 + storeConfig.ID;
                    redpoint = new Redpoint(StoreFunc5_RedKey, redKey);
                    break;
            }
            shopRedDict.Add(storeConfig.ID,redpoint);
        }
    }
 
    public void CheckShopRedpoint()
    {
        if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Store)) return;
   
        foreach(var key in shopRedDict.Keys)
        {
            StoreConfig storeConfig = ConfigManager.Instance.GetTemplate<StoreConfig>(key);
            if (storeConfig.MoneyNumber == 0)
            {
                int canBuyCnt = 0;
                int addBuyCnt = 0;
                bool isLimitBuy = BuyItemPopModel.Instance.CheckIsLimitBuyCnt(storeConfig, out canBuyCnt, out addBuyCnt);
                BuyShopItemLimit shopItemLimit = GetBuyShopLimit((uint)storeConfig.ID);
                int remainNum = canBuyCnt;
                if (shopItemLimit != null)
                {
                    remainNum -= shopItemLimit.BuyCnt;
                }
                List<StoreConfig> list = StoreConfig.GetSellShoplist();
                if (remainNum > 0 && list.Contains(storeConfig))
                {
                    shopRedDict[storeConfig.ID].state = RedPointState.Simple;
                }
                else
                {
                    shopRedDict[storeConfig.ID].state = RedPointState.None;
                }
 
            }
            else
            {
                shopRedDict[storeConfig.ID].state = RedPointState.None;
            }
        }
    }
 
    #endregion
}
 
public enum StoreFunc
{
    WeekStore = 1, //1:每周限购
    CommonStore = 2, //2:常用道具
    GrowStrongerStore = 3, //3:成长变强
    BindStore = 4,  //4:绑玉商城
    IntegralStore = 5,  //5:积分商城
    BagStore = 6,  //6:随身商店
    RuneStore = 7,  //7:符印商店
    ToolStore = 8, // 道具商店
    MountStoneStore = 9, //坐骑魂石商店
    MountSkillBookStore = 10,//坐骑技能书商店
    XBEquipStore = 11, //寻宝装备商店
    XBRuneStore = 12, //寻宝符印商店
    XBToolStore = 13, //寻宝道具商店
    OSGift = 14,//开服礼包
    OSTimeLimitGift = 15,//限时特惠
}
 
public enum LocalSaveStoreType
{
    UnionStore, //仙盟商店
}