少年修仙传客户端代码仓库
hch
2019-10-31 3c35f85432d317061f09c93319108de899469d55
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Wednesday, July 18, 2018
//--------------------------------------------------------
using Snxxz.UI;
using System;
using System.Collections.Generic;
using LitJson;
 
[XLua.LuaCallCSharp]
public class DayPackageItemClassModel : Model, IPlayerLoginOk, IOpenServerActivity
{
    int m_SelectIndex = 0;
    VipModel vipModel
    {
        get { return ModelCenter.Instance.GetModel<VipModel>(); }
    }
 
    public int selectIndex
    {
        get { return m_SelectIndex; }
        set
        {
            if (m_SelectIndex != value)
            {
                m_SelectIndex = value;
                if (selectUpdate != null)
                {
                    selectUpdate(value);
                }
            }
        }
    }
 
    public class DayGift
    {
        public string title; // 礼包名
        public int getCount; // 已获得次数
        public int[][] items;
        public int money;
        public string orderInfo;
    }
 
 
    public int[] recordIDs;
    public Dictionary<int, DayGift> m_RechargeDict = new Dictionary<int, DayGift>();
    public event Action<int> selectUpdate;
 
    public event Action<int> onStateUpdate;
    public override void Init()
    {
        OpenServerActivityCenter.Instance.Register(23, this);
        recordIDs = ConfigParse.GetMultipleStr<int>(FuncConfigConfig.Get("DayFreeGoldGift").Numerical2);
        if (!m_RechargeDict.ContainsKey(0))
        {
            var _sortArray = JsonMapper.ToObject<int[][]>(FuncConfigConfig.Get("DayFreeGoldGift").Numerical1);
 
            foreach (int recordID in recordIDs)
            {
                if (recordID == 0)
                {
                    m_RechargeDict[recordID] = new DayGift()
                    {
                        title = "免费礼包",
                        items = _sortArray,
                        getCount = 0,
                        money = 0,
                    };
                }
                else
                {
                    var ctg = CTGConfig.Get(recordID);
                    OrderInfoConfig config;
                    vipModel.TryGetOrderInfo(recordID, out config);
                    m_RechargeDict[recordID] = new DayGift()
                    {
                        title = ctg.Title,
                        items = LitJson.JsonMapper.ToObject<int[][]>(ctg.GainItemList),
                        getCount = 0,
                        money = (int)config.PayRMBNum,
                        orderInfo = config.OrderInfo,
                    };
                }
            }
        }
    }
    private const int Redpoint_key1 = 20923;
    public Redpoint redPointStre1 = new Redpoint(209, Redpoint_key1); //每日免费礼包
    public bool IsOpen
    {
        get
        {
            return FuncOpen.Instance.IsFuncOpen(185);
        }
    }
 
    public bool priorityOpen
    {
        get
        {
            return redPointStre1.state == RedPointState.Simple || redPointStre1.state == RedPointState.GetReward;
        }
    }
 
    public bool IsAdvance
    {
        get
        {
            return false;
        }
    }
 
 
    public override void UnInit()
    {
 
    }
    public void OnPlayerLoginOk()
    {
        IsShowTip();
 
    }
 
    public DayGift GetDayGift(int index)
    {
        return m_RechargeDict[recordIDs[index]];
    }
 
 
    public void IsShowTip()
    {
        if (!FuncOpen.Instance.IsFuncOpen(185)) return;
 
        if (m_RechargeDict.ContainsKey(0) && m_RechargeDict[0].getCount == 0)
            redPointStre1.state = RedPointState.Simple;
        else
            redPointStre1.state = RedPointState.None;
 
    }
    public void UpdateRechargeCount(HA110_tagMCCoinToGoldCountInfo package)
    {
        for (int i = 0; i < package.RecordCount; i++)
        {
            var _data = package.CTGCountInfoList[i];
            if (m_RechargeDict.ContainsKey(_data.RecordID))
                m_RechargeDict[_data.RecordID].getCount = _data.TodayPayCount;
        }
        if (onStateUpdate != null) onStateUpdate(selectIndex);
    }
 
    public void FreeGoldGiftState(HAA24_tagMCDayFreeGoldGiftState package)
    {
 
        m_RechargeDict[0].getCount = package.DayFreeGoldGiftState;
        
        if (onStateUpdate != null) onStateUpdate(selectIndex);
 
        IsShowTip();
    }
 
    public void OpenFreePlat(string Title, float RMBNum, string OrderInfo)
    {
        if (!WindowCenter.Instance.IsOpen<GotoChargeWin>())
        {
            WindowCenter.Instance.Open<GotoChargeWin>(true);
        }
        SDKUtility.Instance.FreePlatformPay(Title, RMBNum, OrderInfo);
        //  DesignDebug.LogErrorFormat("礼包标题{0},所需金额{1},商品编号{2}", Title, RMBNum, OrderInfo);
    }
    public void RequestReward()
    {
        var sendInfo = new CA504_tagCMPlayerGetReward();
        sendInfo.RewardType = (int)GotServerRewardType.Def_RewardType_DayPackageFree;
        sendInfo.DataEx = 0;
        sendInfo.DataExStrLen = 0;
        sendInfo.DataExStr = string.Empty;
        GameNetSystem.Instance.SendInfo(sendInfo);
    }
 
 
}