少年修仙传客户端代码仓库
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Friday, January 12, 2018
//--------------------------------------------------------
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System;
 
using System.Collections.Generic;
 
namespace vnxbqy.UI
{
    public class ResourcesBackClass
    {
        public int ID;//ID 
        public int RecoverCnt;// 可找回次数
        public int ExtraCnt;// VIP额外次数
        public string NameOfActivity;//活动名称
        public int RelatedID;//关联日常任务表ID
        public int CanBackTimes;//能否找回次数
        public int NormalCostJade;//绑玉找回普通次数价格
        public int VipCostJade;//绑玉找回VIP次数找回价格
        public RewardRecovery JadeReward;//绑玉找回奖励
        public int CostCopper; //铜钱找回铜钱消耗
        public RewardRecovery CopperReward;//铜钱找回奖励
        public int ExtraData;//额外参数
        public int ExtraData2;//额外参数2
        public string[] RewardList;//奖励列表
        public ulong TjgExp;//经验(脱机挂)
        public int Times;//可找回时间
        public string DeadTime;//死亡时间
        public List<int> ReplaceItemID;//替换的物品ID
        public byte HaveRecover;        // 已找回 1-全部已找回 2-非VIP已找回
    }
    public class RewardRecovery
    {
        public string exp;
        public string money;
        public ItemModelResourcesBack[] item;
    }
 
    public class ItemModelResourcesBack
    {
        public int ItemID;
        public string ItemCount;
    }
    public struct FairyJadeFindOneKey//一键找回(仙玉)
    {
        public int Index { get; set; }
        public int Number { get; set; }
        public int FairyJade { get; set; }
        public int IsOn { get; set; }
    }
 
    public struct CopperCashFindOneKey//一键找回(铜钱)
    {
        public int Index { get; set; }
        public int Number { get; set; }
        public int CopperCash { get; set; }
        public int IsOn { get; set; }
 
    }
    public enum ResourcesBackEnum
    {
        exp,
        money,
        item,
        sp,
    }
    
    public class ResourcesBackModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk
    {
 
        public Dictionary<int, ResourcesBackClass> ResourcesBackDic = new Dictionary<int, ResourcesBackClass>();
 
        public static Action ResourcesBackUpdateEvent;
        public int ResourcesBackId = 0;//用来标记所选的找回资源ID
        const int RESOURCESBACK = 78003;
        const int RESOURCESBACK_1 = 780031;
        public Redpoint redPointStre1 = new Redpoint(78000, RESOURCESBACK);//资源找回红点
        public Redpoint redPointStre2 = new Redpoint(RESOURCESBACK, RESOURCESBACK_1);//资源找回红点
        public bool IsPointStre = true;//是否显示红点
        public bool IsMainGo = false;//是否显示主界面入口
        public override void Init()
        {
            ResourcesBackWin.IsAccordingRedPoint += IsAccordingRedPoint;
 
 
        }
        public override void UnInit()
        {
            ResourcesBackWin.IsAccordingRedPoint -= IsAccordingRedPoint;
        }
 
        private void IsAccordingRedPoint()
        {
            IsPointStre = false;
            IsMainGo = false;
            ResourcesBackRedPoint();
        }
 
        public void OnBeforePlayerDataInitialize()
        {
          //  IsPointStre = true;
            IsMainGo = false;
            ResourcesBackDic.Clear();
        }
        public void OnPlayerLoginOk()
        {
            ResourcesBackRedPoint();
            if (ResourcesBackUpdateEvent != null)
            {
                ResourcesBackUpdateEvent();
            }
        }
        
       
 
 
        private void ResourcesBackRedPoint()//资源找回红点
        {
            redPointStre2.state = RedPointState.None;
            IsMainGo = false;
 
            if (IsPointStre && ResourcesBackDic.Count > 0)
            {
                foreach (var key in ResourcesBackDic.Keys)
                {
                    if (ResourcesBackDic[key].RecoverCnt > 0)
                    {
                        redPointStre2.state = RedPointState.Simple;
                        IsMainGo = true;
                        return;
                    }
                }
            }
        }
 
        List<int> ResourcesIdList = new List<int>();
        public void ResourcesBackAcceptance(HA349_tagMCRecoverNum vNetData)
        {
            ResourcesIdList.Clear();
            foreach (var key in ResourcesBackDic.Keys)
            {
                if (key != 1)
                {
                    ResourcesIdList.Add(key);
                }
            }
            for (int i = 0; i < ResourcesIdList.Count; i++)
            {
                if (ResourcesBackDic.ContainsKey(ResourcesIdList[i]))
                {
                    ResourcesBackDic.Remove(ResourcesIdList[i]);
                }              
            }
            // ResourcesBackDic.Clear();
            for (int i = 0; i < vNetData.NumInfo.Length; i++)
            {
                int id = vNetData.NumInfo[i].Index;
 
                if (id == 1)
                {
                    continue;
                }
                if (ResourcesBackDic.ContainsKey(id))
                {
                    var resourcesBackDic = ResourcesBackDic[id];
                    resourcesBackDic.RecoverCnt = vNetData.NumInfo[i].RecoverCnt;
                    resourcesBackDic.ExtraCnt = vNetData.NumInfo[i].ExtraCnt;
                    resourcesBackDic.ExtraData = vNetData.NumInfo[i].ExtraData;
                    resourcesBackDic.ExtraData2 = vNetData.NumInfo[i].ExtraData2;
                    resourcesBackDic.HaveRecover = vNetData.NumInfo[i].HaveRecover;
                }
                else
                {
                    var configRB = ResourcesBackConfig.Get(id);//资源找回表
 
                    ResourcesBackClass resourcesBackClass = new ResourcesBackClass();
                    resourcesBackClass.ID = id;
                    resourcesBackClass.RecoverCnt = vNetData.NumInfo[i].RecoverCnt;
                    resourcesBackClass.ExtraCnt = vNetData.NumInfo[i].ExtraCnt;
                    resourcesBackClass.ExtraData = vNetData.NumInfo[i].ExtraData;
                    resourcesBackClass.ExtraData2 = vNetData.NumInfo[i].ExtraData2;
                    resourcesBackClass.RelatedID = configRB.RelatedID;
                    var configDQC = DailyQuestConfig.Get(configRB.RelatedID);//日常任务表
                    resourcesBackClass.NameOfActivity = configDQC.Title;
                    resourcesBackClass.CanBackTimes = configRB.CanBackTimes;
                    resourcesBackClass.NormalCostJade = configRB.NormalCostJade;
                    resourcesBackClass.VipCostJade = configRB.VipCostJade;
                    resourcesBackClass.JadeReward = LitJson.JsonMapper.ToObject<RewardRecovery>(configRB.JadeReward);
                    resourcesBackClass.CostCopper = configRB.CostCopper;
                    resourcesBackClass.CopperReward = LitJson.JsonMapper.ToObject<RewardRecovery>(configRB.CopperReward);
                    resourcesBackClass.RewardList = ConfigParse.GetMultipleStr(configRB.RewardList);
                    resourcesBackClass.ReplaceItemID = ReplaceItemID(configRB.JobItem);
                    resourcesBackClass.HaveRecover = vNetData.NumInfo[i].HaveRecover;
                    ResourcesBackDic.Add(id, resourcesBackClass);
                }
            }
            ResourcesBackRedPoint();
            if (ResourcesBackUpdateEvent != null)
            {
                ResourcesBackUpdateEvent();
            }
        }
 
        private List<int> ReplaceItemID(string str)
        {
            List<int> list = new List<int>();
            if (str == string.Empty)
            {
                return list;
            }
            var _jsonData = LitJson.JsonMapper.ToObject(str);
            for (int i = 0; i < _jsonData.Count; i++)
            {
                list.Add(int.Parse(_jsonData[i][0].ToString()));
                list.Add(int.Parse(_jsonData[i][1].ToString()));
            }
            return list;
        }
    }
 
}