少年修仙传客户端代码仓库
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Friday, January 18, 2019
//--------------------------------------------------------
 
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
 
namespace Snxxz.UI
{
    [XLua.Hotfix]
    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] RewardPreviewGroup m_RewardBehaviour;
        [SerializeField] TextEx m_LevelLimit;
        [SerializeField] TextEx m_FightPower;
 
        [SerializeField] Button m_Challenge;
        [SerializeField] TextEx m_ChallengeTitle;
        [SerializeField] ImageEx m_ChallengeImage;
 
        SkyTowerModel model { get { return ModelCenter.Instance.GetModel<SkyTowerModel>(); } }
 
        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(() => { DisplayRewardInfo(false); });
        }
 
        protected override void OnPreOpen()
        {
            showType = ShowType.None;
            model.ConfirmRedpoint02();
        }
 
        protected override void OnAfterOpen()
        {
        }
 
        protected override void OnPreClose()
        {
        }
 
        protected override void OnAfterClose()
        {
        }
 
        protected override void OnActived()
        {
            base.OnActived();
            DisplayTowerInfo();
            DisplayChallengeButton();
            DisplayRewardInfo(false);
        }
 
        #endregion
 
        private void DisplayTowerInfo()
        {
            m_TowerBehaviour.Display();
        }
 
        private void DisplayBossInfo(bool immediately)
        {
            if (showType == ShowType.Boss)
            {
                return;
            }
 
            showType = ShowType.Boss;
 
            m_BossContainer.gameObject.SetActive(true);
            m_RewardContainer.gameObject.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.ClientRealm > 0 && RealmConfig.Has(npcConfig.ClientRealm))
            {
                m_BossRealm.gameObject.SetActive(true);
                var realmConfig = RealmConfig.Get(npcConfig.ClientRealm);
                m_BossRealm.SetSprite(realmConfig.Img);
            }
            else
            {
                m_BossRealm.gameObject.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)
        {
            if (showType == ShowType.Reward)
            {
                return;
            }
 
            showType = ShowType.Reward;
 
            m_BossContainer.gameObject.SetActive(false);
            m_RewardContainer.gameObject.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);
 
            m_FightPower.text = config.fightPower.ToString();
            m_FightPower.colorType = PlayerDatas.Instance.baseData.FightPoint >= config.fightPower ? TextColType.Green : TextColType.Red;
 
            m_LevelLimit.text = config.levelLimit.ToString();
            m_LevelLimit.colorType = PlayerDatas.Instance.baseData.LV >= config.levelLimit ? TextColType.Green : TextColType.Red;
 
            if (immediately)
            {
                m_RewardShowTween.SetEndState();
            }
            else
            {
                m_RewardShowTween.Play();
            }
        }
 
        private void DisplayChallengeButton()
        {
            m_ChallengeTitle.text = Language.Get(model.allPassed ? "SkyTower4" : "Multiple_Challenge");
            m_ChallengeImage.gray = !model.IsChallengable();
        }
 
        private void Challenge()
        {
            model.ConfirmRedpoint03();
            if (model.allPassed)
            {
                return;
            }
 
            var config = SkyTowerConfig.Get(model.currentFloor);
            var myFightPoint = PlayerDatas.Instance.baseData.FightPoint;
            if (myFightPoint >= config.fightPower)
            {
                model.RequestChallenge();
            }
            else
            {
                ConfirmCancel.ShowPopConfirm(
                    Language.Get("Mail101"),
                    Language.Get("RuneTower25", config.fightPower),
                    (bool ok) =>
                    {
                        if (ok)
                        {
                            model.RequestChallenge();
                        }
                    }
                    );
            }
        }
 
        public enum ShowType
        {
            None,
            Boss,
            Reward,
        }
 
    }
 
}