少年修仙传客户端代码仓库
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
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Monday, October 16, 2017
//--------------------------------------------------------
 
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
using System.Text.RegularExpressions;
 
namespace vnxbqy.UI
{
 
    public class XMZZMissionDetailsWin : Window
    {
        [SerializeField] MissionBar[] m_Missions;
 
        [SerializeField] Transform m_ContainerHint;
        [SerializeField] RichText m_Hint;
 
        [SerializeField] Transform m_ContainerMainLineTask;
        [SerializeField] Text m_MainLineTask;
 
        [SerializeField] GameObject winIconObj;
 
        DungeonModel m_Model;
        DungeonModel model { get { return m_Model ?? (m_Model = ModelCenter.Instance.GetModel<DungeonModel>()); } }
 
        bool isInitHintBaseInfo = false;
 
        int dungeonStep = -1;
 
        #region Built-in
        protected override void BindController()
        {
        }
 
        protected override void AddListeners()
        {
        }
 
        protected override void OnPreOpen()
        {
            dungeonStep = -1;
            ShowMission();
            UpdateMissions();
        }
 
        protected override void OnAfterOpen()
        {
            model.updateMissionEvent += UpdateMissions;
        }
 
        protected override void OnPreClose()
        {
            model.updateMissionEvent -= UpdateMissions;
        }
 
        protected override void OnAfterClose()
        {
        }
        #endregion
 
        private void ShowMission()
        {
            var mission = model.mission;
            var dataMapId = model.GetDataMapIdByMapId(PlayerDatas.Instance.baseData.MapID);
            var hintId = model.GetDungeonHintId(dataMapId, mission.lineID);
            var config = DungeonHintConfig.Get(hintId);
 
            if (config != null)
            {
                m_ContainerMainLineTask.SetActive(true);
                if (mission.missionID > 0)
                {
                    var taskConfig = PyTaskConfig.Get(mission.missionID);
                    var taskShowConfig = TASKINFOConfig.Get(taskConfig.name);
                    m_MainLineTask.text = taskShowConfig.show_writing;
                }
                else
                {
                    var dungeonId = model.GetDungeonId(dataMapId, mission.lineID);
                    var dungeonConfig = DungeonConfig.Get(dungeonId);
                    m_MainLineTask.text = dungeonConfig.FBName;
                }
            }
        }
 
        private void UpdateMissions()
        {
            var mission = model.mission;
            var dateMapId = model.GetDataMapIdByMapId(PlayerDatas.Instance.baseData.MapID);
            var hintId = model.GetDungeonHintId(dateMapId, mission.lineID);
            var config = DungeonHintConfig.Get(hintId);
 
            if (mission.step != dungeonStep)
            {
                m_Hint.text = string.Empty;
                try
                {
                    if (config.Info.Length > 0)
                    {
                        m_Hint.text = config.Info[Mathf.Min(Mathf.Clamp(mission.step - 1, 0, int.MaxValue), config.Info.Length - 1)];
                    }
                }
                catch (Exception ex)
                {
                    DebugEx.LogError(ex);
                }
            }
 
            if (config != null)
            {
                for (int i = 0; i < 3; i++)
                {
                    if (i < config.targetNum)
                    {
                        m_Missions[i].container.SetActive(true);
                        UpdateMissionContent(mission, i + 1, m_Missions[i]);
                    }
                    else
                    {
                        m_Missions[i].container.SetActive(false);
                    }
                }
            }
 
            dungeonStep = mission.step;
        }
 
        private void UpdateMissionContent(DungeonMissionData _mission, int _targetIndex, MissionBar _missionBar)
        {
            var dateMapId = model.GetDataMapIdByMapId(PlayerDatas.Instance.baseData.MapID);
            var hintId = model.GetDungeonHintId(dateMapId, _mission.lineID);
            var config = DungeonHintConfig.Get(hintId);
            if (config == null)
            {
                return;
            }
 
            var targetInfo = GetTargetInfo(config, Mathf.Clamp(_mission.step - 1, 0, int.MaxValue), _targetIndex);
 
            if (dungeonStep != _mission.step)
            {
                var configDescription = targetInfo.decription;
                var npcId = targetInfo.npcId;
 
                var match = Regex.Match(configDescription, "@.*@");
                switch (match.Value)
                {
                    case "@NPCName@":
                        try
                        {
                            var npcConfig = NPCConfig.Get(npcId);
                            configDescription = configDescription.Replace(match.Value, npcConfig.charName);
                        }
                        catch (Exception e)
                        {
                            DebugEx.LogErrorFormat("不存在该Npc {0}", npcId);
                        }
                        break;
                }
 
                _missionBar.title.text = configDescription;
            }
 
            var progress = 0L;
            switch ((DungeonTargetType)targetInfo.type)
            {
                //case DungeonTargetType.NPC:
                //    if (_mission.npc != null)
                //    {
                //        for (int i = 0; i < _mission.npc.Length; i++)
                //        {
                //            var npcInfo = _mission.npc[i];
                //            if (_targetIndex == NPCBelongToTargetIndex(npcInfo.NPCID, config, Mathf.Clamp(_mission.step - 1, 0, int.MaxValue)))
                //            {
                //                progress = npcInfo.killCnt;
                //                break;
                //            }
                //        }
                //    }
                //    break;
                //case DungeonTargetType.Exp:
                //    progress = _mission.totalExp;
                //    break;
                //case DungeonTargetType.Score:
                //    progress = _mission.score;
                //    break;
                //case DungeonTargetType.Money:
                //    progress = _mission.money[0].moneyValue;
                //    break;
                //case DungeonTargetType.Wave:
                //    progress = _mission.wheel;
                //    break;
                //case DungeonTargetType.NpcTotal:
                //    progress = _mission.npcTotal;
                //    break;
                //case DungeonTargetType.Stage:
                //    progress = _mission.step;
                //    break;
                //case DungeonTargetType.NPCDialogue:
                //    progress = _mission.talkOver;
                //    break;
                case DungeonTargetType.VictorySumCnt:
                    progress = HeavenBattleInfo.Instance.WinCnt;
                    break;
                case DungeonTargetType.StageVictoryCnt:
                    progress = _mission.winCnt;
                    if (progress < 1)
                    {
                        winIconObj.SetActive(false);
                    }
                    else
                    {
                        winIconObj.SetActive(true);
                    }
                    break;
 
            }
 
            if (targetInfo.targetValue == 0)
            {
                _missionBar.progress.text = StringUtility.Contact(UIHelper.ReplaceLargeNum(progress),
                   (DungeonTargetType)targetInfo.type == DungeonTargetType.Exp && _mission.isFullExp == 1 ? StringUtility.Contact("  ", Language.Get("FullExp")) : string.Empty);
            }
            else
            {
                _missionBar.progress.text = StringUtility.Contact(UIHelper.ReplaceLargeNum(progress), "/", targetInfo.targetValue);
            }
        }
 
        private int NPCBelongToTargetIndex(int _npcId, DungeonHintConfig _config, int _step)
        {
            if (_config.targetType1 == 1 && _config.NPC1ID[Mathf.Min(_step, _config.NPC1ID.Length - 1)] == _npcId)
            {
                return 1;
            }
 
            if (_config.targetType2 == 1 && _config.NPC2ID[Mathf.Min(_step, _config.NPC2ID.Length - 1)] == _npcId)
            {
                return 2;
            }
 
            if (_config.targetType3 == 1 && _config.NPC3ID[Mathf.Min(_step, _config.NPC3ID.Length - 1)] == _npcId)
            {
                return 3;
            }
 
            return 0;
        }
 
        TargetInfo GetTargetInfo(DungeonHintConfig _config, int _step, int _index)
        {
            TargetInfo targetInfo;
            switch (_index)
            {
                case 1:
                    targetInfo.type = _config.targetType1;
                    targetInfo.npcId = _config.NPC1ID.Length == 0 ? 0 : (_config.targetType1 == 1 || _config.targetType1 == 8 || _config.targetType1 == 6) ? _config.NPC1ID[Mathf.Min(_step, _config.NPC1ID.Length - 1)] : 0;
                    targetInfo.decription = _config.targetDescription1[Mathf.Min(_step, _config.targetDescription1.Length - 1)];
                    targetInfo.targetValue = _config.targetValue1[Mathf.Min(_step, _config.targetValue1.Length - 1)];
                    break;
                case 2:
                    targetInfo.type = _config.targetType2;
                    targetInfo.npcId = _config.NPC2ID.Length == 0 ? 0 : (_config.targetType2 == 1 || _config.targetType2 == 8 || _config.targetType2 == 6) ? _config.NPC2ID[Mathf.Min(_step, _config.NPC2ID.Length - 1)] : 0;
                    targetInfo.decription = _config.targetDescription2[Mathf.Min(_step, _config.targetDescription2.Length - 1)];
                    targetInfo.targetValue = _config.targetValue2[Mathf.Min(_step, _config.targetValue2.Length - 1)];
                    break;
                case 3:
                    targetInfo.type = _config.targetType3;
                    targetInfo.npcId = _config.NPC3ID.Length == 0 ? 0 : (_config.targetType3 == 1 || _config.targetType3 == 8 || _config.targetType3 == 6) ? _config.NPC3ID[Mathf.Min(_step, _config.NPC3ID.Length - 1)] : 0;
                    targetInfo.decription = _config.targetDescription3[Mathf.Min(_step, _config.targetDescription3.Length - 1)];
                    targetInfo.targetValue = _config.targetValue3[Mathf.Min(_step, _config.targetValue3.Length - 1)];
                    break;
                default:
                    targetInfo = default(TargetInfo);
                    break;
            }
 
            return targetInfo;
        }
 
        struct TargetInfo
        {
            public int type;
            public int npcId;
            public string decription;
            public int targetValue;
        }
 
        [System.Serializable]
        public class MissionBar
        {
            public Transform container;
            public Text title;
            public Text progress;
        }
 
    }
 
}