少年修仙传客户端代码仓库
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
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using LitJson;
using UnityEngine;
namespace vnxbqy.UI
{
    public class FullServerRechargeRedpackModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk, IOpenServerActivity
    {
        RedPacketModel redbagModel { get { return ModelCenter.Instance.GetModel<RedPacketModel>(); } }
 
        //全服充值红包类型
        public const int FullServer_Recharge_Redpack = 36;
        public const int ActivityType = 34;
        const int REDPOINTID = 20934;
        public readonly Redpoint redpoint = new Redpoint(MainRedDot.REDPOINT_OPENSERVER, REDPOINTID);
        public event Action<int> onStateUpdate;
        public Dictionary<int, int> vipRedpackCount = new Dictionary<int, int>();
        public bool hasQFRedbag = false;//可领红包
 
        public override void Init()
        {
            redbagModel.RedbagRefresh += RedEnvelopeToRefresh;//红包的刷新
            redbagModel.ServerGrabCntEvent += ServerGrabCntEvent;
            ParseConfig();
            OpenServerActivityCenter.Instance.Register(ActivityType, this);
        }
 
        public bool IsOpen
        {
            get
            {
                return FuncOpen.Instance.IsClientLVLimit(1);
            }
        }
 
        public bool IsAdvance { get { return false; } }
        public bool priorityOpen { get { return redpoint.state == RedPointState.Simple; } }
 
        
        public void OnBeforePlayerDataInitialize()
        {
            hasQFRedbag = false;
        }
 
        public void OnPlayerLoginOk()
        {
 
        }
 
        public override void UnInit()
        {
 
        }
 
        void ParseConfig()
        {
            vipRedpackCount.Clear();
            var config = JsonMapper.ToObject(FuncConfigConfig.Get("RechargeRedPacket").Numerical3);
            foreach (var key in config.Keys)
            {
                vipRedpackCount[int.Parse(key)] = int.Parse(config[key].ToString());
            }
 
        }
 
        //全服充值红包的可开启次数, 0代表无限制
        public int GetMaxOpenRedpackCount()
        {
            var keyList = vipRedpackCount.Keys.ToList();
            keyList.Sort();
            var viplv = PlayerDatas.Instance.baseData.VIPLv;
            foreach (var key in keyList)
            {
                if (viplv <= key)
                {
                    return vipRedpackCount[key];
                }
            }
 
            return 0;
        }
 
        void RedEnvelopeToRefresh()//红包的刷新
        {
            ServerGrabCntEvent();
        }
 
        //hasQFRedbag: 可抢个数,已领完,已领取
        public void ServerGrabCntEvent()
        {
            hasQFRedbag = false;
            int maxCnt = GetMaxOpenRedpackCount();
            foreach (int key in redbagModel._DicRedBag.Keys)
            {
                if (!redbagModel.IsDisplayRechargeTH(redbagModel._DicRedBag[key]))
                {
                    continue;
                }
 
                if (redbagModel._DicRedBag[key].State == 1)
                {
                    if ((maxCnt == 0 || maxCnt > redbagModel.ServerGrabCnt) && IsOpen)
                    {
                        hasQFRedbag = true;
                        break;
                    }
 
                }
            }
            UpdateRedPoint();
        }
 
        void UpdateRedPoint()
        {
            redpoint.state = RedPointState.None;
            if (!IsOpen)
                return;
 
            int maxCnt = GetMaxOpenRedpackCount();
            foreach (int key in redbagModel._DicRedBag.Keys)
            {
                if (!redbagModel.IsDisplayRechargeTH(redbagModel._DicRedBag[key]))
                {
                    continue;
                }
                if (redbagModel._DicRedBag[key].State == 0 || hasQFRedbag)
                {
                    redpoint.state = RedPointState.Simple;
                    break;
                }
            }
        }
    }
}