少年修仙传客户端代码仓库
client_Wu Xijin
2019-06-13 033958214c0b16d7e7b93cc821b018c295251867
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Tuesday, October 31, 2017
//--------------------------------------------------------
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
 
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using Snxxz.UI;
using System;
//赏金任务面板
namespace Snxxz.UI
{
 
    public class CoinTaskWin : MonoBehaviour
    {
 
        [SerializeField] Text m_AwardNumbertext;
        [SerializeField] Image m_Btn_Receive;//领取按钮
        [SerializeField] UIEffect m_uiEffct1;//特效播放
        [Header("滚动速度")]
        public double RollingSpeed = 0.1f;
        [SerializeField] Text _Text_TaskCount;//任务次数
        [SerializeField] RichText _Text_TaskTarget;//任务目标
        [SerializeField] Transform _Grid;//任务奖励
        [SerializeField] Button _Btn_Finish;//立即完成按钮
 
        [SerializeField] Button _Btn_Forward;//立即前往按钮
 
        [SerializeField] Button _Btn_Receive;//领取奖励按钮
 
        [SerializeField] Text Text_TaskCount2;//当前总环数
 
        [SerializeField] Text m_Text_Forward;
 
        [Header("等待时间(秒)")]
        public int Second = 20;
        private float timeType = 0f;
 
 
        private List<RewardAnalysis.RewardInfo> rewardList = new List<RewardAnalysis.RewardInfo>();
        private Dictionary<int, MissionDetailDates> _BountyDic;//赏金任务
 
        private Dictionary<int, int> RunTaskCnt1 = new Dictionary<int, int>();//关于跑环环数的记录1
        private Dictionary<int, int> RunTaskCnt2 = new Dictionary<int, int>();//关于跑环环数的记录2
 
        private int TaskID = 0;//获取任务ID
 
        int Value = -1;
        int Default = 0;
        private float lastTime1 = 0;
        private int Length = 7;//所需长度
        private int _requireNumber = 0;//直接完成所需仙玉数量
        StringBuilder theTarget = new StringBuilder();//目标值
        StringBuilder variation = new StringBuilder();//变化值
 
        private int RewardForNumber = 0;//奖励数值
        TaskModel m_TaskModel;
        TaskModel taskmodel { get { return m_TaskModel ?? (m_TaskModel = ModelCenter.Instance.GetModel<TaskModel>()); } }
 
        PlayerMainDate m_MainModel;
        PlayerMainDate mainModel { get { return m_MainModel ?? (m_MainModel = ModelCenter.Instance.GetModel<PlayerMainDate>()); } }
 
        CoinTaskTipModel m_CoinTaskTip;
        CoinTaskTipModel coinTaskTip { get { return m_CoinTaskTip ?? (m_CoinTaskTip = ModelCenter.Instance.GetModel<CoinTaskTipModel>()); } }
        private void Awake()
        {
            string _requireNumberStr = FuncConfigConfig.Get("TaskExpend").Numerical1;
            var RunTaskCntStr = FuncConfigConfig.Get("RunTaskCnt");
            RunTaskCnt1 = ConfigParse.GetDic<int, int>(RunTaskCntStr.Numerical1);
            RunTaskCnt2 = ConfigParse.GetDic<int, int>(RunTaskCntStr.Numerical2);
            _requireNumber = int.Parse(_requireNumberStr);
        }
        private void Start()
        {
            _Btn_Finish.AddListener(Finish);
            _Btn_Forward.AddListener(Forward);
            _Btn_Receive.AddListener(Receive);
        }
        private void OnEnable()
        {
            lastTime1 = 0;
            timeType = 0;
            RewardForNumber = taskmodel.BountyRewardsNumber;
            RewardFor();
            TaskModel.Event_nBounty += OnBounty;//赏金任务添加
            TaskModel.Event_BountyRewards += BountyRewards;//获取赏金奖励
            _BountyDic = taskmodel.BountyDic;
            RewardsToOpen();
            ContentAssignment();
            int GetCylinderNumber = TaskAllocation.Instance.ForRingAllNumber();//获取赏金总环数
            if (coinTaskTip.IsPopup && GetCylinderNumber == 10)
            {
                m_Text_Forward.text = string.Format(Language.Get("TaskContinueCount_1"), Second);
            }
            else
            {
                m_Text_Forward.text = Language.Get("TaskBoxWin_BtnGetReward_Text_1");
            }
        }
 
        private void OnDisable()
        {
            TaskModel.Event_nBounty -= OnBounty;
            TaskModel.Event_BountyRewards -= BountyRewards;
            taskmodel.BountyMotionBool = false;
            if (coinTaskTip.IsPopup)
            {
                coinTaskTip.IsPopup = false;
            }
        }
 
        void RewardFor()//奖励默认金
        {
            if (RewardForNumber != 0)
            {
                theTarget.Length = 0;
                theTarget.Append('0', 7 - RewardForNumber.ToString().Length);
                theTarget.Append(RewardForNumber);
                m_AwardNumbertext.text = theTarget.ToString();
            }
            else
            {
                m_AwardNumbertext.text = "0000000";
            }
        }
 
        void Finish()
        {
            if (CrossServerUtility.IsCrossServerBoss())
            {
                SysNotifyMgr.Instance.ShowTip("CrossMap10");
                return;
            }
            if (mainModel.IsBoolCoinTask)
            {
                AccomplishTask();
            }
            else
            {
                ConfirmCancel.ToggleConfirmCancel(Language.Get("MoneyReward_Task"), Language.Get("Accomplish_Task"), Language.Get("ConfirmCancel101"), (bool isOk, bool IsToggle) =>
                {
                    if (isOk)
 
                    {
                        AccomplishTask();
                    }
                    if (IsToggle)
                    {
                        mainModel.IsBoolCoinTask = true;
                    }
                });
            }
        }
 
        void AccomplishTask()
        {
 
            if ((int)UIHelper.GetMoneyCnt(1) >= _requireNumber )
            {
                taskmodel.CompletionOfTask(TaskID);
                taskmodel.BountyMotionBool = true;
            }
            else
            {
                if (VersionConfig.Get().isBanShu)
                {
                    SysNotifyMgr.Instance.ShowTip("GoldErr");
                    return;
                }
                WindowCenter.Instance.Open<RechargeTipWin>();
            }
        }
 
        void RewardsToOpen()//奖励按钮打开
        {
            if (TaskAllocation.Instance.ForRingNumber() == RunTaskCnt2[7])
            {
 
                m_Btn_Receive.SetSprite("ReceiveBG_a");
                _Btn_Receive.gameObject.SetActive(true);
 
            }
            else
            {
                m_Btn_Receive.SetSprite("UnReceiveBG");
                _Btn_Receive.gameObject.SetActive(false);
 
            }
        }
        void Receive()//领取奖励
        {
            CA221_tagCMGetRunTaskEndAward _CA221 = new CA221_tagCMGetRunTaskEndAward();
            _CA221.Type = 7;
            GameNetSystem.Instance.SendInfo(_CA221);
            if (coinTaskTip.IsPopup)
            {
                coinTaskTip.IsPopup = false;
            }
        }
 
 
        void BountyRewards(int Number, int _AwardState)
        {
            if (Number == 0)
            {
                m_AwardNumbertext.text = "0000000";
            }
            else
            {
                if (!m_uiEffct1.IsPlaying)
                {
                    m_uiEffct1.Play();
                }
 
                RewardForNumber = Number;
                Value = Length - 1;
                Default = 0;
                int length = 0;
                length = RewardForNumber.ToString().Length;
                theTarget.Length = 0;
                theTarget.Append('0', Length - length);
                theTarget.Append(RewardForNumber);
                theTarget.ToString();
                variation.Length = 0;
                variation.Append('0', Length);
            }
        }
 
        private void LateUpdate()
        {
            if (coinTaskTip.IsPopup)
            {
                int GetCylinderNumber = TaskAllocation.Instance.ForRingAllNumber();//获取赏金总环数
                timeType += Time.deltaTime;
                if (Second >= timeType)
                {
                    m_Text_Forward.text = string.Format(Language.Get("TaskContinueCount_1"), Second - (int)timeType);
                }
                else
                {
                    m_Text_Forward.text = string.Format(Language.Get("TaskContinueCount_1"), 0);
                }
                if (timeType >= Second && GetCylinderNumber == 10)
                {
                    Receive();
                    WindowCenter.Instance.Close<TaskWin>();
                    WindowCenter.Instance.Open<MainInterfaceWin>();
                }
 
            }
 
            if (Value < 0)
            {
                return;
            }
            lastTime1 += Time.deltaTime;
            if (lastTime1 >= RollingSpeed)
            {
                if (theTarget[Value] != variation[Value])
                {
                    Default += (int)Mathf.Pow(10, Length - 1 - Value);
                    variation.Length = 0;
                    int length = Default.ToString().Length;
                    variation.Append('0', Length - length);
                    variation.Append(Default);
                    variation.ToString();
                    m_AwardNumbertext.text = variation.ToString();
                }
                else Value--;
                lastTime1 = 0;
            }
        }
 
        void Forward()
        {
            if (CrossServerUtility.IsCrossServerBoss())
            {
                SysNotifyMgr.Instance.ShowTip("CrossMap10");
                return;
            }
            _Text_TaskTarget.ExcuteHref();
            TaskAllocation.Instance.TaskTime = TimeUtility.ServerNow;
            WindowCenter.Instance.Close<TaskWin>();
            WindowCenter.Instance.Open<MainInterfaceWin>();
        }
 
        void CompleteTaskDeletion()//删除完成的任务
        {
            List<int> _ListArray = new List<int>();
            foreach (int key in _BountyDic.Keys)
            {
                if (_BountyDic[key].MissionState == 3 || _BountyDic[key].MissionState == 0)
                    _ListArray.Add(key);
            }
            for (int i = 0; i < _ListArray.Count; i++)
            {
                _BountyDic.Remove(_ListArray[i]);
            }
        }
 
        void ContentAssignment()//内容赋值
        {
            int _TaskID = 2000;
            CompleteTaskDeletion();
            if (taskmodel.SpecialTask.Count != 0)
            {
                foreach (int key in taskmodel.SpecialTask.Keys)
                {
                    if (taskmodel.SpecialTask[key].Type == 13 && taskmodel.SpecialTask[key].MissionState != 3)//未接任务
                    {
                        _TaskID = key;
                        TheDefaultTask(_TaskID);
                        return;
                    }
                }
            }
            if (_BountyDic.Count != 0)//可接,正在进行中
            {
                foreach (int key in _BountyDic.Keys)
                {
                    _TaskID = key;
                    BountyMission(_TaskID);
                    return;
                }
            }
            else//全部完成
            {
                EndOfTheTask();
                return;
            }
        }
 
        void BountyMission(int _TaskID)//赏金任务接取
        {
            _Btn_Forward.gameObject.SetActive(true);
            if (TaskAllocation.Instance.ForRingNumber() >= RunTaskCnt2[7])
            {
                _Btn_Finish.gameObject.SetActive(false);
                _Text_TaskCount.text = string.Format(Language.Get("NumberOfRings_Z2"), TaskAllocation.Instance.ForRingNumber(), RunTaskCnt2[7]);
                _Btn_Forward.gameObject.SetActive(false);
            }
            else
            {
                _Btn_Finish.gameObject.SetActive(true);
                _Text_TaskCount.text = (TaskAllocation.Instance.ForRingNumber() + 1) + "/" + RunTaskCnt2[7];
            }
            Text_TaskCount2.text = TaskAllocation.Instance.ForRingAllNumber() + "/" + RunTaskCnt1[7];
 
            string strINfor = _BountyDic[_TaskID].InforList;
            TaskID = _TaskID;
 
            var taskTargetConfig = TASKINFOConfig.Get(strINfor);
            string _str = TaskAllocation.Instance.GetTaskInfo(taskTargetConfig.show_writing, _TaskID);
            _Text_TaskTarget.text = _str;
 
            var taskRewardConfig = TASKINFOConfig.Get(_BountyDic[_TaskID].RewardList);
            string _RewardStr = TaskAllocation.Instance.GetTaskInfo(taskRewardConfig.show_writing, _TaskID);
 
            RewardAnalysis.Inst.GetReward(_RewardStr, ref rewardList);
            RewardInformationDisplay(rewardList);
        }
 
        void TheDefaultTask(int _TaskID)//赏金任务未接取特殊状态
        {
            m_Btn_Receive.SetSprite("UnReceiveBG");
            _Btn_Finish.gameObject.SetActive(false);
            _Btn_Forward.gameObject.SetActive(true);
            _Text_TaskCount.text = Language.Get("TaskFinish");
 
            Text_TaskCount2.text = TaskAllocation.Instance.ForRingAllNumber() + "/" + RunTaskCnt1[7];
            string strINfor = taskmodel.SpecialTask[_TaskID].InforList;
            TaskID = _TaskID;
 
            var taskTargetConfig = TASKINFOConfig.Get(strINfor);
            string _str = TaskAllocation.Instance.GetTaskInfo(taskTargetConfig.show_writing, _TaskID);
            _Text_TaskTarget.text = _str;
 
            var taskRewardConfig = TASKINFOConfig.Get(taskmodel.SpecialTask[_TaskID].RewardList);
            string _RewardStr = TaskAllocation.Instance.GetTaskInfo(taskRewardConfig.show_writing, _TaskID);
 
            RewardAnalysis.Inst.GetReward(_RewardStr, ref rewardList);
            RewardInformationDisplay(rewardList);
        }
 
        void EndOfTheTask()//任务结束状态
        {
            m_Btn_Receive.SetSprite("UnReceiveBG");
            _Btn_Finish.gameObject.SetActive(false);
            _Btn_Forward.gameObject.SetActive(false);
            _Btn_Receive.gameObject.SetActive(false);
            _Text_TaskCount.text = TaskAllocation.Instance.ForRingNumber() + "/" + RunTaskCnt2[7];
 
            Text_TaskCount2.text = TaskAllocation.Instance.ForRingAllNumber() + "/" + RunTaskCnt1[7];
 
            _Text_TaskTarget.text = Language.Get("CoinTaskText_1");//已完成本日所有师门悬赏任务
 
            if (_Grid.childCount != 0)
            {
                for (int i = 0; i < _Grid.childCount; i++)
                {
                    DestroyObject(_Grid.GetChild(i).gameObject);
                }
            }
        }
 
        void OnBounty()
        {
            _BountyDic = taskmodel.BountyDic;
            RewardsToOpen();
            ContentAssignment();
        }
 
        void RewardInformationDisplay(List<RewardAnalysis.RewardInfo> rewardList)//奖励信息
        {
            if (_Grid.childCount != 0)
            {
                for (int i = 0; i < _Grid.childCount; i++)
                {
                    DestroyObject(_Grid.GetChild(i).gameObject);
                }
            }
            if (rewardList.Count == 0)
                return;
            for (int i = 0; i < rewardList.Count; i++)
            {
                GameObject go = GameObject.Instantiate(UILoader.LoadPrefab("ItemCell"));
                ItemCell itemcell = go.GetComponent<ItemCell>();
                go.transform.SetParent(_Grid);
                go.transform.localScale = Vector3.one;
                Vector3 pos = go.transform.localPosition;
                go.transform.localPosition = pos.SetZ(0);
                Button _button = go.transform.GetComponent<Button>();
                ulong number = 0;
                if (rewardList[i].expPoint != 0)
                {
                    number = (ulong)rewardList[i].expPoint * 100000000;
                    number += (ulong)rewardList[i].num;
                }
                else
                {
                    number = (ulong)rewardList[i].num;
                }
                ItemCellModel cellModel = new ItemCellModel(rewardList[i].itemCfg.ID, true, (ulong)number);
                itemcell.Init(cellModel);
                itemcell.button.RemoveAllListeners();
                int tab = i;
                itemcell.button.AddListener(() =>
                {
                    ItemTipUtility.Show(rewardList[tab].itemCfg.ID);
                });
            }
        }
    }
}