提交 | 用户 | age
|
e92fd5
|
1 |
//-------------------------------------------------------- |
CX |
2 |
// [Author]: 第二世界 |
|
3 |
// [ Date ]: Thursday, February 28, 2019 |
|
4 |
//-------------------------------------------------------- |
|
5 |
|
|
6 |
using System; |
|
7 |
using System.Collections; |
|
8 |
using System.Collections.Generic; |
|
9 |
using UnityEngine; |
|
10 |
using UnityEngine.UI; |
|
11 |
|
4465b6
|
12 |
namespace vnxbqy.UI |
7c2ade
|
13 |
{ |
e92fd5
|
14 |
|
CX |
15 |
public class EquipStarWin : Window |
|
16 |
{ |
dbdbd5
|
17 |
[SerializeField] RectTransform m_LevelContainer; |
8222f7
|
18 |
[SerializeField] ScrollRect m_LevelScrollRect; |
eb1a8d
|
19 |
[SerializeField] RectTransform m_OperateContainer; |
CX |
20 |
[SerializeField] RectTransform m_EmptyContainer; |
91c831
|
21 |
[SerializeField] Star[] m_Stars; |
7c2ade
|
22 |
[SerializeField] ItemCell m_TargetEquip; |
807064
|
23 |
[SerializeField] Text m_EquipStar; |
d56e0c
|
24 |
[SerializeField] EquipStarUpgradeSpecialMaterialBehaviour m_SpecialMaterial1; |
H |
25 |
[SerializeField] EquipStarUpgradeSpecialMaterialBehaviour m_SpecialMaterial2; |
652343
|
26 |
|
9842ca
|
27 |
[SerializeField] RectTransform m_EmptyHint; |
5100d2
|
28 |
[SerializeField] RectTransform m_PropertyDetails; |
7268a7
|
29 |
[SerializeField] BaseProperty[] m_BasePropertys; |
CX |
30 |
[SerializeField] Text[] m_LevelUpPropertys; |
7c2ade
|
31 |
[SerializeField] Button m_StarUpgrade; |
3e1bdb
|
32 |
[SerializeField] RectTransform m_MaxStarLevelHint; |
652343
|
33 |
[SerializeField] Button m_Preview; |
dbdbd5
|
34 |
|
3c35f8
|
35 |
[SerializeField] ToggleButton m_Auto; |
H |
36 |
[SerializeField] Text m_AutoMoney; |
|
37 |
[SerializeField] RectTransform m_AutoContainer; |
|
38 |
|
dbdbd5
|
39 |
List<EquipStarLevelSelectBehaviour> levelBehaviours = new List<EquipStarLevelSelectBehaviour>(); |
ccbc64
|
40 |
int curTime = 0; |
7c2ade
|
41 |
|
CX |
42 |
EquipStarModel model { get { return ModelCenter.Instance.GetModel<EquipStarModel>(); } } |
acc67c
|
43 |
EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } } |
7c2ade
|
44 |
PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } } |
3ed42e
|
45 |
EquipStarEffectTipModel starEffectTipModel { get { return ModelCenter.Instance.GetModel<EquipStarEffectTipModel>(); } } |
fffbb5
|
46 |
StoreModel storeModel { get { return ModelCenter.Instance.GetModel<StoreModel>(); } } |
ccbc64
|
47 |
|
H |
48 |
|
e92fd5
|
49 |
#region Built-in |
CX |
50 |
protected override void BindController() |
|
51 |
{ |
ad10fe
|
52 |
|
e92fd5
|
53 |
} |
CX |
54 |
|
|
55 |
protected override void AddListeners() |
|
56 |
{ |
ad10fe
|
57 |
m_StarUpgrade.SetListener(StarUpgrade); |
3ed42e
|
58 |
m_Preview.SetListener(() => |
CX |
59 |
{ |
|
60 |
var equipStarEffectTipModel = ModelCenter.Instance.GetModel<EquipStarEffectTipModel>(); |
|
61 |
equipStarEffectTipModel.Preview(new Int2(model.selectedLevel.value, model.selectedPlace.value)); |
|
62 |
}); |
3c35f8
|
63 |
m_Auto.SetListener(ShowAuto); |
e92fd5
|
64 |
} |
CX |
65 |
|
3c35f8
|
66 |
private void ShowAuto() |
e92fd5
|
67 |
{ |
3c35f8
|
68 |
m_Auto.isOn = !m_Auto.isOn; |
d56e0c
|
69 |
model.autoBuy.value = -1; |
3c35f8
|
70 |
} |
H |
71 |
|
|
72 |
public void ShowAutoText(int money) |
|
73 |
{ |
cd52cf
|
74 |
var color = PlayerDatas.Instance.baseData.bindDiamond >= money ? TextColType.Green : TextColType.Red; |
3c35f8
|
75 |
m_AutoMoney.text = Language.Get("StartUpAutoBuy", UIHelper.AppendColor(color, money.ToString(), true)); |
H |
76 |
|
|
77 |
} |
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
protected override void OnPreOpen() |
|
83 |
{ |
|
84 |
DTCB511_tagGCEquipStarAutoBuyCostInfo.QueryAutoStarEvent += QueryAutoStarEvent; |
fffbb5
|
85 |
storeModel.RefreshBuyResultEvent += OnItemCountRefresh; |
aa7987
|
86 |
if (model.selectedLevel.value == 0) |
CX |
87 |
{ |
f20ff4
|
88 |
Int2 equipPosition; |
H |
89 |
if (model.jumpEquipPos != Int2.zero) |
|
90 |
{ |
|
91 |
equipPosition = model.jumpEquipPos; |
|
92 |
model.jumpEquipPos = Int2.zero; |
|
93 |
} |
|
94 |
else |
|
95 |
{ |
|
96 |
equipPosition = model.GetRecommendEquipPosition(); |
|
97 |
} |
a72128
|
98 |
model.SelectLevel(equipPosition.x); |
d0b3f7
|
99 |
model.SelectPlace(equipPosition); |
aa7987
|
100 |
} |
6e3256
|
101 |
|
d57686
|
102 |
DisplayBaseInfo(); |
ccbc64
|
103 |
|
e92fd5
|
104 |
} |
CX |
105 |
|
|
106 |
protected override void OnAfterOpen() |
|
107 |
{ |
|
108 |
} |
|
109 |
|
|
110 |
protected override void OnPreClose() |
|
111 |
{ |
fffbb5
|
112 |
storeModel.RefreshBuyResultEvent -= OnItemCountRefresh; |
3c35f8
|
113 |
DTCB511_tagGCEquipStarAutoBuyCostInfo.QueryAutoStarEvent -= QueryAutoStarEvent; |
cf2457
|
114 |
|
e92fd5
|
115 |
} |
CX |
116 |
|
|
117 |
protected override void OnAfterClose() |
|
118 |
{ |
cf2457
|
119 |
model.ResetOperateParams(); |
91c831
|
120 |
} |
CX |
121 |
|
|
122 |
protected override void OnActived() |
|
123 |
{ |
|
124 |
base.OnActived(); |
|
125 |
DisplayDynamicInfo(true); |
e92fd5
|
126 |
} |
d57686
|
127 |
|
CX |
128 |
protected override void LateUpdate() |
|
129 |
{ |
|
130 |
base.LateUpdate(); |
|
131 |
DisplayDynamicInfo(false); |
|
132 |
} |
|
133 |
|
e92fd5
|
134 |
#endregion |
7c2ade
|
135 |
|
3c35f8
|
136 |
void QueryAutoStarEvent(HB511_tagGCEquipStarAutoBuyCostInfo pack) |
H |
137 |
{ |
|
138 |
if (pack.ClassLV != model.selectedLevel.value) return; |
|
139 |
if (pack.EquipPlace != model.selectedPlace.value) return; |
|
140 |
var equipPosition = new Int2(model.selectedLevel.value, model.selectedPlace.value); |
|
141 |
var currentStarLevel = model.GetEquipStarLevel(equipPosition); |
|
142 |
if (pack.CurStar != currentStarLevel) return; |
|
143 |
|
70fa65
|
144 |
model.autoBuy.value = pack.CurRate >= 100 ? (int)pack.AutoBuyCostMoney : -2; |
3c35f8
|
145 |
model.autoBuy.dirty = true; |
H |
146 |
//model.starUpgradeProbability.value = pack.CurRate; |
|
147 |
} |
|
148 |
|
fffbb5
|
149 |
private void OnItemCountRefresh(int index) |
372516
|
150 |
{ |
3aa853
|
151 |
var equipPosition = new Int2(model.selectedLevel.value, model.selectedPlace.Fetch());
|
H |
152 |
var currentStarLevel = model.GetEquipStarLevel(equipPosition); |
|
153 |
DisplayMaterialSlots(equipPosition, currentStarLevel); |
372516
|
154 |
} |
H |
155 |
|
|
156 |
|
|
157 |
|
7c2ade
|
158 |
private void DisplayBaseInfo() |
CX |
159 |
{ |
dbdbd5
|
160 |
CreateLevelBehaviours(); |
a33a82
|
161 |
} |
3c35f8
|
162 |
|
7c2ade
|
163 |
|
CX |
164 |
private void DisplayDynamicInfo(bool force) |
|
165 |
{ |
0a5fe1
|
166 |
if (force || model.selectedLevel.dirty) |
CX |
167 |
{ |
8222f7
|
168 |
DisplayCandidateSlots(model.selectedLevel.Fetch(), force); |
0a5fe1
|
169 |
} |
CX |
170 |
|
3d54e4
|
171 |
if (force || model.selectedPlace.dirty) |
d57686
|
172 |
{ |
16acef
|
173 |
model.autoBuy.dirty = true; |
eb1a8d
|
174 |
var place = model.selectedPlace.Fetch(); |
CX |
175 |
if (place == 0) |
5100d2
|
176 |
{ |
f23c81
|
177 |
m_OperateContainer.SetActive(false); |
H |
178 |
m_EmptyContainer.SetActive(true); |
5100d2
|
179 |
} |
CX |
180 |
else |
|
181 |
{ |
eb1a8d
|
182 |
var currentStarLevel = 0; |
CX |
183 |
var equipPosition = new Int2(model.selectedLevel.value, place); |
f23c81
|
184 |
m_OperateContainer.SetActive(true); |
H |
185 |
m_EmptyContainer.SetActive(false); |
eb1a8d
|
186 |
var equipGuid = equipModel.GetEquip(equipPosition); |
CX |
187 |
var equip = packModel.GetItemByGuid(equipGuid); |
|
188 |
if (equip != null) |
|
189 |
{ |
f23c81
|
190 |
m_TargetEquip.SetActive(true); |
eb1a8d
|
191 |
m_TargetEquip.Init(equip); |
CX |
192 |
m_TargetEquip.button.SetListener(ViewEquipTip); |
|
193 |
currentStarLevel = model.GetEquipStarLevel(equipPosition); |
|
194 |
|
f23c81
|
195 |
m_EquipStar.SetActive(true); |
dee74a
|
196 |
m_EquipStar.text = currentStarLevel >= 1 ? Language.Get("EquipStarLevel", currentStarLevel) : ""; |
eb1a8d
|
197 |
} |
CX |
198 |
else |
|
199 |
{ |
f23c81
|
200 |
m_EquipStar.SetActive(false); |
H |
201 |
m_TargetEquip.SetActive(false); |
eb1a8d
|
202 |
} |
CX |
203 |
|
|
204 |
DisplayMaterialSlots(equipPosition, currentStarLevel); |
|
205 |
DisplayPropertyPreview(equipPosition, currentStarLevel, EquipStarModel.GetMaxStarLevel(equipPosition.x)); |
|
206 |
DisplayStarUpgradeButton(equipPosition, currentStarLevel); |
5100d2
|
207 |
} |
CX |
208 |
|
0a5fe1
|
209 |
} |
CX |
210 |
|
cf2457
|
211 |
if (force || model.equipStarLevel.dirty || model.equipMaxStarLevel.dirty) |
0a5fe1
|
212 |
{ |
16acef
|
213 |
model.autoBuy.dirty = true; |
642426
|
214 |
var equipPosition = new Int2(model.selectedLevel.value, model.selectedPlace.value); |
0a5fe1
|
215 |
var starLevel = model.equipStarLevel.Fetch(); |
cf2457
|
216 |
var maxStar = model.equipMaxStarLevel.Fetch(); |
642426
|
217 |
DisplayPropertyPreview(equipPosition, starLevel, EquipStarModel.GetMaxStarLevel(equipPosition.x)); |
CX |
218 |
DisplayStarUpgradeButton(equipPosition, starLevel); |
91c831
|
219 |
} |
CX |
220 |
|
|
221 |
if (force || model.stars.dirty) |
|
222 |
{ |
|
223 |
DisplayStars(model.stars.Fetch()); |
d57686
|
224 |
} |
CX |
225 |
|
49d14c
|
226 |
|
d49590
|
227 |
if (force || model.starResultEffect.dirty) |
CX |
228 |
{ |
|
229 |
var result = model.starResultEffect.Fetch(); |
|
230 |
model.starResultEffect.value = 0; |
|
231 |
PlayStarUpgradeEffect(result); |
49d14c
|
232 |
} |
d62a78
|
233 |
|
3c35f8
|
234 |
|
H |
235 |
|
|
236 |
if (force || model.autoBuy.dirty) |
|
237 |
{ |
|
238 |
if (model.equipMaxStarLevel.value == model.equipStarLevel.value) |
|
239 |
{ |
|
240 |
} |
|
241 |
else |
|
242 |
{ |
|
243 |
var value = model.autoBuy.Fetch(); |
|
244 |
if (value == -1) |
|
245 |
{ |
|
246 |
//不勾选自动购买 |
|
247 |
m_Auto.isOn = false; |
d56e0c
|
248 |
ShowAutoText(value); |
3c35f8
|
249 |
} |
H |
250 |
else |
|
251 |
{ |
|
252 |
m_Auto.isOn = true; |
|
253 |
ShowAutoText(value); |
|
254 |
} |
|
255 |
} |
|
256 |
|
d62a78
|
257 |
} |
7c2ade
|
258 |
} |
CX |
259 |
|
8222f7
|
260 |
private void DisplayCandidateSlots(int selectedLevel, bool resetPosition) |
CX |
261 |
{ |
|
262 |
for (var i = 0; i < levelBehaviours.Count; i++) |
|
263 |
{ |
|
264 |
var behaviour = levelBehaviours[i]; |
|
265 |
if (behaviour.level != selectedLevel) |
|
266 |
{ |
|
267 |
behaviour.Dispose(); |
|
268 |
} |
|
269 |
} |
|
270 |
|
|
271 |
RectTransform selectedBehaviour = null; |
|
272 |
for (var i = 0; i < levelBehaviours.Count; i++) |
|
273 |
{ |
|
274 |
var behaviour = levelBehaviours[i]; |
|
275 |
if (behaviour.level == selectedLevel) |
|
276 |
{ |
|
277 |
behaviour.Display(); |
|
278 |
selectedBehaviour = behaviour.transform as RectTransform; |
|
279 |
} |
|
280 |
} |
|
281 |
|
3d86df
|
282 |
//if (resetPosition && selectedBehaviour != null) |
H |
283 |
//{ |
|
284 |
// var height = 0f; |
|
285 |
// var totalHeight = 0f; |
|
286 |
// var index = selectedBehaviour.GetSiblingIndex(); |
|
287 |
// var childCount = m_LevelContainer.childCount; |
8222f7
|
288 |
|
3d86df
|
289 |
// //for (var i = 0; i < childCount; i++) |
H |
290 |
// //{ |
|
291 |
// // var child = m_LevelContainer.GetChild(i); |
|
292 |
// // if (i < index) |
|
293 |
// // { |
|
294 |
// // height += (child as RectTransform).rect.height; |
|
295 |
// // } |
8222f7
|
296 |
|
3d86df
|
297 |
// // totalHeight += (child as RectTransform).rect.height; |
H |
298 |
// //} |
8222f7
|
299 |
|
3d86df
|
300 |
// var viewRect = (m_LevelScrollRect.transform as RectTransform).rect; |
H |
301 |
// if (totalHeight > viewRect.height) |
|
302 |
// { |
|
303 |
// m_LevelScrollRect.verticalNormalizedPosition = 1 - height / (totalHeight - viewRect.height); |
|
304 |
// } |
|
305 |
// else |
|
306 |
// { |
|
307 |
// m_LevelScrollRect.verticalNormalizedPosition = 1; |
|
308 |
// } |
|
309 |
//} |
8222f7
|
310 |
} |
CX |
311 |
|
91c831
|
312 |
private void DisplayStars(List<EquipStarModel.Star> stars) |
7268a7
|
313 |
{ |
91c831
|
314 |
StopCoroutine("Co_DisplayStars"); |
CX |
315 |
StartCoroutine("Co_DisplayStars", stars); |
5100d2
|
316 |
} |
CX |
317 |
|
642426
|
318 |
private void DisplayMaterialSlots(Int2 equipPosition, int currentStarLevel) |
5100d2
|
319 |
{ |
642426
|
320 |
var equipGuid = equipModel.GetEquip(equipPosition); |
9842ca
|
321 |
var equip = packModel.GetItemByGuid(equipGuid); |
5100d2
|
322 |
|
9842ca
|
323 |
var maxStarLevel = equip != null ? EquipStarModel.GetMaxStarLevel(equip.config.ItemColor, equip.config.LV) : 0; |
CX |
324 |
var upgradable = maxStarLevel > 0; |
|
325 |
var isMax = upgradable && currentStarLevel >= maxStarLevel; |
|
326 |
|
6d4c04
|
327 |
if (!upgradable || isMax ) |
9842ca
|
328 |
{ |
d56e0c
|
329 |
m_SpecialMaterial1.Display(false, 0, 0); |
H |
330 |
m_SpecialMaterial2.Display(false, 0, 0); |
9842ca
|
331 |
} |
CX |
332 |
else |
|
333 |
{ |
6d4c04
|
334 |
var starConfig = EquipStarConfig.Get(equipPosition.x, equipPosition.y, currentStarLevel + 1); |
9842ca
|
335 |
|
d56e0c
|
336 |
|
H |
337 |
m_SpecialMaterial1.Display(starConfig.CostItemDict[0].x != 0, starConfig.CostItemDict[0].x, starConfig.CostItemDict[0].y); |
|
338 |
m_SpecialMaterial2.Display(starConfig.CostItemDict[1].x != 0, starConfig.CostItemDict[1].x, starConfig.CostItemDict[1].y); |
9842ca
|
339 |
} |
5100d2
|
340 |
} |
CX |
341 |
|
642426
|
342 |
private void DisplayPropertyPreview(Int2 equipPosition, int currentStar, int maxStar) |
5100d2
|
343 |
{ |
642426
|
344 |
var equipGuid = equipModel.GetEquip(equipPosition); |
cf2457
|
345 |
var isMax = maxStar > 0 && currentStar >= maxStar; |
CX |
346 |
var upgradable = model.IsEquipPlaceUpgradable(equipGuid); |
9842ca
|
347 |
|
cf2457
|
348 |
if (isMax) |
CX |
349 |
{ |
f23c81
|
350 |
m_EmptyHint.SetActive(false); |
H |
351 |
m_PropertyDetails.SetActive(true); |
642426
|
352 |
DisplayBaseProperty(equipPosition, currentStar, currentStar); |
CX |
353 |
DisplayLevelUpProperty(equipPosition, currentStar, currentStar); |
cf2457
|
354 |
} |
19165c
|
355 |
else if (upgradable) |
cf2457
|
356 |
{ |
f23c81
|
357 |
m_EmptyHint.SetActive(false); |
H |
358 |
m_PropertyDetails.SetActive(true); |
642426
|
359 |
DisplayBaseProperty(equipPosition, currentStar, currentStar + 1); |
CX |
360 |
DisplayLevelUpProperty(equipPosition, currentStar, currentStar + 1); |
cf2457
|
361 |
} |
CX |
362 |
else |
5100d2
|
363 |
{ |
f23c81
|
364 |
m_EmptyHint.SetActive(true); |
H |
365 |
m_PropertyDetails.SetActive(false); |
5100d2
|
366 |
} |
7268a7
|
367 |
} |
CX |
368 |
|
642426
|
369 |
private void DisplayBaseProperty(Int2 equipPosition, int currentStar, int nextStar) |
7268a7
|
370 |
{ |
642426
|
371 |
var nowConfig = EquipStarConfig.Get(equipPosition.x, equipPosition.y, currentStar); |
CX |
372 |
var nextConfig = EquipStarConfig.Get(equipPosition.x, equipPosition.y, nextStar); |
6c76e5
|
373 |
if (nextConfig == null) |
CX |
374 |
{ |
|
375 |
nextConfig = nowConfig; |
|
376 |
} |
|
377 |
|
3e1bdb
|
378 |
var count = nextConfig != null ? nextConfig.BaseAttrInfo.Length : 0; |
7268a7
|
379 |
for (var i = 0; i < m_BasePropertys.Length; i++) |
CX |
380 |
{ |
|
381 |
var behaviour = m_BasePropertys[i]; |
|
382 |
if (i < count) |
|
383 |
{ |
|
384 |
var current = nowConfig == null ? 0 : nowConfig.BaseAttrInfo[i].y; |
|
385 |
var next = nextConfig == null ? 0 : nextConfig.BaseAttrInfo[i].y; |
|
386 |
behaviour.Display(nextConfig == null ? 0 : nextConfig.BaseAttrInfo[i].x, current, next); |
|
387 |
} |
|
388 |
else |
|
389 |
{ |
|
390 |
behaviour.Hide(); |
|
391 |
} |
|
392 |
} |
|
393 |
} |
|
394 |
|
642426
|
395 |
private void DisplayLevelUpProperty(Int2 equipPosition, int currentStar, int nextStar) |
7268a7
|
396 |
{ |
fffbb5
|
397 |
var descriptions = starEffectTipModel.DisplayStarProperty(equipPosition); |
7268a7
|
398 |
for (var i = 0; i < m_LevelUpPropertys.Length; i++) |
CX |
399 |
{ |
|
400 |
var behaviour = m_LevelUpPropertys[i]; |
3ed42e
|
401 |
if (i < descriptions.Count) |
7268a7
|
402 |
{ |
f23c81
|
403 |
behaviour.SetActive(true); |
3ed42e
|
404 |
behaviour.text = descriptions[i]; |
7268a7
|
405 |
} |
CX |
406 |
else |
|
407 |
{ |
f23c81
|
408 |
behaviour.SetActive(false); |
7268a7
|
409 |
} |
cf2457
|
410 |
} |
CX |
411 |
} |
|
412 |
|
d56e0c
|
413 |
|
7268a7
|
414 |
|
642426
|
415 |
private void DisplayStarUpgradeButton(Int2 equipPosition, int currentStarLevel) |
3e1bdb
|
416 |
{ |
642426
|
417 |
if (equipPosition.y == 0) |
cf2457
|
418 |
{ |
f23c81
|
419 |
m_StarUpgrade.SetActive(false); |
H |
420 |
m_MaxStarLevelHint.SetActive(false); |
cf2457
|
421 |
} |
CX |
422 |
else |
|
423 |
{ |
642426
|
424 |
var maxLevel = EquipStarModel.GetMaxStarLevel(equipPosition.x); |
cf2457
|
425 |
var isMax = currentStarLevel >= maxLevel; |
f23c81
|
426 |
m_StarUpgrade.SetActive(!isMax); |
H |
427 |
m_MaxStarLevelHint.SetActive(isMax); |
cf2457
|
428 |
} |
3e1bdb
|
429 |
} |
CX |
430 |
|
ccbc64
|
431 |
|
7c2ade
|
432 |
private void StarUpgrade() |
CX |
433 |
{ |
ccbc64
|
434 |
if ((TimeUtility.AllSeconds - curTime) < 2) |
H |
435 |
{ |
|
436 |
return; |
|
437 |
} |
|
438 |
|
642426
|
439 |
var equipPosition = new Int2(model.selectedLevel.value, model.selectedPlace.value); |
CX |
440 |
var currentStarLevel = model.GetEquipStarLevel(equipPosition); |
3c35f8
|
441 |
|
H |
442 |
if (model.autoBuy.value == -2) |
|
443 |
{ |
|
444 |
//库存不足 |
|
445 |
SysNotifyMgr.Instance.ShowTip("AuctionNoEquip"); |
|
446 |
return; |
|
447 |
} |
ccbc64
|
448 |
curTime = TimeUtility.AllSeconds; |
3c35f8
|
449 |
var auto = model.autoBuy.value > 0 ? 1 : 0; |
H |
450 |
model.DoStarUpgrade(equipPosition, currentStarLevel + 1, auto); |
7268a7
|
451 |
} |
CX |
452 |
|
dbdbd5
|
453 |
private void CreateLevelBehaviours() |
CX |
454 |
{ |
0fae82
|
455 |
var levels = equipModel.GetUnLockedEquipSets(); |
dbdbd5
|
456 |
var gap = levels.Count - levelBehaviours.Count; |
CX |
457 |
for (var i = 0; i < gap; i++) |
|
458 |
{ |
|
459 |
var instance = UIUtility.CreateWidget("EquipStarLevelSelectBehaviour", "EquipStarLevelSelectBehaviour"); |
|
460 |
var behaviour = instance.GetComponent<EquipStarLevelSelectBehaviour>(); |
|
461 |
behaviour.transform.SetParentEx(m_LevelContainer, Vector3.zero, Quaternion.identity, Vector3.one); |
|
462 |
levelBehaviours.Add(behaviour); |
|
463 |
} |
|
464 |
|
|
465 |
for (var i = 0; i < levelBehaviours.Count; i++) |
|
466 |
{ |
|
467 |
var behaviour = levelBehaviours[i]; |
|
468 |
if (i < levels.Count) |
|
469 |
{ |
f23c81
|
470 |
behaviour.SetActive(true); |
dbdbd5
|
471 |
behaviour.UnInit(); |
CX |
472 |
behaviour.Init(levels[i]); |
|
473 |
} |
|
474 |
else |
|
475 |
{ |
|
476 |
behaviour.UnInit(); |
f23c81
|
477 |
behaviour.SetActive(false); |
dbdbd5
|
478 |
} |
CX |
479 |
} |
|
480 |
} |
|
481 |
|
d49590
|
482 |
private void PlayStarUpgradeEffect(int result) |
CX |
483 |
{ |
af278f
|
484 |
if (result == 1 || result == -1) |
d49590
|
485 |
{ |
652343
|
486 |
//StopCoroutine("Co_PlaySuccessEffect"); |
CX |
487 |
// StopCoroutine("Co_PlayFailedEffect"); |
af278f
|
488 |
} |
CX |
489 |
|
|
490 |
if (result == 1) |
|
491 |
{ |
652343
|
492 |
//StartCoroutine("Co_PlaySuccessEffect"); |
d49590
|
493 |
} |
CX |
494 |
else if (result == -1) |
|
495 |
{ |
652343
|
496 |
//StartCoroutine("Co_PlayFailedEffect"); |
d49590
|
497 |
} |
CX |
498 |
} |
|
499 |
|
d56e0c
|
500 |
//IEnumerator Co_PlaySuccessEffect() |
H |
501 |
//{ |
|
502 |
// m_EffectStarFill.Play(); |
|
503 |
// yield return WaitingForSecondConst.WaitMS700; |
|
504 |
// m_EffectSuccess.Play(); |
|
505 |
//} |
d49590
|
506 |
|
d56e0c
|
507 |
//IEnumerator Co_PlayFailedEffect() |
H |
508 |
//{ |
|
509 |
// m_EffectStarFill.Play(); |
|
510 |
// yield return WaitingForSecondConst.WaitMS700; |
|
511 |
// m_EffectFailed.Play(); |
|
512 |
//} |
d49590
|
513 |
|
91c831
|
514 |
IEnumerator Co_DisplayStars(List<EquipStarModel.Star> stars) |
CX |
515 |
{ |
|
516 |
var hasNewStar = stars.FindIndex(x => { return x.newGet; }) != -1; |
|
517 |
if (hasNewStar) |
|
518 |
{ |
|
519 |
yield return WaitingForSecondConst.WaitMS2000; |
|
520 |
} |
|
521 |
|
c9d7a4
|
522 |
//循环显示不同颜色,如10星在第一颗图标星换颜色 |
H |
523 |
int starCnt = stars.Count; |
|
524 |
int starLevel = model.GetStarLevel(new Int2(model.selectedLevel.value, model.selectedPlace.value)); |
|
525 |
int iconCnt = m_Stars.Length; |
|
526 |
int loop = ((int)Math.Max(starLevel - 1, 0)) / iconCnt; |
|
527 |
for (var i = 0; i < iconCnt; i++) |
91c831
|
528 |
{ |
c9d7a4
|
529 |
if (i < starCnt) |
91c831
|
530 |
{ |
c9d7a4
|
531 |
var starIndex = loop * iconCnt + i < starLevel ? loop * iconCnt + i : i; |
H |
532 |
var star = stars[starIndex]; |
|
533 |
m_Stars[i].Display(star.actived, starIndex / iconCnt); |
91c831
|
534 |
if (star.newGet) |
CX |
535 |
{ |
|
536 |
m_Stars[i].PlayEffect(); |
|
537 |
} |
|
538 |
} |
|
539 |
else |
|
540 |
{ |
|
541 |
m_Stars[i].Hide(); |
|
542 |
} |
|
543 |
} |
|
544 |
} |
|
545 |
|
eef5be
|
546 |
private void ViewEquipTip() |
CX |
547 |
{ |
|
548 |
var level = model.selectedLevel.value; |
|
549 |
var place = model.selectedPlace.value; |
565d5b
|
550 |
var equipPosition = new Int2(level, place); |
eef5be
|
551 |
var equipGuid = equipModel.GetEquip(equipPosition); |
CX |
552 |
|
927444
|
553 |
ItemTipUtility.Show(equipGuid); |
eef5be
|
554 |
} |
CX |
555 |
|
7268a7
|
556 |
[System.Serializable] |
91c831
|
557 |
public class Star |
7268a7
|
558 |
{ |
CX |
559 |
public RectTransform container; |
|
560 |
public Image imageBase; |
|
561 |
public Image imageStar; |
91c831
|
562 |
public UIEffect newStarEffect; |
7268a7
|
563 |
|
c9d7a4
|
564 |
public void Display(bool active, int loopIndex) |
7268a7
|
565 |
{ |
c9d7a4
|
566 |
container.gameObject.SetActive(true); |
H |
567 |
imageStar.gameObject.SetActive(active); |
|
568 |
imageStar.SetSprite("ImgStar_" + loopIndex); |
7268a7
|
569 |
} |
CX |
570 |
|
|
571 |
public void Hide() |
|
572 |
{ |
f23c81
|
573 |
container.SetActive(false); |
7268a7
|
574 |
} |
91c831
|
575 |
|
CX |
576 |
public void PlayEffect() |
|
577 |
{ |
|
578 |
newStarEffect.Play(); |
|
579 |
} |
7c2ade
|
580 |
} |
CX |
581 |
|
|
582 |
[System.Serializable] |
7268a7
|
583 |
public class BaseProperty |
7c2ade
|
584 |
{ |
d57686
|
585 |
public RectTransform container; |
7c2ade
|
586 |
public Text current; |
3ed42e
|
587 |
public RectTransform arrow; |
7c2ade
|
588 |
public Text next; |
CX |
589 |
|
|
590 |
public void Display(int propertyId, int currentValue, int nextValue) |
|
591 |
{ |
f23c81
|
592 |
container.SetActive(true); |
7c2ade
|
593 |
var config = PlayerPropertyConfig.Get(propertyId); |
CX |
594 |
if (config != null) |
|
595 |
{ |
c55aae
|
596 |
this.current.text = StringUtility.Contact(config.Name, ":", PlayerPropertyConfig.GetValueDescription(propertyId, currentValue)); |
9842ca
|
597 |
if (currentValue != nextValue) |
CX |
598 |
{ |
f23c81
|
599 |
this.arrow.SetActive(true); |
H |
600 |
this.next.SetActive(true); |
c55aae
|
601 |
this.next.text = PlayerPropertyConfig.GetValueDescription(propertyId, nextValue); |
9842ca
|
602 |
} |
CX |
603 |
else |
|
604 |
{ |
f23c81
|
605 |
this.arrow.SetActive(false); |
H |
606 |
this.next.SetActive(false); |
9842ca
|
607 |
} |
7c2ade
|
608 |
} |
CX |
609 |
} |
|
610 |
|
d57686
|
611 |
public void Hide() |
CX |
612 |
{ |
f23c81
|
613 |
container.SetActive(false); |
d57686
|
614 |
} |
7c2ade
|
615 |
} |
CX |
616 |
|
|
617 |
|
e92fd5
|
618 |
} |
CX |
619 |
|
|
620 |
} |
|
621 |
|
|
622 |
|
|
623 |
|
|
624 |
|