提交 | 用户 | age
|
eb222a
|
1 |
//-------------------------------------------------------- |
CX |
2 |
// [Author]: 第二世界 |
|
3 |
// [ Date ]: Thursday, July 18, 2019 |
|
4 |
//-------------------------------------------------------- |
|
5 |
|
|
6 |
using System; |
|
7 |
using System.Collections; |
|
8 |
using System.Collections.Generic; |
|
9 |
using UnityEngine; |
|
10 |
using UnityEngine.UI; |
|
11 |
using DG.Tweening; |
|
12 |
|
4465b6
|
13 |
namespace vnxbqy.UI |
eb222a
|
14 |
{ |
CX |
15 |
|
|
16 |
public class EquipStarSuccessWin : Window |
|
17 |
{ |
|
18 |
[SerializeField] ScrollRect m_ScrollRect; |
|
19 |
[SerializeField] Star[] m_Stars; |
|
20 |
[SerializeField] ItemCell m_ItemCell; |
|
21 |
[SerializeField] Text m_EquipStar; |
|
22 |
[SerializeField] BaseProperty[] m_BaseProperties; |
|
23 |
|
|
24 |
[SerializeField] RectTransform m_CloseTip; |
|
25 |
[SerializeField] Button m_Close; |
|
26 |
|
|
27 |
List<EquipStarSuccessActiveItemBehaviour> activeItemBehaviours = new List<EquipStarSuccessActiveItemBehaviour>(); |
|
28 |
|
|
29 |
EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } } |
|
30 |
PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } } |
|
31 |
EquipStarModel starModel { get { return ModelCenter.Instance.GetModel<EquipStarModel>(); } } |
|
32 |
EquipStarSuccessModel model { get { return ModelCenter.Instance.GetModel<EquipStarSuccessModel>(); } } |
|
33 |
EquipStrengthModel strengthModel { get { return ModelCenter.Instance.GetModel<EquipStrengthModel>(); } } |
b849ed
|
34 |
EquipTrainModel equipTrainModel { get { return ModelCenter.Instance.GetModel<EquipTrainModel>(); } } |
eb222a
|
35 |
|
6e1f70
|
36 |
int ActiveSuit = -1; |
04d2f8
|
37 |
string ActiveSuitString = string.Empty; |
eb222a
|
38 |
#region Built-in |
CX |
39 |
protected override void BindController() |
|
40 |
{ |
|
41 |
} |
|
42 |
|
|
43 |
protected override void AddListeners() |
|
44 |
{ |
|
45 |
m_Close.SetListener(() => { WindowCenter.Instance.Close<EquipStarSuccessWin>(); }); |
|
46 |
} |
|
47 |
|
|
48 |
protected override void OnPreOpen() |
|
49 |
{ |
f23c81
|
50 |
m_CloseTip.SetActive(false); |
H |
51 |
m_Close.SetActive(false); |
6d4c04
|
52 |
foreach (var behaviour in activeItemBehaviours) |
CX |
53 |
{ |
f23c81
|
54 |
behaviour.SetActive(false); |
6d4c04
|
55 |
} |
eb222a
|
56 |
} |
CX |
57 |
|
|
58 |
protected override void OnAfterOpen() |
|
59 |
{ |
|
60 |
} |
|
61 |
|
|
62 |
protected override void OnPreClose() |
|
63 |
{ |
|
64 |
} |
|
65 |
|
|
66 |
protected override void OnAfterClose() |
|
67 |
{ |
6e1f70
|
68 |
if (ActiveSuit < 0) return; |
H |
69 |
ActiveSuit = -1; |
04d2f8
|
70 |
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("ActiveSuitEff", ActiveSuitString), (bool isOk) => |
6e1f70
|
71 |
{ |
H |
72 |
if (isOk) |
|
73 |
{ |
47fa2f
|
74 |
equipModel.SelectSet(model.equipPosition.x); |
6e1f70
|
75 |
equipModel.selectedStarLevel.value = ActiveSuit; |
e594ad
|
76 |
equipModel.isOpenSuiteAttrRect = true; |
6e1f70
|
77 |
WindowCenter.Instance.Close<EquipFrameWin>(); |
b68077
|
78 |
WindowCenter.Instance.Open<KnapSackWin>(false, 0); |
6e1f70
|
79 |
|
H |
80 |
} |
|
81 |
}); |
|
82 |
equipModel.UpdateSuitRedPoint(model.equipPosition.x); |
04d2f8
|
83 |
|
H |
84 |
ActiveSuitString = string.Empty; |
6e1f70
|
85 |
return; |
eb222a
|
86 |
} |
6e1f70
|
87 |
|
eb222a
|
88 |
|
CX |
89 |
protected override void OnActived() |
|
90 |
{ |
|
91 |
base.OnActived(); |
|
92 |
|
207a25
|
93 |
Clock.AlarmAfter(1f, () => |
eb222a
|
94 |
{ |
f23c81
|
95 |
m_Close.SetActive(true); |
H |
96 |
m_CloseTip.SetActive(true); |
eb222a
|
97 |
}); |
CX |
98 |
|
|
99 |
DisplayItem(); |
|
100 |
DisplayStars(); |
|
101 |
DisplayBaseProperty(); |
|
102 |
DisplaySpecialEffects(); |
|
103 |
} |
|
104 |
|
|
105 |
#endregion |
|
106 |
|
|
107 |
private void DisplayItem() |
|
108 |
{ |
|
109 |
var equip = equipModel.GetEquip(model.equipPosition); |
f23c81
|
110 |
m_ItemCell.SetActive(true); |
eb222a
|
111 |
m_ItemCell.Init(packModel.GetItemByGuid(equip)); |
CX |
112 |
|
f23c81
|
113 |
m_EquipStar.SetActive(true); |
dee74a
|
114 |
m_EquipStar.text = Language.Get("EquipStarLevel", model.star); |
eb222a
|
115 |
} |
CX |
116 |
|
|
117 |
private void DisplayStars() |
|
118 |
{ |
|
119 |
var maxStarLevel = EquipStarModel.GetMaxStarLevel(model.equipPosition.x); |
|
120 |
var currentStar = model.star; |
|
121 |
|
d56e0c
|
122 |
var iconCnt = m_Stars.Length; |
H |
123 |
for (int i = 0; i < iconCnt; i++) |
eb222a
|
124 |
{ |
CX |
125 |
var behaviour = m_Stars[i]; |
|
126 |
if (i < maxStarLevel) |
|
127 |
{ |
|
128 |
if (i < currentStar) |
|
129 |
{ |
d56e0c
|
130 |
var loopIndex = (currentStar / iconCnt * iconCnt + i < currentStar ? currentStar / iconCnt * iconCnt + i : i) / iconCnt; |
H |
131 |
behaviour.Display(true, loopIndex); |
|
132 |
if (i == (currentStar - 1) % iconCnt) |
eb222a
|
133 |
{ |
d56e0c
|
134 |
behaviour.Display(false, loopIndex); |
6d4c04
|
135 |
Clock.AlarmAfter(1f, () => |
CX |
136 |
{ |
d56e0c
|
137 |
behaviour.Display(true, loopIndex); |
6d4c04
|
138 |
behaviour.PlayScaleAnimation(); |
CX |
139 |
}); |
eb222a
|
140 |
} |
CX |
141 |
} |
|
142 |
else |
|
143 |
{ |
d56e0c
|
144 |
behaviour.Display(false, 0); |
eb222a
|
145 |
} |
CX |
146 |
} |
|
147 |
else |
|
148 |
{ |
|
149 |
behaviour.Hide(); |
|
150 |
} |
|
151 |
} |
|
152 |
|
|
153 |
} |
|
154 |
|
|
155 |
private void DisplayBaseProperty() |
|
156 |
{ |
|
157 |
var configs = EquipStarConfig.GetConfigs(model.equipPosition.x, model.equipPosition.y); |
|
158 |
EquipStarConfig beforeConfig = null; |
|
159 |
EquipStarConfig nowConfig = null; |
|
160 |
|
|
161 |
for (int i = 0; i < configs.Count; i++) |
|
162 |
{ |
|
163 |
var config = configs[i]; |
|
164 |
if (config.Star == model.star - 1) |
|
165 |
{ |
|
166 |
beforeConfig = config; |
|
167 |
} |
|
168 |
else if (config.Star == model.star) |
|
169 |
{ |
|
170 |
nowConfig = config; |
|
171 |
} |
|
172 |
} |
|
173 |
|
|
174 |
var nowValues = nowConfig.BaseAttrInfo; |
|
175 |
var beforeValues = new Int2[nowValues.Length]; |
|
176 |
if (beforeConfig != null) |
|
177 |
{ |
|
178 |
for (var i = 0; i < beforeConfig.BaseAttrInfo.Length; i++) |
|
179 |
{ |
|
180 |
beforeValues[i] = beforeConfig.BaseAttrInfo[i]; |
|
181 |
} |
|
182 |
} |
|
183 |
|
|
184 |
for (int i = 0; i < m_BaseProperties.Length; i++) |
|
185 |
{ |
|
186 |
var behaviour = m_BaseProperties[i]; |
|
187 |
if (i < nowValues.Length) |
|
188 |
{ |
|
189 |
behaviour.Display(nowValues[i].x, beforeValues[i].y, nowValues[i].y); |
|
190 |
} |
|
191 |
else |
|
192 |
{ |
|
193 |
behaviour.Hide(); |
|
194 |
} |
|
195 |
} |
|
196 |
} |
|
197 |
|
|
198 |
private void DisplaySpecialEffects() |
|
199 |
{ |
|
200 |
m_ScrollRect.verticalNormalizedPosition = 0f; |
|
201 |
DisplaySuitEffect(); |
|
202 |
DisplayStarProperty(); |
|
203 |
DisplayGemHole(); |
1ef700
|
204 |
//DisplayStrengthLevel(); |
eb222a
|
205 |
DisplayTrainLevel(); |
CX |
206 |
} |
|
207 |
|
|
208 |
private void DisplaySuitEffect() |
|
209 |
{ |
14118d
|
210 |
var star = starModel.GetStarLevel(model.equipPosition); |
H |
211 |
if (!equipModel.IsDressedInSuit(model.equipPosition)) |
|
212 |
{ |
|
213 |
return; |
|
214 |
} |
|
215 |
|
eb222a
|
216 |
if (model.star % 3 == 0) |
CX |
217 |
{ |
|
218 |
var count = 0; |
c95dd3
|
219 |
if (model.equipPosition.y <= 8) |
eb222a
|
220 |
{ |
c95dd3
|
221 |
for (int i = 1; i <= 8; i++) |
eb222a
|
222 |
{ |
14118d
|
223 |
var equipPosition = new Int2(model.equipPosition.x, i); |
H |
224 |
var curStar = starModel.GetStarLevel(equipPosition); |
|
225 |
var isSuit = equipModel.IsDressedInSuit(equipPosition); |
|
226 |
if (isSuit && curStar >= model.star) |
c95dd3
|
227 |
{ |
H |
228 |
count++; |
|
229 |
} |
eb222a
|
230 |
} |
CX |
231 |
} |
|
232 |
var behaviour = GetStarSuccessActiveItemBehaviour(); |
|
233 |
var job = PlayerDatas.Instance.baseData.Job; |
17c59c
|
234 |
|
eb222a
|
235 |
switch (count) |
CX |
236 |
{ |
|
237 |
case 2: |
6e1f70
|
238 |
ActiveSuit = model.star; |
eb222a
|
239 |
var twoConfigs = EquipSuitConfig.GetConfigs(job, model.equipPosition.x, EquipSuitType.TwoSuit); |
CX |
240 |
var twoConfig = twoConfigs.Find(x => { return x.star == model.star; }); |
|
241 |
behaviour.DisplaySuitEffect(model.star, EquipSuitType.TwoSuit, twoConfig.attr); |
04d2f8
|
242 |
ActiveSuitString = behaviour.GetContent(); |
eb222a
|
243 |
break; |
CX |
244 |
case 5: |
6e1f70
|
245 |
ActiveSuit = model.star; |
eb222a
|
246 |
var fiveConfigs = EquipSuitConfig.GetConfigs(job, model.equipPosition.x, EquipSuitType.FiveSuit); |
CX |
247 |
var fiveConfig = fiveConfigs.Find(x => { return x.star == model.star; }); |
|
248 |
behaviour.DisplaySuitEffect(model.star, EquipSuitType.FiveSuit, fiveConfig.attr); |
04d2f8
|
249 |
ActiveSuitString = behaviour.GetContent(); |
eb222a
|
250 |
break; |
CX |
251 |
case 8: |
6e1f70
|
252 |
ActiveSuit = model.star; |
eb222a
|
253 |
var eightConfigs = EquipSuitConfig.GetConfigs(job, model.equipPosition.x, EquipSuitType.EightSuit); |
CX |
254 |
var eightConfig = eightConfigs.Find(x => { return x.star == model.star; }); |
|
255 |
if (eightConfig.skillID > 0) |
|
256 |
{ |
|
257 |
behaviour.DisplaySuitEffect(model.star, eightConfig.description); |
|
258 |
} |
|
259 |
else |
|
260 |
{ |
|
261 |
behaviour.DisplaySuitEffect(model.star, EquipSuitType.EightSuit, eightConfig.attr); |
|
262 |
} |
04d2f8
|
263 |
ActiveSuitString = behaviour.GetContent(); |
eb222a
|
264 |
break; |
17c59c
|
265 |
default: |
f23c81
|
266 |
behaviour.SetActive(false); |
17c59c
|
267 |
break; |
H |
268 |
|
eb222a
|
269 |
} |
CX |
270 |
} |
|
271 |
|
|
272 |
} |
|
273 |
|
|
274 |
private void DisplayStarProperty() |
|
275 |
{ |
|
276 |
var beforeConfig = EquipStarConfig.Get(model.equipPosition.x, model.equipPosition.y, model.star - 1); |
|
277 |
var nowConfig = EquipStarConfig.Get(model.equipPosition.x, model.equipPosition.y, model.star); |
|
278 |
|
17c59c
|
279 |
var behaviour = GetStarSuccessActiveItemBehaviour(); |
eb222a
|
280 |
if (beforeConfig == null || beforeConfig.StarAttrInfo.Length != nowConfig.StarAttrInfo.Length) |
CX |
281 |
{ |
|
282 |
behaviour.DisplayStarProperty(model.star, nowConfig.StarAttrInfo[nowConfig.StarAttrInfo.Length - 1]); |
|
283 |
} |
17c59c
|
284 |
else |
f23c81
|
285 |
behaviour.SetActive(false); |
eb222a
|
286 |
} |
CX |
287 |
|
|
288 |
private void DisplayGemHole() |
|
289 |
{ |
17c59c
|
290 |
var behaviour = GetStarSuccessActiveItemBehaviour(); |
eb222a
|
291 |
if (model.star == 2 || model.star == 5) |
CX |
292 |
{ |
|
293 |
behaviour.DisplayGemHole(model.star); |
|
294 |
} |
17c59c
|
295 |
else |
f23c81
|
296 |
behaviour.SetActive(false); |
eb222a
|
297 |
} |
CX |
298 |
|
1ef700
|
299 |
//private void DisplayStrengthLevel() |
H |
300 |
//{ |
|
301 |
// var type = EquipStrengthModel.GetEquipStrengthType(model.equipPosition.y); |
|
302 |
// var beforeLevel = strengthModel.GetEquipLevelMax(type, model.star - 1); |
|
303 |
// var nowLevel = strengthModel.GetEquipLevelMax(type, model.star); |
|
304 |
// var behaviour = GetStarSuccessActiveItemBehaviour(); |
|
305 |
// if (beforeLevel != nowLevel) |
|
306 |
// { |
|
307 |
// behaviour.DisplayStrengthLevelLimit(model.star, nowLevel); |
|
308 |
// } |
|
309 |
// else |
f23c81
|
310 |
// behaviour.SetActive(false); |
1ef700
|
311 |
//} |
eb222a
|
312 |
|
CX |
313 |
private void DisplayTrainLevel() |
|
314 |
{ |
b849ed
|
315 |
if (model.equipPosition.x < equipTrainModel.limitLevel) |
H |
316 |
return; |
eb222a
|
317 |
var type = EquipTrainModel.GetTrainType(model.equipPosition.y); |
CX |
318 |
var beforeConfig = WashLevelMaxConfig.Get(type, model.star - 1); |
|
319 |
var nowConfig = WashLevelMaxConfig.Get(type, model.star); |
17c59c
|
320 |
var behaviour = GetStarSuccessActiveItemBehaviour(); |
eb222a
|
321 |
if (beforeConfig == null || beforeConfig.levelMax != nowConfig.levelMax) |
CX |
322 |
{ |
|
323 |
behaviour.DisplayTrainLevelLimit(model.star, nowConfig.levelMax); |
|
324 |
} |
17c59c
|
325 |
else |
f23c81
|
326 |
behaviour.SetActive(false); |
eb222a
|
327 |
} |
CX |
328 |
|
|
329 |
private EquipStarSuccessActiveItemBehaviour GetStarSuccessActiveItemBehaviour() |
|
330 |
{ |
|
331 |
foreach (var item in activeItemBehaviours) |
|
332 |
{ |
|
333 |
if (!item.gameObject.activeInHierarchy) |
|
334 |
{ |
f23c81
|
335 |
item.SetActive(true); |
eb222a
|
336 |
return item; |
CX |
337 |
} |
|
338 |
} |
|
339 |
|
|
340 |
var instance = UIUtility.CreateWidget("EquipStarSuccessActiveItemBehaviour", "EquipStarSuccessActiveItemBehaviour"); |
|
341 |
instance.transform.SetParentEx(m_ScrollRect.content, Vector3.zero, Quaternion.identity, Vector3.one); |
|
342 |
var behaviour = instance.GetComponent<EquipStarSuccessActiveItemBehaviour>(); |
|
343 |
activeItemBehaviours.Add(behaviour); |
|
344 |
return behaviour; |
|
345 |
} |
|
346 |
|
|
347 |
[System.Serializable] |
|
348 |
public class Star |
|
349 |
{ |
|
350 |
public RectTransform container; |
|
351 |
public Image imageBase; |
|
352 |
public Image imageStar; |
|
353 |
|
d56e0c
|
354 |
public void Display(bool active, int loopIndex) |
eb222a
|
355 |
{ |
f23c81
|
356 |
container.SetActive(true); |
H |
357 |
imageStar.SetActive(active); |
eb222a
|
358 |
imageStar.transform.localScale = Vector3.one; |
d56e0c
|
359 |
imageStar.SetSprite("ImgStar_" + loopIndex); |
eb222a
|
360 |
} |
CX |
361 |
|
|
362 |
public void Hide() |
|
363 |
{ |
f23c81
|
364 |
container.SetActive(false); |
eb222a
|
365 |
} |
CX |
366 |
|
|
367 |
public void PlayScaleAnimation() |
|
368 |
{ |
|
369 |
imageStar.transform.localScale = Vector3.one * 5; |
|
370 |
imageStar.transform.DOScale(Vector3.one, 0.5f); |
|
371 |
} |
|
372 |
|
|
373 |
} |
|
374 |
|
|
375 |
[System.Serializable] |
|
376 |
public class BaseProperty |
|
377 |
{ |
|
378 |
public RectTransform container; |
|
379 |
public Text title; |
|
380 |
public Text before; |
|
381 |
public Text now; |
|
382 |
|
|
383 |
public void Hide() |
|
384 |
{ |
f23c81
|
385 |
container.SetActive(false); |
eb222a
|
386 |
} |
CX |
387 |
|
|
388 |
public void Display(int id, int beforeValue, int nowValue) |
|
389 |
{ |
f23c81
|
390 |
container.SetActive(true); |
eb222a
|
391 |
|
CX |
392 |
var config = PlayerPropertyConfig.Get(id); |
|
393 |
title.text = string.Format("{0}:", config.Name); |
|
394 |
|
|
395 |
before.text = beforeValue.ToString(); |
|
396 |
now.text = nowValue.ToString(); |
|
397 |
} |
|
398 |
} |
|
399 |
|
|
400 |
|
|
401 |
} |
|
402 |
|
|
403 |
} |
|
404 |
|
|
405 |
|
|
406 |
|
|
407 |
|