少年修仙传客户端代码仓库
hch
2025-06-12 204ef05a831c9484e2abc561d27ecbff7c797453
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Wednesday, October 11, 2017
//--------------------------------------------------------
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
 
using System.Collections.Generic;
using UnityEngine.EventSystems;
//剧情任务面板
namespace vnxbqy.UI
{
 
    public class StoryTask : MonoBehaviour
    {
        [SerializeField] ScrollerController _TaskRamusList;
        //右侧面板
        [SerializeField] Text _Text_TaskName;//任务名
        [SerializeField] RichText _Text_TaskDescribe;//任务描述
        [SerializeField] RichText _Text_TaskTarget;//任务目标
        [SerializeField] Transform _Grid;//任务奖励生成的节点
 
        [SerializeField] Button _Btn_Forward;//剧情面板按钮
        [SerializeField] Text _Text_Forward;//按钮文字
        private List<RewardAnalysis.RewardInfo> rewardList = new List<RewardAnalysis.RewardInfo>();
        Dictionary<int, Dictionary<string, string>> _DicTaskInforma = new Dictionary<int, Dictionary<string, string>>();//任务字典的信息
        private Dictionary<int, MissionDetailDates> _MainTaskDic = new Dictionary<int, MissionDetailDates>();//主线任务字典
        private Dictionary<int, string> chapterDic = new Dictionary<int, string>();//用来存储主线任务章节
        private List<int> listTask = new List<int>();//储存当前章节的任务个数
        private int mainTaskID = 0;//获取当前正在进行任务的ID
        private int closerTaskId = 0;
        private int mainTaaskChapter = 1;//获取当前任务的章节
 
        private int MainTaaskChapterNow = 1;//获取当前选中的选中章节数
        private int MainTaskIDNow = 0;//当前选中的任务ID
        private bool _IsOpenbool = true;
        TaskModel m_TaskModel;
        TaskModel taskmodel { get { return m_TaskModel ?? (m_TaskModel = ModelCenter.Instance.GetModel<TaskModel>()); } }
 
        private void Awake()
        {
            _TaskRamusList.OnRefreshCell += OnRefreshGridCell;
            SaveChapter();
        }
        private void OnEnable()
        {
            _IsOpenbool = true;
            TaskModel.Event_TaskInformation += TaskInformation;//任务字典信息
            _DicTaskInforma = taskmodel._DicTaskInformation;
            _MainTaskDic = taskmodel.MainTaskDic;
            GetMainIDAndMainTaskChapter();
            MainTaaskChapterNow = mainTaaskChapter;
            ListTask(MainTaaskChapterNow);
            MainTaskIDNow = closerTaskId;
            OnCreateGridLineCell(_TaskRamusList);//创建赋值
            StartCoroutine("Delay");
        }
        IEnumerator Delay()
        {
 
            yield return null;
            _TaskRamusList.JumpIndex(JunpIndex() - 1);
 
        }
        private void Start()
        {
            _Btn_Forward.onClick.AddListener(ForwardButton);
        }
        private void OnDisable()
        {
            StopCoroutine("Delay");
            TaskModel.Event_TaskInformation -= TaskInformation;//任务字典信息 
        }
 
        void OnCreateGridLineCell(ScrollerController gridCtrl)//任务预制体创建
        {
            gridCtrl.Refresh();
 
            foreach (int key in chapterDic.Keys)
            {
                if (key <= mainTaaskChapter)
                {
                    gridCtrl.AddCell(ScrollerDataType.Header, key);
                    if (key == MainTaaskChapterNow && _IsOpenbool)
                    {
                        for (int i = 0; i < listTask.Count; i++)
                        {
                            var config = TaskListConfig.Get(listTask[i]);
                            if (config != null && TASKINFOConfig.Has(config.TaskName))
                            {
                                gridCtrl.AddCell(ScrollerDataType.Normal, listTask[i]);
                            }
                        }
                    }
                }
            }
            gridCtrl.Restart();
 
        }
 
        void OnRefreshGridCell(ScrollerDataType type, CellView cell)
        {
            int taskID = cell.index;
            if (type == ScrollerDataType.Header)
            {
                TaskTitleBtton taskTitleBtton = cell.GetComponent<TaskTitleBtton>();
                if (MainTaaskChapterNow == taskID)
                {
                    taskTitleBtton.PitchOnImage.SetActive(true);
                }
                else
                {
                    taskTitleBtton.PitchOnImage.SetActive(false);
                }
                taskTitleBtton.TitleName.text = chapterDic[taskID];
                taskTitleBtton.TitleBtton.RemoveAllListeners();
                taskTitleBtton.TitleBtton.AddListener(() =>
                {
                    if (taskID != MainTaaskChapterNow)
                    {
                        MainTaaskChapterNow = taskID;
                        ListTask(MainTaaskChapterNow);
                        _IsOpenbool = true;
                        OnCreateGridLineCell(_TaskRamusList);
                    }
                    else
                    {
                        MainTaaskChapterNow = 0;
                        _IsOpenbool = false;
                        OnCreateGridLineCell(_TaskRamusList);
                    }
                });
            }
            if (type == ScrollerDataType.Normal)
            {
 
                MainTaskButton mainTaskButton = cell.GetComponent<MainTaskButton>();
                TaskListConfig tasklistmodel = TaskListConfig.Get(taskID);
 
                mainTaskButton.LightUpTheState.SetActive(false);//是否选中状态
                if (taskID < mainTaskID)
                {
                    mainTaskButton.Text_RamusName.text = TASKINFOConfig.Get(tasklistmodel.TaskName).show_writing;
                    mainTaskButton.Text_RamusState.SetActive(false);
                    mainTaskButton.m_Img_Finish.SetActive(true);
                }
                else if (taskID == mainTaskID)
                {
                    mainTaskButton.Text_RamusName.text = TASKINFOConfig.Get(tasklistmodel.TaskName).show_writing;
                    mainTaskButton.Text_RamusState.SetActive(true);
                    mainTaskButton.Text_RamusState.text = GegionalTaskStatus(_MainTaskDic[taskID].MissionState);
                    mainTaskButton.m_Img_Finish.SetActive(false);
                }
                else if (taskID > mainTaskID)
                {
                    mainTaskButton.Text_RamusName.text = TASKINFOConfig.Get(tasklistmodel.TaskName).show_writing;
                    mainTaskButton.Text_RamusState.SetActive(true);
                    mainTaskButton.Text_RamusState.text = Language.Get("NotPickedUp_Z");
                    mainTaskButton.m_Img_Finish.SetActive(false);
                }
                if (taskID <= mainTaskID)
                {
                    mainTaskButton.MainTaskBtn.interactable = true;
                    mainTaskButton.LightUpThe.color = new Color(1, 1, 1, 1);
                    if (taskID == MainTaskIDNow)
                    {
                        mainTaskButton.LightUpTheState.SetActive(true);
                        if (taskID == mainTaskID)
                        {
                            _Btn_Forward.SetActive(true);
                            Information(taskID);
                        }
                        else
                        {
                            _Btn_Forward.SetActive(false);
                            MissionsTask(taskID);
                        }
                    }
                    mainTaskButton.MainTaskBtn.RemoveAllListeners();
                    mainTaskButton.MainTaskBtn.AddListener(() =>
                    {
                        MainTaskIDNow = taskID;
                        _TaskRamusList.m_Scorller.RefreshActiveCellViews();//刷新当前可见
                    });
                }
                else
                {
                    mainTaskButton.MainTaskBtn.interactable = false;
                    mainTaskButton.LightUpThe.color = new Color(1, 1, 1, 0.5f);
                }
            }
        }
 
 
        void ForwardButton()//剧情任务按钮
        {
            if (CrossServerUtility.IsCrossServerBoss())
            {
                SysNotifyMgr.Instance.ShowTip("CrossMap10");
                return;
            }
            _Text_TaskTarget.ExcuteHref();
            WindowCenter.Instance.Close<TaskWin>();
            WindowCenter.Instance.Open<MainInterfaceWin>();
 
        }
 
        void Information(int taskID)
        {
            _Text_TaskName.text = TASKINFOConfig.Get(_MainTaskDic[taskID].Name).show_writing;//任务名
            _Text_TaskDescribe.text = TASKINFOConfig.Get(_MainTaskDic[taskID].Desclist).show_writing;//任务描述
            string strINfor = _MainTaskDic[taskID].InforList;
            string str= TASKINFOConfig.Get(strINfor).show_writing;
            //str= WordAnalysis.Color_Start_Regex.Replace(str, string.Empty);
            //str = WordAnalysis.Color_End_Regex.Replace(str, string.Empty);
            _Text_TaskTarget.text = str;//任务目标
            _Text_Forward.text = TaskStatus(_MainTaskDic[taskID].MissionState);
            if (_DicTaskInforma.ContainsKey(taskID))
            {
                _Text_TaskTarget.SetReplaceInfo(_DicTaskInforma[taskID]);
            }
            string _RewardStr = TASKINFOConfig.Get(_MainTaskDic[taskID].RewardList).show_writing;
            RewardAnalysis.Inst.GetReward(_RewardStr, ref rewardList);
            RewardInformationDisplay(rewardList);
        }
 
        void MissionsTask(int taskID)
        {
            TaskListConfig taskListModel = TaskListConfig.Get(taskID);
            _Text_TaskName.text = TASKINFOConfig.Get(taskListModel.TaskName).show_writing;//任务名
            _Text_TaskDescribe.text = TASKINFOConfig.Get(taskListModel.TaskDescribe).show_writing;//任务描述
            var taskconfig = TASKINFOConfig.Get(taskListModel.TaskTarget);
            if (taskconfig == null)
            {
                DebugEx.LogError("告诉TT任务目标没有这条数据(TASKINFO)" + taskListModel.TaskTarget);
                return;
            }
            string str = TASKINFOConfig.Get(taskListModel.TaskTarget).show_writing;
            //str = WordAnalysis.Color_Start_Regex.Replace(str, string.Empty);
            //str = WordAnalysis.Color_End_Regex.Replace(str, string.Empty);
            _Text_TaskTarget.text = str;//任务目标
            string _RewardStr = TASKINFOConfig.Get(taskListModel.TaskRewards).show_writing;
            RewardAnalysis.Inst.GetReward(_RewardStr, ref rewardList);
            RewardInformationDisplay(rewardList);
        }
 
 
        string TaskStatus(int _index)//获取主线任务状态
        {
            switch (_index)
            {
                case 0:
                    return Language.Get("Z1075");
                case 1:
                    return Language.Get("Z1074");
                case 2:
                    return Language.Get("Z1076");
            }
            return string.Empty;
        }
 
        string GegionalTaskStatus(int _index)//任务状态
        {
            switch (_index)
            {
                case 0:
                    return Language.Get("Z1072");
                case 1:
                    return Language.Get("Z1071");
                case 2:
                    return Language.Get("Z1073");
            }
            return string.Empty;
        }
        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);
                ItemCellModel cellModel = new ItemCellModel(rewardList[i].itemCfg.ID, true, (ulong)rewardList[i].num);
                itemcell.Init(cellModel);
                itemcell.button.RemoveAllListeners();
                int tab = i;
                itemcell.button.AddListener(() =>
                {
                    ItemTipUtility.Show(rewardList[tab].itemCfg.ID);
                });
            }
        }
        void TaskInformation(int _Taskid, Dictionary<int, Dictionary<string, string>> _Dic)//任务字典信息
        {
            _DicTaskInforma = taskmodel._DicTaskInformation;
            if (_DicTaskInforma.ContainsKey(_Taskid))
            {
                _Text_TaskTarget.SetReplaceInfo(_DicTaskInforma[_Taskid]);
            }
        }
        List<TaskListConfig> configs = new List<TaskListConfig>();
        void SaveChapter()//获取主线任务章节
        {
            if (configs.Count <= 0)
            {
                configs = TaskListConfig.GetValues();
            }
           // var configs = TaskListConfig.GetValues();
            foreach (var value in configs)
            {
                if (!chapterDic.ContainsKey(value.ChapterID))
                {
                    chapterDic.Add(value.ChapterID, value.ChapterName);
 
                }
            }
        }
 
        void GetMainIDAndMainTaskChapter()//获取正在进行的任务ID和章节数
        {
 
            foreach (int key in _MainTaskDic.Keys)
            {
                if (_MainTaskDic[key].MissionState != 0 && _MainTaskDic[key].MissionState != 3)
                {
                    mainTaskID = key;
                    closerTaskId = GetCloserTask(key);
                    mainTaaskChapter = TaskListConfig.Get(closerTaskId).ChapterID;
                }
            }
        }
 
        int GetCloserTask(int taskId)
        {
            if (TaskListConfig.Has(taskId))
            {
                return taskId;
            }
            var configs = TaskListConfig.GetValues();
            var id = configs[0].TaskID;
            foreach (var config in configs)
            {
                if (config.TaskID <= taskId && TASKINFOConfig.Has(config.TaskName))
                {
                    id = config.TaskID;
                }
                else
                {
                    break;
                }
            }
            return id;
        }
 
 
        private void ListTask(int ChapterID)
        {
            listTask.Clear();
            if (configs.Count <= 0)
            {
                configs = TaskListConfig.GetValues();
            }
           // var configs = TaskListConfig.GetValues();
            foreach (var value in configs)
            {
                if (value.ChapterID == ChapterID && value.TaskID<= mainTaskID)
                {
                    listTask.Add(value.TaskID);
                }
            }
        }
 
        private int JunpIndex()
        {
            int Index = 0;
            Index += mainTaaskChapter;
            for (int i = 0; i < listTask.Count; i++)
            {
                Index += 1;
                if (listTask[i] == closerTaskId)
                {
                    return Index;
 
                }
            }
            return 0;
        }
    }
 
 
 
}