少年修仙传客户端代码仓库
hch
2025-03-03 28785d6ddf9c08e49527ede9405c7b6c93c6ed32
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Friday, January 18, 2019
//--------------------------------------------------------
 
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
 
namespace vnxbqy.UI
{
    
    public class SkyTowerWin : Window
    {
        [SerializeField] SkyTowerBehaviour m_TowerBehaviour;
 
        [SerializeField] Button m_ViewBoss;
        [SerializeField] UIEffect m_ViewBossEffect;
        [SerializeField] Button m_ViewReward;
        [SerializeField] UIEffect m_ViewRewardEffect;
 
        [SerializeField] RectTransform m_BossContainer;
        [SerializeField] PositionTween m_BossShowTween;
        [SerializeField] Image m_BossRealm;
        [SerializeField] Text m_BossName;
        [SerializeField] Text m_BossLevel;
        [SerializeField] RawImage m_BossPortrait;
        [SerializeField] UIEffect m_BossEffect;
 
        [SerializeField] RectTransform m_RewardContainer;
        [SerializeField] PositionTween m_RewardShowTween;
        [SerializeField] SkyTowerRewardPreviewGroup m_RewardBehaviour;
 
        [SerializeField] RectTransform m_LevelContaienr;
        [SerializeField] TextEx m_LevelLimit;
        [SerializeField] RectTransform m_FightPowerContainer;
        [SerializeField] TextEx m_FightPower;
 
        [SerializeField] Button m_Challenge;
        [SerializeField] TextEx m_ChallengeTitle;
        [SerializeField] ImageEx m_ChallengeImage;
        [SerializeField] Button m_FlashKill;
        [SerializeField] Text m_FlashKillCount;
        [SerializeField] ToggleButton m_MoreFlashToggle;
        [SerializeField] Text m_MoreFlashText;
 
        [SerializeField] Button m_Rank;
        [SerializeField] Button m_Gift;
        [SerializeField] Button m_NewSuccess;
 
        SkyTowerModel model { get { return ModelCenter.Instance.GetModel<SkyTowerModel>(); } }
        RankModel rankModel { get { return ModelCenter.Instance.GetModel<RankModel>(); } }
        DungeonModel dungeonModel { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
 
        ShowType showType = ShowType.None;
 
        #region Built-in
        protected override void BindController()
        {
        }
 
        protected override void AddListeners()
        {
            m_Challenge.SetListener(Challenge);
            m_ViewBoss.SetListener(() => { DisplayBossInfo(false); });
            m_ViewReward.SetListener(() => {
                if (showType == ShowType.Reward)
                {
                    return;
                }
                DisplayRewardInfo(false); });
            m_Rank.SetListener(() => {
                rankModel.jumpRankType = 6;
                WindowJumpMgr.Instance.WindowJumpTo(JumpUIType.GameRank);
            });
 
            m_Gift.SetListener(() => {
                WindowJumpMgr.Instance.WindowJumpToEx("SkyTowerServerGift", 1, 0, model.GetChallengeAwardOrder());
            });
 
            m_NewSuccess.SetListener(() => {
                ILAchievementModel.Instance.SetJumpSuccessGroup(201);
                WindowJumpMgr.Instance.WindowJumpToEx("NewAchievementActivityWin");
            });
 
            m_MoreFlashToggle.SetListener(() => {
                m_MoreFlashToggle.isOn = !m_MoreFlashToggle.isOn;
                DisplayChallengeButton();
            });
        }
 
        protected override void OnPreOpen()
        {
            model.OnFlashOverEvent += OnFlashOverEvent;
            showType = ShowType.None;
            model.ConfirmRedpoint02();
        }
 
        protected override void OnAfterOpen()
        {
        }
 
        protected override void OnPreClose()
        {
            model.OnFlashOverEvent -= OnFlashOverEvent;
        }
 
        protected override void OnAfterClose()
        {
        }
 
        protected override void OnActived()
        {
            base.OnActived();
            Display();
        }
 
        void Display()
        {
            DisplayTowerInfo();
            DisplayChallengeButton();
            DisplayRewardInfo(false);
        }
 
        #endregion
 
        private void OnFlashOverEvent(int state)
        {
            if (state == 2)
                Display();
        }
 
 
        private void DisplayTowerInfo()
        {
            m_TowerBehaviour.Display();
        }
 
        private void DisplayBossInfo(bool immediately)
        {
            if (showType == ShowType.Boss)
            {
                return;
            }
 
            showType = ShowType.Boss;
 
            m_BossContainer.SetActive(true);
            m_RewardContainer.SetActive(false);
 
            m_ViewBoss.transform.localScale = Vector3.one;
            m_ViewReward.transform.localScale = Vector3.one * 0.8f;
 
            m_ViewBossEffect.Play();
            m_ViewRewardEffect.Stop();
            m_BossEffect.Play();
 
            var towerConfig = SkyTowerConfig.Get(model.currentFloor);
            var npcConfig = NPCConfig.Get(towerConfig.bossId);
 
            if (npcConfig.Realm > 0 && RealmConfig.Has(npcConfig.Realm))
            {
                m_BossRealm.SetActive(true);
                var realmConfig = RealmConfig.Get(npcConfig.Realm);
                m_BossRealm.SetSprite(realmConfig.Img);
            }
            else
            {
                m_BossRealm.SetActive(false);
            }
 
            m_BossName.text = npcConfig.charName;
            m_BossLevel.text = Language.Get("HeadUpName_Monster", npcConfig.NPCLV);
            UI3DModelExhibition.Instance.ShowNPC(towerConfig.bossId, new Vector3(0, 30, 0), m_BossPortrait);
 
            if (immediately)
            {
                m_BossShowTween.SetEndState();
            }
            else
            {
                m_BossShowTween.Play();
            }
        }
 
        private void DisplayRewardInfo(bool immediately)
        {
 
            showType = ShowType.Reward;
 
            m_BossContainer.SetActive(false);
            m_RewardContainer.SetActive(true);
 
            m_ViewBoss.transform.localScale = Vector3.one * 0.8f;
            m_ViewReward.transform.localScale = Vector3.one;
 
            m_ViewBossEffect.Stop();
            m_ViewRewardEffect.Play();
            m_BossEffect.Stop();
 
            var config = SkyTowerConfig.Get(model.currentFloor);
            m_RewardBehaviour.Display(config.rewards);
 
            if (PlayerDatas.Instance.baseData.LV < config.levelLimit)
            {
                m_LevelContaienr.SetActive(true);
                m_LevelLimit.text = config.levelLimit.ToString();
                m_LevelLimit.colorType = PlayerDatas.Instance.baseData.LV >= config.levelLimit ? TextColType.Green : TextColType.Red;
            }
            else
            {
                m_LevelContaienr.SetActive(false);
            }
 
            if (PlayerDatas.Instance.baseData.LV >= config.levelLimit)
            {
                m_FightPowerContainer.SetActive(true);
                var fightPower = NPCExConfig.Get(config.bossId).SuppressFightPower;
                m_FightPower.text = UIHelper.ReplaceLargeNum(fightPower);
                m_FightPower.colorType = PlayerDatas.Instance.baseData.FightPoint >= (ulong)fightPower ? TextColType.Green : TextColType.Red;
            }
            else
            {
                m_FightPowerContainer.SetActive(false);
            }
 
            if (immediately)
            {
                m_RewardShowTween.SetEndState();
            }
            else
            {
                m_RewardShowTween.Play();
            }
        }
 
        private void DisplayChallengeButton()
        {
            int count = GetFlashKillCount();
            if (count == 0)
            {
                m_FlashKill.SetActive(false);
                m_Challenge.SetActive(true);
                m_ChallengeTitle.text = Language.Get(model.allPassed ? "SkyTower4" : "Multiple_Challenge");
                m_ChallengeImage.gray = !model.IsChallengable();
            }
            else
            {
                bool needMoreFlash = model.currentFloor > GeneralDefine.flashCntMoreArr[0];
 
                m_MoreFlashToggle.SetActive(needMoreFlash);
                m_MoreFlashText.text = Language.Get("WorldBoss_Endurance0", GeneralDefine.flashKillMaxCount);
 
                m_FlashKill.SetActive(true);
                m_Challenge.SetActive(false);
                m_FlashKillCount.text = count == 1 ? string.Empty : count.ToString();
 
                m_FlashKill.AddListener(() => {
 
                    if (!dungeonModel.CanFlashKill())
                    {
                        SysNotifyMgr.Instance.ShowTip("InFBCanotDo");
                        return;
                    }
 
                    var pack = new CB108_tagCMFBQuickPass();
                    pack.MapID = SkyTowerModel.DATA_MAPID;
                    pack.LineID = (ushort)(model.currentFloor + count - 1);
                    GameNetSystem.Instance.SendInfo(pack);
                });
            }
        }
 
        // 前20层不用雷诛
        int GetFlashKillCount()
        {
            int count = 0;
            if (model.currentFloor <= GeneralDefine.flashOpenArr[0])
                return count;
 
            int maxCount = GeneralDefine.flashKillMaxCount;
 
            if (model.currentFloor <= GeneralDefine.flashCntMoreArr[0] || !m_MoreFlashToggle.isOn)
            {
                maxCount = 1;
            }
 
            for (int i = 0; i < maxCount; i++)
            { 
                var config = SkyTowerConfig.Get(model.currentFloor + i);
                if (config == null)
                    break;
 
                var fightPower = NPCExConfig.Get(config.bossId).SuppressFightPower;
                if (PlayerDatas.Instance.baseData.FightPoint >= (ulong)fightPower * GeneralDefine.fightPowerMore)
                {
                    count++;
                }
                else
                {
                    //遇到第一个卡点就停止
                    break;
                }
            }
            return count;
        }
 
        private void Challenge()
        {
            model.ConfirmRedpoint03();
            if (model.allPassed)
            {
                return;
            }
 
            var config = SkyTowerConfig.Get(model.currentFloor);
            var myFightPoint = PlayerDatas.Instance.baseData.FightPoint;
            if (myFightPoint >= (ulong)NPCExConfig.Get(config.bossId).SuppressFightPower)
            {
                model.RequestChallenge();
            }
            else
            {
                ConfirmCancel.ShowPopConfirm(
                    Language.Get("Mail101"),
                    Language.Get("RuneTower25", UIHelper.ReplaceLargeNum(NPCExConfig.Get(config.bossId).SuppressFightPower)),
                    (bool ok) =>
                    {
                        if (ok)
                        {
                            model.RequestChallenge();
                        }
                    }
                    );
            }
        }
 
        public enum ShowType
        {
            None,
            Boss,
            Reward,
        }
 
    }
 
}