少年修仙传客户端代码仓库
hch
2025-06-12 204ef05a831c9484e2abc561d27ecbff7c797453
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
using System;
using UnityEngine;
using UnityEngine.UI;
 
namespace vnxbqy.UI
{
    //成长必买
    public class CZBMWin : Window
    {
        [SerializeField] ScrollerController m_GroupCtrl;
        [SerializeField] ScrollerController m_BuyInfoCtrl;
        [SerializeField] Button m_BtnClose;
        [SerializeField] RichText m_ShowTip;
        [SerializeField] Text m_Time;
 
 
        CZBMModel model { get { return ModelCenter.Instance.GetModel<CZBMModel>(); } }
        VipModel vipModel { get { return ModelCenter.Instance.GetModel<VipModel>(); } }
        protected override void BindController()
        {
 
        }
 
        protected override void AddListeners()
        {
            m_BtnClose.onClick.AddListener(CloseClick);
        }
 
        protected override void OnPreOpen()
        {
            m_GroupCtrl.OnRefreshCell += OnGroupRefresh;
            m_BuyInfoCtrl.OnRefreshCell += OnBuyInfoRefresh;
            vipModel.rechargeCountEvent += RechargeCountEvent;
            OperationTimeHepler.Instance.operationTimeUpdateEvent += RefreshUI;
            model.selectUpdate += OnSelectGroup;
            model.selectIndex = GetDefaultSelect();
            Display();
        }
 
        protected override void OnActived()
        {
 
        }
 
        protected override void OnAfterOpen()
        {
            DayRemind.Instance.SetDayRemind(DayRemind.CZBM_REDPOINT, true);
            model.CloseRedpoint();
        }
 
        protected override void OnPreClose()
        {
            m_GroupCtrl.OnRefreshCell -= OnGroupRefresh;
            m_BuyInfoCtrl.OnRefreshCell -= OnBuyInfoRefresh;
            vipModel.rechargeCountEvent -= RechargeCountEvent;
            OperationTimeHepler.Instance.operationTimeUpdateEvent -= RefreshUI;
            model.selectUpdate -= OnSelectGroup;
        }
 
        protected override void OnAfterClose()
        {
 
        }
 
        private void RechargeCountEvent(int id)
        {
            Display();
        }
 
        //过滤已购买的
        int GetDefaultSelect()
        {
            int i = 0;
            OperationBase operationBase;
            if (OperationTimeHepler.Instance.TryGetOperationTime(Operation.CZBMGift, out operationBase))
            {
                OperationCZBM operation = operationBase as OperationCZBM;
                foreach(var buyInfo in operation.CZBMGiftInfo)
                {
                    if (buyInfo.PlayerBuyIndex == buyInfo.BuyCTGIDList.Length - 1)
                    {
                        //最后一档是否已购买
                        int ctgID = (int)buyInfo.BuyCTGIDList[buyInfo.PlayerBuyIndex].CTGID;
 
                        VipModel.RechargeCount _rechargeCount;
                        if (vipModel.TryGetRechargeCount(ctgID, out _rechargeCount))
                        {
                            if (_rechargeCount.todayCount > 0)
                            {
                                i++;
                                if (i >= operation.CZBMGiftInfo.Count)
                                {
                                    //全部购买完毕显示最后一个
                                    i = operation.CZBMGiftInfo.Count - 1;
                                }
                            }
                        
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
            return i;
        }
 
 
 
        private void OnGroupRefresh(ScrollerDataType type, CellView cell)
        {
            var resolveCell = cell as CZBMGroupCell;
            resolveCell.Display(cell.index);
        }
 
        private void OnBuyInfoRefresh(ScrollerDataType type, CellView cell)
        {
            var resolveCell = cell as CZBMCell;
            resolveCell.Display(cell.index);
        }
 
        // 选中刷新购买物品
        private void OnSelectGroup()
        {
            m_GroupCtrl.m_Scorller.RefreshActiveCellViews();
            
            OperationBase operationBase;
            if (OperationTimeHepler.Instance.TryGetOperationTime(Operation.CZBMGift, out operationBase))
            {
                OperationCZBM operation = operationBase as OperationCZBM;
                if(model.selectIndex >= operation.CZBMGiftInfo.Count)
                {
                    CloseClick();
                    return;
                }
                m_BuyInfoCtrl.Refresh();
                for(var i = 0; i < operation.CZBMGiftInfo[model.selectIndex].BuyCTGIDList.Length; i++)
                {
                    m_BuyInfoCtrl.AddCell(ScrollerDataType.Header, i);
                }
 
                m_BuyInfoCtrl.Restart();
                m_BuyInfoCtrl.m_Scorller.RefreshActiveCellViews();
 
                ShowTip(operation);
            }
        }
 
 
        private void ShowTip(OperationCZBM operation)
        {
            if (operation.CZBMGiftInfo[model.selectIndex].PlayerBuyIndex >= operation.CZBMGiftInfo[model.selectIndex].BuyCTGIDList.Length)
            {
                m_ShowTip.text = string.Empty;
                return;
            }
            int ctgID = (int)operation.CZBMGiftInfo[model.selectIndex].BuyCTGIDList[operation.CZBMGiftInfo[model.selectIndex].PlayerBuyIndex].CTGID;
            var ctgInfo = CTGConfig.Get(ctgID);
 
            int ctgID1 = (int)operation.CZBMGiftInfo[model.selectIndex].BuyCTGIDList[0].CTGID;
            var ctgInfo1 = CTGConfig.Get(ctgID1);
 
            m_ShowTip.text = Language.Get("CZBMBuyTip", ctgInfo.Title, ctgInfo1.Title, ctgInfo.Title);
        }
        private void RefreshUI(Operation _type)
        {
            if (_type != Operation.CZBMGift)
            {
                return;
            }
 
 
            Display();
        }
 
        private void Display()
        {
            OperationBase operationBase;
            if (OperationTimeHepler.Instance.TryGetOperationTime(Operation.CZBMGift, out operationBase))
            {
                OperationCZBM operation = operationBase as OperationCZBM;
                if(operation.CZBMGiftInfo.Count == 0)
                {
                    CloseClick();
                    return;
                }
                RefreshGroup(operation);
 
                ShowTip(operation);
                m_Time.text = Language.Get("ActivityTime") + operationBase.startDate.ToDisplay() + "-" + operationBase.endDate.ToDisplay();
            }
 
 
        }
 
        private void RefreshGroup(OperationCZBM operation)
        {
            m_GroupCtrl.Refresh();
            for(var i = 0; i < operation.CZBMGiftInfo.Count; i++)
            {
                m_GroupCtrl.AddCell(ScrollerDataType.Header, i);
            }
 
            m_GroupCtrl.Restart();
            m_GroupCtrl.m_Scorller.RefreshActiveCellViews();
 
            m_BuyInfoCtrl.Refresh();
            for(var i = 0; i < operation.CZBMGiftInfo[model.selectIndex].BuyCTGIDList.Length; i++)
            {
                m_BuyInfoCtrl.AddCell(ScrollerDataType.Header, i);
            }
 
            m_BuyInfoCtrl.Restart();
            m_BuyInfoCtrl.m_Scorller.RefreshActiveCellViews();
        }
    }
}