少年修仙传客户端代码仓库
hch
2025-07-24 50e53441950268933694eeb5aad36147bbe1014d
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
using System.Collections.Generic;
using UnityEngine;
 
namespace vnxbqy.UI
{
    public class FairySiegeRechargeGiftActWin : Window
    {
        [SerializeField] ButtonEx btnClose;
        [SerializeField] ScrollerController scroller;
        FairySiegeHelpModel model { get { return ModelCenter.Instance.GetModel<FairySiegeHelpModel>(); } }
        VipModel vipModel { get { return ModelCenter.Instance.GetModel<VipModel>(); } }
        StoreModel storeModel { get { return ModelCenter.Instance.GetModel<StoreModel>(); } }
 
        #region Built-in
 
        protected override void BindController()
        {
        }
 
        protected override void AddListeners()
        {
            btnClose.SetListener(CloseClick);
        }
 
        protected override void OnPreOpen()
        {
            scroller.OnRefreshCell += OnRefreshCell;
            vipModel.rechargeCountEvent += VipModel_rechargeCountEvent;
            storeModel.RefreshBuyShopLimitEvent += RefreshBuyShopLimitEvent;
            DisplayScroll();
        }
 
        private void VipModel_rechargeCountEvent(int obj)
        {
            scroller.m_Scorller.RefreshActiveCellViews();
        }
 
        protected override void OnAfterOpen()
        {
        }
 
        protected override void OnPreClose()
        {
            scroller.OnRefreshCell -= OnRefreshCell;
            vipModel.rechargeCountEvent -= VipModel_rechargeCountEvent;
            storeModel.RefreshBuyShopLimitEvent -= RefreshBuyShopLimitEvent;
        }
 
        protected override void OnAfterClose()
        {
        }
 
        #endregion
 
        private void RefreshBuyShopLimitEvent()
        {
            scroller.m_Scorller.RefreshActiveCellViews();
        }
 
        private void DisplayScroll()
        {
            scroller.Refresh();
            OperationFamilyRechargeConn act;
            OperationTimeHepler.Instance.TryGetOperation(FairySiegeHelpModel.operaType, out act);
            if (act != null)
            {
                List<StoreConfig> _list = null;
                StoreConfig.TryGetStoreConfigs(act.shopType, out _list);
                var totaleCnt = (_list == null ? 0 : _list.Count) + act.ctgIDs.Count;
                for (var i = 0; i < totaleCnt; i++)
                {
                    scroller.AddCell(ScrollerDataType.Header, i);
                }
            }
            scroller.Restart();
            scroller.m_Scorller.RefreshActiveCellViews();
            scroller.JumpIndex(GetDefaultSelect());
        }
 
        private void OnRefreshCell(ScrollerDataType type, CellView cell)
        {
            var _cell = cell as FairySiegeRechargeGiftActCell;
            _cell.Display(_cell.index);
        }
 
        private int GetDefaultSelect()
        {
            OperationFamilyRechargeConn act;
            OperationTimeHepler.Instance.TryGetOperation(FairySiegeHelpModel.operaType, out act);
            if (act == null)
                return 0;
            List<StoreConfig> _list = null;
            StoreConfig.TryGetStoreConfigs(act.shopType, out _list);
 
            int storeCnt = _list == null ? 0 : _list.Count;
 
            for (int i = 0; i < storeCnt; i++)
            {
                int remainNum;
                storeModel.TryGetIsSellOut(_list[i], out remainNum);
                if (remainNum > 0)
                    return i;
            }
 
            //跳过已购买
            for (int i = 0; i < act.ctgIDs.Count; i++)
            {
                int ctgID = act.ctgIDs[i];
                var countInfo = model.GetBuyCntInfo(ctgID);
 
                if (countInfo.x < countInfo.y)
                    return i + storeCnt;
            }
            return 0;
        }
    }
}