少年修仙传客户端代码仓库
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
using vnxbqy.UI;
using System;
using System.Collections.Generic;
using UnityEngine.UI;
using System.Linq;
using LitJson;
 
 
public class OnlineRechargeModel : ILModel<OnlineRechargeModel>
{
    public int changeSeconds;
    public int[] ctgArray;
    public int[][] awards;
    public int state;   //奖励是否已领取
    public Redpoint redpoint = new Redpoint(MainRedPoint.zxthRedPoint);
    public event Action updateEvent;
 
    public bool openyet = false;  //默认红点,打开界面消失
 
    VipModel vipModel { get { return ModelCenter.Instance.GetModelEx<VipModel>(); } }
 
    protected override void Init()
    {
        GameEvent.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize;
        vipModel.rechargeCountEvent += RechargeCountEvent;
        FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent;
        ParseConfig();
    }
    protected override void UnInit()
    {
        GameEvent.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitialize;
        vipModel.rechargeCountEvent -= RechargeCountEvent;
        FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent;
    }
 
    public void OnBeforePlayerDataInitialize()
    {
        state = 0;
    }
 
    public void ParseConfig()
    {
        var OnlineRechargeTH = FuncConfigConfig.Get("OnlineRechargeTH");
        changeSeconds = int.Parse(OnlineRechargeTH.Numerical1)*60;
 
 
        ctgArray = JsonMapper.ToObject<int[]>(OnlineRechargeTH.Numerical2);
        awards = JsonMapper.ToObject<int[][]>(OnlineRechargeTH.Numerical3);
    }
 
    
    public void GetAward()
    {
        var SendInfo = new CA504_tagCMPlayerGetReward();
        SendInfo.RewardType = 44;
        GameNetSystem.Instance.SendInfo(SendInfo);
    }
 
    
 
    //奖励领取后关闭
    public bool IsOpen()
    {
        if (!FuncOpen.Instance.IsFuncOpen(193))
        {
            return false;
        }
        if (state == 1)
        {
            return false;
        }
        return true;
    }
 
 
    // c#底层调用 是否在底部显示
    public bool IsBottomButtonOpen()
    {
        bool isbuy = false;
        VipModel.RechargeCount rechargeCount;
        for (int i = 0; i < ctgArray.Length; i++)
        {
            if (vipModel.TryGetRechargeCount(ctgArray[i], out rechargeCount))
            {
                if (rechargeCount.totalCount > 0)
                {
                    isbuy = true;
                    break;
                }
            }
        }
        if (!isbuy)
        {
            if (IL_DTCA109_tagMCOnLineTimeTotal.onlineSeconds < changeSeconds)
            {
                return true;
            }
            else
            {
                //限时降价后 点击一次才消失
                if (!LocalSave.GetBool(StringUtility.Contact(PlayerDatas.Instance.PlayerId, "zxth15"), false))
                {
                    return true;
                }
            }
        }
        return false;
    }
 
 
    public void UpdateRedpoint()
    {
        redpoint.state = RedPointState.None;
        if (!IsOpen()) return;
        if (!openyet)
        { 
            //未打开界面 默认红点
            redpoint.state = RedPointState.Simple;
            return;
        }
        
        //未领取
        VipModel.RechargeCount rechargeCount;
        for (int i = 0; i < ctgArray.Length; i++) 
        {
            if (vipModel.TryGetRechargeCount(ctgArray[i], out rechargeCount))
            {
                if (rechargeCount.totalCount > 0)
                {
                    redpoint.state = RedPointState.Simple;
                    break;
                }
            }
        }
 
    }
 
    public void UpdateState(IL_HAA04_tagMCOnlineRechargeTH pack)
    {
        state = pack.AwardState;
        updateEvent?.Invoke();
        UpdateRedpoint();
    }
 
    private void RechargeCountEvent(int id)
    {
        if (ctgArray.Contains(id))
        {
            UpdateRedpoint();
            updateEvent?.Invoke();
        }
    }
 
    private void OnFuncStateChangeEvent(int id)
    {
        if (id == 193)
        {
            UpdateRedpoint();
        }
    }
}