少年修仙传客户端代码仓库
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Wednesday, July 18, 2018
//--------------------------------------------------------
using vnxbqy.UI;
using System;
using System.Collections.Generic;
 
 
public class HolidayLimitedTimePackageModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk, IOpenServerActivity
{
    Operation operationType = Operation.HolidayGiftPackage;
    int regesitType = 107;
 
    int m_SelectIndex = 0;
    public int selectIndex
    {
        get { return m_SelectIndex; }
        set
        {
            if (m_SelectIndex != value)
            {
                if (selectUpdate != null)
                {
                    selectUpdate(value);
                }
            }
            m_SelectIndex = value;
        }
    }
    public event Action<int> selectUpdate;
    public Dictionary<int, int> DicBuyPackage = new Dictionary<int, int>();
    public event Action UpdateLimitedTimePackageItem;
    public event Action<int> onStateUpdate;
    public override void Init()
    {
        OpenServerActivityCenter.Instance.Register(regesitType, this, (int)OpenServerActivityCenter.ActivityType.AT_JRZF);
        OperationTimeHepler.Instance.operationEndEvent += OperationEndEvent;
    }
    private const int Redpoint_key1 = 28007;
    public Redpoint redPointStre1 = new Redpoint(MainRedDot.RedPoint_HolidayWishes, Redpoint_key1);//限时礼包红点
    public bool IsOpen
    {
        get
        {
            return !IsExpired();
        }
    }
 
    public bool priorityOpen
    {
        get
        {
            return false;
        }
    }
 
    public bool IsAdvance
    {
        get
        {
            return OperationTimeHepler.Instance.SatisfyAdvanceCondition(operationType);
        }
    }
 
    public void OnBeforePlayerDataInitialize()
    {
        DicBuyPackage.Clear();
    }
    public override void UnInit()
    {
 
    }
    public void OnPlayerLoginOk()
    {
        OperationTimeHepler.Instance.operationStartEvent -= operationStartEvent;
        OperationTimeHepler.Instance.operationStartEvent += operationStartEvent;
        OperationTimeHepler.Instance.operationAdvanceEvent -= operationAdvanceEvent;
        OperationTimeHepler.Instance.operationAdvanceEvent += operationAdvanceEvent;
        IsShowTip();
 
    }
 
 
 
    private void operationStartEvent(Operation arg1, int arg2)
    {
        if (arg1 == operationType)
        {
            IsShowTip();
            if (arg2 == 0 && onStateUpdate != null)
            {
                onStateUpdate(regesitType);
            }
        }
    }
    private void operationAdvanceEvent(Operation obj)
    {
        if (obj == operationType)
        {
            // IsShowTip();
            if (onStateUpdate != null)
            {
                onStateUpdate(regesitType);
            }
        }
    }
    private void OperationEndEvent(Operation arg1, int arg2)
    {
        if (arg1 == operationType && arg2 == 0)
        {
            if (onStateUpdate != null)
            {
                onStateUpdate(regesitType);
            }
        }
    }
 
    public void IsShowTip()
    {
        if (OperationTimeHepler.Instance.SatisfyAdvanceCondition(operationType))
        {
            return;
        }
        int GetDayOfYear = DateTime.Now.DayOfYear;
        int day = LocalSave.GetInt("IsOpenLimitedTime");
        bool Isbool = !IsExpired();
        if (day != GetDayOfYear && !IsExpired())
        {
            //   LocalSave.SetInt("IsOpenLimitedTime", GetDayOfYear);
            redPointStre1.state = RedPointState.Simple;
        }
        else
        {
            redPointStre1.state = RedPointState.None;
        }
 
    }
    public void BuyCoutList(HAA13_tagMCFlashGiftbagPlayerInfo Info)
    {
        GiftPackageClass operation;
        if (!OperationTimeHepler.Instance.TryGetOperation(operationType, out operation))
        {
            return;
        }
        if (operation.ActNum != Info.ActNum)
        {
            return;
        }
        
        for (int i = 0; i < Info.Count; i++)
        {
            if (DicBuyPackage.ContainsKey((int)Info.BuyCountList[i].GiftbagID))
            {
                DicBuyPackage[(int)Info.BuyCountList[i].GiftbagID] = (int)Info.BuyCountList[i].BuyCount;
            }
            else
            {
                DicBuyPackage.Add((int)Info.BuyCountList[i].GiftbagID, (int)Info.BuyCountList[i].BuyCount);
            }
        }
        if (UpdateLimitedTimePackageItem != null)
        {
            UpdateLimitedTimePackageItem();
        }
        if (onStateUpdate != null)
        {
            onStateUpdate(regesitType);
        }
    }
 
    public bool IsExpired(int index = 0)
    {
        bool IsSatisfyAliveCondition = false;
        IsSatisfyAliveCondition = (OperationTimeHepler.Instance.SatisfyOpenCondition(operationType)
         || OperationTimeHepler.Instance.SatisfyAdvanceCondition(operationType));
        bool IsBuyBool = false;
        OperationBase operationBase;
        if (OperationTimeHepler.Instance.TryGetOperationTime(operationType, out operationBase))
        {
            GiftPackageClass operation = operationBase as GiftPackageClass;
            GiftPackageClass.Gift_Package gift;
            if (operation.TryGetGift(TimeUtility.ServerNow, out gift))
            {
                if (gift.gifts.Length > 0)
                {
                    int BuyCountLimit = gift.gifts[index].limitNum;//限购数量
                    int GiftID = gift.gifts[index].id;//礼包ID
                    if (DicBuyPackage.ContainsKey(GiftID) && DicBuyPackage[GiftID] >= BuyCountLimit)
                    {
                        IsBuyBool = true;
                    }
                }
            }
        }
        if (IsSatisfyAliveCondition)
        {
            return false;
        }
        else
        {
            return true;
        }
    }
 
}