少年修仙传客户端代码仓库
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
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
using System;
using System.Collections;
using System.Collections.Generic;
 
using UnityEngine;
namespace vnxbqy.UI
{
    
    public class OSGiftModel : Model, IPlayerLoginOk, IBeforePlayerDataInitialize, IOpenServerActivity
    {
        VipModel vipModel
        {
            get { return ModelCenter.Instance.GetModel<VipModel>(); }
        }
 
        PetModel petModel
        {
            get { return ModelCenter.Instance.GetModel<PetModel>(); }
        }
 
        public override void Init()
        {
            ParseConfig();
            vipModel.rechargeCountEvent += RechargeCountEvent;
            FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent;
            OpenServerActivityCenter.Instance.Register(6, this);
        }
 
        public override void UnInit()
        {
            vipModel.rechargeCountEvent -= RechargeCountEvent;
            FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent;
        }
 
        public void OnBeforePlayerDataInitialize()
        {
        }
 
        public void OnPlayerLoginOk()
        {
            if (onStateUpdate != null)
            {
                onStateUpdate(6);
            }
            UpdateRedpoint();
        }
 
        public event Action<int> onStateUpdate;
        public event Action onSelectUpdate;
 
        public bool IsOpen
        {
            get
            {
                return ExistAnyGift();
            }
        }
 
        public bool priorityOpen
        {
            get
            {
                for (int i = 0; i < redpoints.Count; i++)
                {
                    if (redpoints[i].state == RedPointState.Simple)
                    {
                        return true;
                    }
                }
                return false;
            }
        }
 
        public bool IsAdvance
        {
            get
            {
                return false;
            }
        }
 
        int m_SelectIndex = 0;
        public int selectIndex
        {
            get { return m_SelectIndex; }
            set
            {
                if (value != m_SelectIndex)
                {
                    m_SelectIndex = value;
                    if (onSelectUpdate != null)
                    {
                        onSelectUpdate();
                    }
                }
                m_SelectIndex = value;
            }
        }
 
        public int jumpGiftId { get; set; }
 
        public List<SuperValueGift> gifts { get; private set; }
        public List<int> alreadyOpens { get; private set; }
        public SkillActivePoint skillActivePoint { get; private set; }
        void ParseConfig()
        {
            gifts = new List<SuperValueGift>();
            alreadyOpens = new List<int>();
            var config = FuncConfigConfig.Get("SuperGiftTimeList");
            var array = LitJson.JsonMapper.ToObject<int[][]>(config.Numerical1);
            for (int i = 0; i < array.Length; i++)
            {
                gifts.Add(new SuperValueGift()
                {
                    payType = array[i][0],
                    functionId = array[i][1],
                });
            }
 
            for (int i = 0; i < gifts.Count; i++)
            {
                redpoints.Add(new Redpoint(MainRedDot.REDPOINT_OPENSERVER, 20906 * 100 + i));
            }
 
            config = FuncConfigConfig.Get("ImmortalDomainActivePoint");
            var skillArray = LitJson.JsonMapper.ToObject<int[]>(config.Numerical4);
            skillActivePoint = new SkillActivePoint()
            {
                skillId = skillArray[0],
                levelArea = skillArray[1],
                upperPoint = skillArray[2],
                limit = skillArray[3],
            };
        }
 
        private void RechargeCountEvent(int id)
        {
            UpdateRedpoint();
        }
 
        private void OnFuncStateChangeEvent(int id)
        {
            foreach (var gift in gifts)
            {
                if (gift.functionId == id)
                {
                    if(onStateUpdate != null)
                    {
                        onStateUpdate(6);
                    }
                    UpdateRedpoint();
                    break;
                }
            }
        }
 
        public bool ExistAnyGift()
        {
            for (int i = 0; i < gifts.Count; i++)
            {
                if (!IsGiftExist(gifts[i].payType))
                {
                    continue;
                }
                return true;
            }
            return false;
        }
 
        public bool IsGiftExist(int payType)
        {
            if (IsGiftAlreadyBuy(payType))
            {
                return false;
            }
            var gift = gifts.Find((x) =>
            {
                return x.payType == payType;
            });
            if (!gift.Equals(default(SuperValueGift)))
            {
                return FuncOpen.Instance.IsFuncOpen(gift.functionId);
            }
            return false;
        }
 
        public bool IsGiftAlreadyBuy(int payType)
        {
            var rechargeId = GetRechargeId(payType);
            if (rechargeId != 0)
            {
                VipModel.RechargeCount rechargeCount;
                if (vipModel.TryGetRechargeCount(rechargeId, out rechargeCount))
                {
                    var rechargeConfig = CTGConfig.Get(rechargeId);
                    return rechargeCount.totalCount >= rechargeConfig.TotalBuyCount;
                }
            }
            return false;
        }
 
        public void DisplayErrorRemind(int payType)
        {
            var gift = gifts.Find((x) =>
            {
                return x.payType == payType;
            });
            if (!gift.Equals(default(SuperValueGift)))
            {
                FuncOpen.Instance.ProcessorFuncErrorTip(gift.functionId);
            }
        }
 
        public int GetRechargeId(int payType)
        {
            var list = vipModel.GetCTGConfigs(VersionConfig.Get().appId);
            if (list != null)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    var config = CTGConfig.Get(list[i]);
                    if (config != null && config.PayType == payType)
                    {
                        return config.RecordID;
                    }
                }
            }
            return 0;
        }
 
        public void SetAreadyOpens()
        {
            alreadyOpens.Clear();
            for (int i = 0; i < gifts.Count; i++)
            {
                if (IsGiftExist(gifts[i].payType))
                {
                    alreadyOpens.Add(i);
                }
            }
        }
 
        public int GetDefaultSelect()
        {
            for (int i = 0; i < alreadyOpens.Count; i++)
            {
                if (gifts[alreadyOpens[i]].payType == jumpGiftId)
                {
                    jumpGiftId = 0;
                    return alreadyOpens[i];
                }
            }
            jumpGiftId = 0;
            for (int i = 0; i < alreadyOpens.Count; i++)
            {
                if (redpoints[alreadyOpens[i]].state == RedPointState.Simple)
                {
                    return alreadyOpens[i];
                }
            }
            return alreadyOpens[0];
        }
 
        bool GetDayRemind(int index)
        {
            return LocalSave.GetInt(StringUtility.Contact("OSGift_", index, "_",
                PlayerDatas.Instance.baseData.PlayerID), 0) == TimeUtility.Day;
        }
 
        public void SetDayRemind(int index)
        {
            if (redpoints[index].state == RedPointState.Simple)
            {
                LocalSave.SetInt(StringUtility.Contact("OSGift_", index, "_",
                       PlayerDatas.Instance.baseData.PlayerID), TimeUtility.Day);
                UpdateRedpoint();
            }
        }
 
        public void GetPetInfo(out int petId, out int level)
        {
            petId = 0;
            level = petModel.GetSkillUnlockLevel(skillActivePoint.skillId);
            petModel.TryGetPetId(skillActivePoint.skillId, out petId);
        }
 
        public int GetSkillActivePoint(int level)
        {
            var totalPoint = 0;
 
            var step = level / skillActivePoint.levelArea;
            var maxLevel = step * skillActivePoint.levelArea;
            for (int i = 0; i < step; i++)
            {
                var levels = i == 0 ? (skillActivePoint.levelArea - 1) : skillActivePoint.levelArea;
                var point = Mathf.Min(skillActivePoint.limit, (i + 1) * skillActivePoint.upperPoint);
                totalPoint += point * levels;
            }
 
            {
                var point = Mathf.Min(skillActivePoint.limit, (step + 1) * skillActivePoint.upperPoint);
                var levels = level - maxLevel;
                if (maxLevel == 0)
                {
                    levels -= 1;
                }
                totalPoint += Mathf.Max(0, levels) * point;
            }
 
            return totalPoint;
        }
 
        List<Redpoint> redpoints = new List<Redpoint>();
 
        void UpdateRedpoint()
        {
            for (int i = 0; i < redpoints.Count; i++)
            {
                redpoints[i].state = RedPointState.None;
                if (IsGiftExist(gifts[i].payType) && !IsGiftAlreadyBuy(gifts[i].payType)
                    && !GetDayRemind(i))
                {
                    redpoints[i].state = RedPointState.Simple;
                }
            }
        }
 
        public struct SuperValueGift
        {
            public int payType;
            public int functionId;
        }
 
        public struct SkillActivePoint
        {
            public int skillId;
            public int levelArea;
            public int upperPoint;
            public int limit;
        }
    }
}