少年修仙传客户端代码仓库
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
using vnxbqy.UI;
using System;
using System.Collections.Generic;
using UnityEngine.UI;
using System.Linq;
using LitJson;
 
public class ManyDayRechargeModel : ILModel<ManyDayRechargeModel>
{
    public ILOpenServerActivityProxy activity;
 
    public const int activityType = (int)OpenServerActivityCenter.ActivityType.AT_JCHD;
    //精彩活动表中的ID
    public const int activityID = 32;
    public const Operation operationType = Operation.default1; //多日连充
 
    List<uint> playerRecharges = new List<uint>(); //玩家的充值情况
    List<uint> playerAwardState = new List<uint>();
    public List<int> rechargeList = new List<int>(); //活动可参与的充值档次
 
    //价格档位:红点
    Dictionary<int, Redpoint> titleRedpoints = new Dictionary<int, Redpoint>();
    public const int redpointID = 20932;
    public Redpoint redpoint = new Redpoint(MainRedDot.REDPOINT_OPENSERVER, redpointID);
    public event Action onSelectUpdate;
    public event Action onRechargeInfoUpdate;
 
 
    //连充档位 价格
    int m_SelectType = 0;
    public int selectType
    {
        get { return m_SelectType; }
        set
        {
            if (m_SelectType != value)
            {
                m_SelectType = value;
                if (onSelectUpdate != null)
                {
                    onSelectUpdate();
                }
            }
        }
    }
 
 
 
 
 
    protected override void Init()
    {
        GameEvent.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize;
        ILOperationTimeHepler.Instance.operationTimeUpdateEvent += operationTimeUpdateEvent;
        activity = new ILOpenServerActivityProxy(IsOpen, IsAdvance, priorityOpen);
        OpenServerActivityCenter.Instance.Register(activityID, activity, activityType);
    }
 
    protected override void UnInit()
    {
        ILOperationTimeHepler.Instance.operationTimeUpdateEvent -= operationTimeUpdateEvent;
        GameEvent.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitialize;
    }
 
    public bool IsOpen()
    {
        return OperationTimeHepler.Instance.SatisfyOpenCondition(operationType);
    }
 
    public bool IsAdvance()
    {
        return false;
    }
 
    public bool priorityOpen()
    {
        //红点
        return redpoint.state == RedPointState.Simple;
    }
 
 
    public void OnBeforePlayerDataInitialize()
    {
        playerRecharges.Clear();
        playerAwardState.Clear();
    }
 
    public void OnPlayerLoginOk()
    {
 
    }
 
    public void UpdateManyRechargePlayerInfo(IL_HAA49_tagMCActManyDayRechargePlayerInfo package)
    {
        OperationBase operationBase;
        if (!OperationTimeHepler.Instance.TryGetOperationTime(operationType, out operationBase))
        {
            return;
        }
        OperationManyDayRecharge operation = operationBase as OperationManyDayRecharge;
        if (operation.ActNum != package.ActNum)
        {
            return;
        }
 
        playerRecharges = new List<uint>(package.DayRechargeValues);
        playerAwardState = new List<uint>(package.AwardRecord);
 
        UpdateRedpoint();
 
        onRechargeInfoUpdate?.Invoke();
 
    }
 
 
    public int GetSelectType()
    {
        var keyList = titleRedpoints.Keys.ToList();
        for (int i = 0; i < keyList.Count; i++)
        {
            var type = keyList[i];
            if (titleRedpoints[type].state == RedPointState.Simple)
            {
                return type;
            }
        }
 
        return rechargeList[0];
    }
 
    public int jumpIndex {
        get { return rechargeList.IndexOf(selectType); }
    }
 
 
 
    private void operationTimeUpdateEvent(Operation type)
    {
        if (type == operationType)
        {
            OperationBase operationBase;
            if (!OperationTimeHepler.Instance.TryGetOperationTime(operationType, out operationBase))
            {
                return;
            }
            OperationManyDayRecharge operation = operationBase as OperationManyDayRecharge;
 
            //用于排版和红点
            rechargeList = operation.drlcInfoDict.Keys.ToList();
            rechargeList.Sort();
            titleRedpoints.Clear();
            for (int i = 0; i < rechargeList.Count; i++)
            {
                titleRedpoints.Add(rechargeList[i], new Redpoint(redpointID, redpointID * 100 + i));
            }
 
            UpdateRedpoint();
        }
    }
 
    //获取指定档位连充几天,判断充值大小
    public int GetRechargeDayCnt(int NeedRecharge)
    {
        int days = 0;
 
        for (int i = 0; i < playerRecharges.Count; i++)
        {
            if (playerRecharges[i] >= NeedRecharge)
            {
                days++;
            }
        }
        return days;
    }
 
    //获取档位状态 0未达成,1可领取,2已领取
    public int GetRechargeStateByIndex(int NeedRecharge, int NeedDays, int AwardIndex)
    {
        if (NeedDays > GetRechargeDayCnt(NeedRecharge))
            return 0;
 
        //每个数按位存31个激活索引
        var listIndex = AwardIndex / 31;
        var bitIndex = AwardIndex % 31;
        if (((int)Math.Pow(2, bitIndex) & playerAwardState[listIndex]) == 0)
        {
            return 1;
        }
 
        return 2;
    }
 
    void UpdateRedpoint()
    {
        OperationBase operationBase;
        if (!OperationTimeHepler.Instance.TryGetOperationTime(operationType, out operationBase))
        {
            return;
        }
        OperationManyDayRecharge operation = operationBase as OperationManyDayRecharge;
 
        var keyList = titleRedpoints.Keys.ToList();
        for (int i = 0; i < keyList.Count; i++)
        {
            titleRedpoints[keyList[i]].state = RedPointState.None;
            var rechargeList = operation.drlcInfoDict[keyList[i]];
            for (int j = 0; j < rechargeList.Count; j++)
            {
                if (GetRechargeStateByIndex(keyList[i], rechargeList[j].NeedDays, rechargeList[j].AwardIndex) == 1)
                {
                    titleRedpoints[keyList[i]].state = RedPointState.Simple;
                }
            }
        }
    }
 
 
    public void SendGetReward(int awardIndex, int actNumd)
    {
        var pak = new IL_CA504_tagCMPlayerGetReward();
        pak.RewardType = 41;
        pak.DataEx = (uint)awardIndex;
        pak.DataExStr = actNumd.ToString();
        pak.DataExStrLen = (byte)actNumd.ToString().Length;
        GameNetSystem.Instance.SendInfo(pak);
    }
 
}