少年修仙传客户端代码仓库
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
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
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using LitJson;
 
namespace vnxbqy.UI
{
    //开服活动BOSS首杀
    public class BossFirstBloodWin : Window
    {
        [SerializeField] Button m_Goto;
        [SerializeField] Button m_GetAward;
        [SerializeField] UIEffect m_EffectGet;
        [SerializeField] ScrollerController m_BossCtrl;
        [SerializeField] RawImage m_MonsterPortrait;
        [SerializeField] Transform m_HorizontaFirstBlood;
        [SerializeField] Transform m_HorizontaKill;
        [SerializeField] Text m_NPCNameLV;
        [SerializeField] Text m_PlayerName;
        [SerializeField] Text m_KillTime;
        [SerializeField] UIEffect m_Effect;
        [SerializeField] Button m_RedPack;
        [SerializeField] Text m_RedMoney;
        [SerializeField] RedpointBehaviour redPonint;
 
        BossFirstBloodModel model
        {
            get
            {
                return ModelCenter.Instance.GetModel<BossFirstBloodModel>();
            }
        }
        FindPreciousModel findPreciousModel { get { return ModelCenter.Instance.GetModel<FindPreciousModel>(); } }
        DungeonModel dungeonModel { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
        protected override void AddListeners()
        {
            
        }
 
        private void OnRefreshCell(ScrollerDataType type, CellView cell)
        {
            if (type == ScrollerDataType.Header)
                RefreshNPCCell(cell as BossFirstBloodCell);
 
        }
        private void RefreshNPCCell(BossFirstBloodCell _cell)
        {
            int npcID = _cell.info.Value.infoInt1;
            _cell.ShowIcon(npcID, _cell.index == model.selectIndex);
            _cell.funcBtn.onClick.RemoveAllListeners();
            _cell.funcBtn.onClick.AddListener(() =>
            {
                OnBossIconClick(npcID, _cell.index);
            });
 
        }
        private void GotoKillBoss(int npcID)
        {
            var error = 0;
            if (TestGotoKillBoss(npcID, out error))
            {
                WindowJumpMgr.Instance.ClearJumpData();
                WindowCenter.Instance.Close<OpenServerActivityRankWin>();
 
                GAStaticDefine.NPCLocation _npcLocation;
                var _findLocation = GAStaticDefine.TryGetMapNPCLocation(npcID, out _npcLocation);
                MapTransferUtility.Instance.MoveToNPC(npcID);
            }
            else
            {
                ProcessGotoKillBossError(npcID, error);
            }
        }
        private void ProcessGotoKillBossError(int npcID, int _error)
        {
            switch (_error)
            {
                case 1:
                    var dataMapId = dungeonModel.GetDataMapIdByMapId(PlayerDatas.Instance.baseData.MapID);
                    var config = DungeonOpenTimeConfig.Get(dataMapId);
                    var tip = Language.Get(config.ExitDescription);
 
 
                    ConfirmCancel.ShowPopConfirm(
                        Language.Get("Mail101"),
                        tip,
                        (bool _ok) =>
                        {
                            if (_ok)
                            {
                                WindowCenter.Instance.Close<FindPreciousFrameWin>();
                                MapTransferUtility.Instance.MoveToNPC(npcID);
                            }
                        }
                        );
                    break;
                case 2:
                    SysNotifyMgr.Instance.ShowTip("InDungeon_CantGo");
                    break;
                case 3:
                    SysNotifyMgr.Instance.ShowTip("CrossMap10");
                    break;
                case 4:
                    SysNotifyMgr.Instance.ShowTip("BossRealmHint2", RealmConfig.Get(NPCConfig.Get(npcID).Realm).LvLarge);
                    break;
            }
        }
        private bool TestGotoKillBoss(int npcID, out int _error)
        {
            if (!findPreciousModel.IsBossUnlock(npcID))
            {
                _error = 4;
                return false;
            }
 
            var mapId = PlayerDatas.Instance.baseData.MapID;
            var dataMapId = MapUtility.GetDataMapId(mapId);
            if (dataMapId == ElderGodAreaModel.ELDERGODAREA_MAPID)
            {
                _error = 1;
                return false;
            }
 
            var mapConfig = MapConfig.Get(mapId);
            if (mapConfig.MapFBType != (int)MapType.OpenCountry && mapId != 31020)
            {
                _error = 2;
                return false;
            }
 
            if (CrossServerUtility.IsCrossServer() || ClientCrossServerOneVsOne.isClientCrossServerOneVsOne)
            {
                _error = 3;
                return false;
            }
 
            _error = 0;
            return true;
        }
 
        private void SendGetAward(int npcID, int awardType)
        {
            var pak = new CA901_tagCGGetBossFirstKillAward();
            pak.NPCID = (uint)npcID;
            pak.AwardType = (byte)awardType;
            GameNetSystem.Instance.SendInfo(pak);
        }
 
 
 
        private void OnBossIconClick(int npcID, int index)
        {
            var npcConfig = NPCConfig.Get(npcID);
            if (!m_MonsterPortrait.gameObject.activeSelf)
                m_MonsterPortrait.SetActive(true);
            UI3DModelExhibition.Instance.ShowNPC(npcID, npcConfig.UIModeLOffset, npcConfig.UIModelRotation, m_MonsterPortrait);
            model.selectIndex = index;
            model.selectNPCID = npcID;
            m_BossCtrl.m_Scorller.RefreshActiveCellViews();
 
            m_NPCNameLV.text = npcConfig.charName + " LV." + npcConfig.NPCLV;
 
            //首杀 未击杀红包正常亮,已击杀未领取显示特效红点,已领取置灰
            redPonint.redpointId = model.GetNPCRedPackPointID(npcID);
            model.UpdateRedPackPoint(npcID);
            ShowKillInfo(npcID);
 
            m_RedPack.RemoveAllListeners();
            m_RedPack.AddListener(() =>
            {
                ClickRedPack(npcID);
            });
 
        }
 
        private void ClickRedPack(int npcID)
        {
            var state = model.GetBossKillAwardState(npcID);
 
            if (state == 1)
            {
                SendGetAward(npcID, 0);
                return;
            }
            var npcConfig = NPCConfig.Get(npcID);
            if (state == 0)
                SysNotifyMgr.Instance.ShowTip("NoBossFirstKill", npcConfig.charName);
            else if (state == 2)
                SysNotifyMgr.Instance.ShowTip("GetBossFirstKillAwardYet", npcConfig.charName);
        }
 
        public void ShowKillInfo(int npcID)
        {
            if (model.selectNPCID != npcID)
                return;
            var fkInfo = BOSSFirstKillConfig.Get(npcID);
            bool isAlreadyFirstKill = model.IsAlreadyFirstKill(npcID);
            int killStateSelf = model.GetPersonalKillAwardState(npcID);
 
            m_Goto.RemoveAllListeners();
            m_GetAward.RemoveAllListeners();
            if (killStateSelf == 1)
            {
                m_GetAward.SetActive(true);
                m_EffectGet.Play();
                m_Goto.SetActive(false);
                m_GetAward.AddListener(() =>
                {
                    SendGetAward(npcID, 1);
                });
 
            }
            else
            {
                m_GetAward.SetActive(false);
                m_EffectGet.Stop();
                m_Goto.SetActive(true);
                m_Goto.AddListener(() =>
                {
                    GotoKillBoss(npcID);
                });
            }
            if (isAlreadyFirstKill)
            {
                m_PlayerName.text = Language.Get("FirstKill1") + model.firstKillTimeInfo[npcID].name;
                m_KillTime.text = Language.Get("FirstKill2") + model.firstKillTimeInfo[npcID].time;
            }
            else
            {
                m_PlayerName.text = Language.Get("FirstKill3");
                m_KillTime.text = string.Empty;
            }
 
 
            //首杀奖励
            for (int i = 0; i < m_HorizontaFirstBlood.childCount; i++)
            {
                m_HorizontaFirstBlood.GetChild(i).SetActive(false);
            }
            var fkitemsArray = JsonMapper.ToObject<int[][]>(fkInfo.ServerFirstKillPlayerAward);
 
            for (int type = 0; type < fkitemsArray.Length; type++)
            {
                if (type < m_HorizontaFirstBlood.childCount)
                {
                    int itemId = fkitemsArray[type][0];
                    var Item_Info = m_HorizontaFirstBlood.GetChild(type);
                    Item_Info.SetActive(true);
                    BossFirstBloodItemInfo firstBItemInfo = Item_Info.GetComponent<BossFirstBloodItemInfo>();
 
                    firstBItemInfo.AlreadyGetImage.SetActive(isAlreadyFirstKill);
                    var ItemCell = firstBItemInfo.Item_Cell;
                    var Item = ItemConfig.Get(itemId);
                    ItemCellModel cellModel = new ItemCellModel(itemId, true, (ulong)fkitemsArray[type][1]);
                    ItemCell.Init(cellModel);
                    ItemCell.button.RemoveAllListeners();
                    ItemCell.button.AddListener(() =>
                    {
                        ItemTipUtility.Show(itemId);
                    });
                }
            }
 
 
            //击杀奖励
            for (int i = 0; i < m_HorizontaKill.childCount; i++)
            {
                m_HorizontaKill.GetChild(i).SetActive(false);
            }
            var itemsArray = JsonMapper.ToObject<int[][]>(fkInfo.PersonFirstKillAward);
 
            for (int type = 0; type < itemsArray.Length; type++)
            {
                if (type < m_HorizontaKill.childCount)
                {
                    int itemId = itemsArray[type][0];
                    var Item_Info = m_HorizontaKill.GetChild(type);
                    Item_Info.SetActive(true);
                    BossFirstBloodItemInfo itemInfo = Item_Info.GetComponent<BossFirstBloodItemInfo>();
 
                    itemInfo.AlreadyGetImage.SetActive(killStateSelf == 2);
 
                    var ItemCell = itemInfo.Item_Cell;
                    var Item = ItemConfig.Get(itemId);
                    ItemCellModel cellModel = new ItemCellModel(itemId, true, (ulong)itemsArray[type][1]);
                    ItemCell.Init(cellModel);
                    ItemCell.button.RemoveAllListeners();
                    ItemCell.button.AddListener(() =>
                    {
                        ItemTipUtility.Show(itemId);
                    });
                }
            }
            // 红包状态
            var state = model.GetBossKillAwardState(npcID);
            m_RedMoney.SetActive(false);
            if (state == 0)
            {
                m_RedPack.SetColorful(null, true);
                m_Effect.Stop();
            }
            else if (state == 1)
            {
                m_RedPack.SetColorful(null, true);
                m_Effect.Play();
            }
            else if (state == 2)
            {
                m_RedPack.SetColorful(null, false);
                m_RedMoney.SetActive(true);
                m_Effect.Stop();
            }
 
        }
        protected override void BindController()
        {
        }
 
        protected override void OnAfterClose()
        {
        }
 
        protected override void OnAfterOpen()
        {
 
            JumpNpcByIndex(model.GetFirstNPCRedPoint());
        }
 
        protected override void OnPreClose()
        {
            m_BossCtrl.OnRefreshCell -= OnRefreshCell;
            model.UpdatePersonnalKillEvent -= ShowKillInfo;
            UI3DModelExhibition.Instance.StopShow();
        }
 
        protected override void OnPreOpen()
        {
            m_BossCtrl.OnRefreshCell += OnRefreshCell;
            model.UpdatePersonnalKillEvent += ShowKillInfo;
            CreateNPCScroll();
            if (WindowCenter.Instance.IsOpen<ImpactRankWin>())
                WindowCenter.Instance.Close<ImpactRankWin>();
        }
        private void CreateNPCScroll()
        { 
            int i = 0;
            m_BossCtrl.Refresh();
            foreach (string npcID in model.npcIDConfig)
            {
                CellInfo info = new CellInfo();
                info.infoInt1 = int.Parse(npcID);
                m_BossCtrl.AddCell(ScrollerDataType.Header, i, info);
                i++;
            }
            m_BossCtrl.Restart();
            m_BossCtrl.m_Scorller.RefreshActiveCellViews();
        }
 
        public void JumpNpcByIndex(Int2 npcInfo)
        {
            int index = npcInfo.x;
            int npcID = npcInfo.y;
            m_BossCtrl.JumpIndex(npcInfo.x);
            CellView cell = m_BossCtrl.GetActiveCellView(index); 
            if (cell != null)
                // 此处取的是显示的index,npcindex比这个大取到是空的
                npcID = cell.info.Value.infoInt1;
            OnBossIconClick(npcID, index);
        }
 
    }
}