少年修仙传客户端代码仓库
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
229
230
231
232
233
234
235
236
using vnxbqy.UI;
using System;
using System.Collections.Generic;
using UnityEngine.UI;
using System.Linq;
using LitJson;
 
//跨服充值  功能废弃
public class CSRechargeModel :ILModel<CSRechargeModel>
{
    public event Action UpdatePlayerBillboardEvent;
    public event Action onRechargeInfoUpdate;
 
    public const int activityType = (int)OpenServerActivityCenter.ActivityType.AT_JCHD;
    //精彩活动表中的ID
    public const int activityID = 36;
    public const Operation operationType = Operation.default7; //跨服充值
    public ILOpenServerActivityProxy activity;
 
    public Dictionary<int, Redpoint> titleRedpoints = new Dictionary<int, Redpoint>();
    public Dictionary<uint, int> getRechareDic = new Dictionary<uint, int>();
    public const int redpointID = 20936;    
    public Redpoint redpoint = new Redpoint(MainRedDot.REDPOINT_OPENSERVER, redpointID);
    public List<int> rechargeList = new List<int>(); //活动可参与的充值档次
    public bool IsEnd = false;
    public uint playerRecharges  = 0;   // 活动已累计充值RMB
    uint playerAwardState = 0; // 达标奖励记录,与达标奖励索引位或运算判断是否已领取
    public List<HC007_tagGCCrossBillboardInfo.tagGCCrossBillboardData> CrossBillboardDataList  = new List<HC007_tagGCCrossBillboardInfo.tagGCCrossBillboardData>();
 
    public int RankIndex;
    public List<ServerType> serverTypeList = new List<ServerType>();
    protected override void Init()
    {
        activity = new ILOpenServerActivityProxy(IsOpen, IsAdvance, priorityOpen);
        OpenServerActivityCenter.Instance.Register(activityID, activity, activityType);
 
        GameEvent.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize;
        ILOperationTimeHepler.Instance.operationTimeUpdateEvent += operationTimeUpdateEvent;
    }
 
    protected override void UnInit()
    {
        GameEvent.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitialize;
        ILOperationTimeHepler.Instance.operationTimeUpdateEvent -= operationTimeUpdateEvent;
    }
 
    public bool IsOpen()
    {
        return OperationTimeHepler.Instance.SatisfyOpenCondition(operationType) && !IsEnd;
    }
 
    public bool IsAdvance()
    {
        return false;
    }
 
    public bool priorityOpen()
    {
        //红点
        return redpoint.state == RedPointState.Simple;
    }
 
 
    public void OnPlayerLoginOk()
    {
        
    }
 
    //跨服充值排行活动玩家信息
    public void UpdateCSRechargePlayerInfo(IL_HAA33_tagMCCACTGBillboardPlayerInfo package)
    {
        OperationBase operationBase;
        if (!OperationTimeHepler.Instance.TryGetOperationTime(operationType, out operationBase))
        {
            return;
        }
        //OperationCSRecharge operation = operationBase as OperationCSRecharge;        
 
        playerRecharges = package.CTGRMBTotal;
        playerAwardState = package.DabiaoAwardRecord;
 
        UpdateRedpoint();
 
        onRechargeInfoUpdate?.Invoke();
 
        //SendViewCrossBillboard();
    }
    // 跨服运营活动结束
    public void UpdateCSActEnd(IL_HAC12_tagGCCrossActEnd package)
    {
        IsEnd = true;
    }
    public void OnBeforePlayerDataInitialize()
    {
        CrossBillboardDataList.Clear();
        rechargeList.Clear();
        getRechareDic.Clear();
 
    }
 
    //跨服排行榜信息
    public void UpdateCSBillboardInfo(HC007_tagGCCrossBillboardInfo package)
    {
        if (package.Type != 150)
            return;
        CrossBillboardDataList.Clear();
        RankIndex = -1;
        for(int i= 0;i < package.BillboardCount;i++)
        {
            if (PlayerDatas.Instance.baseData.PlayerID == package.CrossBillboardDataList[i].ID)
                RankIndex = i + 1;
            CrossBillboardDataList.Add(package.CrossBillboardDataList[i]);
        }
        UpdatePlayerBillboardEvent?.Invoke();
 
    }
    private void operationTimeUpdateEvent(Operation type)
    {
        if (type == operationType)
        {
            OperationBase operationBase;
            if (!OperationTimeHepler.Instance.TryGetOperationTime(operationType, out operationBase))
            {
                return;
            }
            OperationCSRecharge operation = operationBase as OperationCSRecharge;
 
            //用于排版和红点
            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 void ParseServerName(string json)
    {
        var itemArray = LitJson.JsonMapper.ToObject<int[][]>(json);
        if (itemArray != null)
        {            
            for (int i = 0; i < itemArray.Length; i++)
            {
                var item = itemArray[i];
 
                int id1 = 0;
                int.TryParse(item[0].ToString(), out id1);
                int id2 = 0;
                int.TryParse(item[1].ToString(), out id2);
 
                var serverType = new ServerType();
                serverType.server1 = id1;
                serverType.server2 = id2;
                serverTypeList.Add(serverType);
            }
        }
    }
 
    //获取档位状态 0未达成,1可领取,2已领取
    public int GetRechargeStateByIndex(int index,int AwardIndex)
    {
        if (rechargeList[index] > playerRecharges)
            return 0;
 
        //每个数按位存31个激活索引
        //var listIndex = AwardIndex / 31;
        var bitIndex = AwardIndex % 31;
        if (((int)Math.Pow(2, bitIndex) & playerAwardState) == 0)
        {
            return 1;
        }
 
        return 2;
    }
 
    void UpdateRedpoint()
    {
        OperationBase operationBase;
        if (!OperationTimeHepler.Instance.TryGetOperationTime(operationType, out operationBase))
        {
            return;
        }
        OperationCSRecharge operation = operationBase as OperationCSRecharge;
 
        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]];
            int result = GetRechargeStateByIndex(i, rechargeList.AwardIndex);
            if (getRechareDic.ContainsKey(rechargeList.NeedRMB))
            {
                result =getRechareDic[rechargeList.NeedRMB];
            }
            if (result == 1)
            {
                titleRedpoints[keyList[i]].state = RedPointState.Simple;
            }
        }
    }
 
    //查看跨服排行榜
    public void SendViewCrossBillboard()
    {
        //OperationBase operationBase;
        //if (!OperationTimeHepler.Instance.TryGetOperationTime(CSRechargeModel.operationType, out operationBase))
        //{
        //    return;
        //}
        //OperationCSRecharge operation = operationBase as OperationCSRecharge;
        //var pak = new CC004_tagCGViewCrossBillboard();
        //pak.Type = 150;
        //pak.GroupValue1 = (byte)operation.GroupValue; // 活动榜单分组值1,用于查询对应榜单
        //GameNetSystem.Instance.SendInfo(pak);
    }
    //玩家领取奖励
    public void SendPlayerGetReward(uint RewardIndex)
    {
        var pak = new IL_CA504_tagCMPlayerGetReward();
        pak.RewardType = 36;
        pak.DataEx = RewardIndex; // 奖励索引
        GameNetSystem.Instance.SendInfo(pak);
    }
 
    public class ServerType
    {
        public int server1;
        public int server2;
    }
 
 
}