提交 | 用户 | age
|
a27c7f
|
1 |
using vnxbqy.UI; |
H |
2 |
using System.Collections.Generic; |
|
3 |
using UnityEngine; |
|
4 |
using UnityEngine.UI; |
|
5 |
|
|
6 |
class EquipEvolveWin : ILWindow |
|
7 |
{ |
|
8 |
ScrollerController scrollerRealm; |
|
9 |
ScrollerController scrollerEquip; |
|
10 |
ItemCell tagetItemCell; |
|
11 |
Transform proEmpty; |
|
12 |
Transform proShow; |
|
13 |
List<Text> countTexts = new List<Text>(); |
|
14 |
List<ItemCell> materialItems = new List<ItemCell>(); |
|
15 |
List<Image> lockImages = new List<Image>(); |
|
16 |
Text fromText; |
|
17 |
Text toText; |
|
18 |
Transform evolveShow; |
|
19 |
ScrollerController scrollerProperty; |
|
20 |
Button evolveBtn; |
|
21 |
Button decomposeBtn; |
|
22 |
|
|
23 |
Text Base1Txt_Current; |
|
24 |
Text Base1Txt_Next; |
|
25 |
Text Base2Txt_Current; |
|
26 |
Text Base2Txt_Next; |
|
27 |
List<Text> LegendCurrent = new List<Text>(); |
|
28 |
List<Text> LegendNext = new List<Text>(); |
|
29 |
List<Transform> PropertyLines = new List<Transform>(); |
|
30 |
Transform BasePropertyLine_2; |
|
31 |
Transform LegendTitle; |
|
32 |
|
|
33 |
int equipID = 0; //当前选中的装备 |
|
34 |
int finalEquipID = 0; //进阶到最高级时的装备ID |
|
35 |
EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } } |
|
36 |
PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } } |
|
37 |
#region Built-in |
|
38 |
protected override void BindController() |
|
39 |
{ |
|
40 |
scrollerRealm = proxy.GetWidgtEx<ScrollerController>("ScrollerRealm"); |
|
41 |
scrollerEquip = proxy.GetWidgtEx<ScrollerController>("ScrollerEquip"); |
|
42 |
tagetItemCell = proxy.GetWidgtEx<ItemCell>("tagetItemCell"); |
|
43 |
materialItems.Add(proxy.GetWidgtEx<ItemCell>("Material1")); |
|
44 |
materialItems.Add(proxy.GetWidgtEx<ItemCell>("Material2")); |
|
45 |
proEmpty = proxy.GetWidgtEx<Transform>("Container_Empty"); |
|
46 |
proShow = proxy.GetWidgtEx<Transform>("Container_Details"); |
|
47 |
countTexts.Add(proxy.GetWidgtEx<Text>("Count1")); |
|
48 |
countTexts.Add(proxy.GetWidgtEx<Text>("Count2")); |
|
49 |
lockImages.Add(proxy.GetWidgtEx<Image>("Img_Lock1")); |
|
50 |
lockImages.Add(proxy.GetWidgtEx<Image>("Img_Lock2")); |
|
51 |
fromText = proxy.GetWidgtEx<Text>("fromText"); |
|
52 |
toText = proxy.GetWidgtEx<Text>("toText"); |
|
53 |
evolveShow = proxy.GetWidgtEx<Transform>("Container_EvolveText"); |
|
54 |
scrollerProperty = proxy.GetWidgtEx<ScrollerController>("ScrollerProperty"); |
|
55 |
evolveBtn = proxy.GetWidgtEx<Button>("Btn_Evolve"); |
|
56 |
decomposeBtn = proxy.GetWidgtEx<Button>("BtnDecompose"); |
|
57 |
|
|
58 |
Base1Txt_Current = proxy.GetWidgtEx<Text>("Base1Txt_Current"); |
|
59 |
Base1Txt_Next = proxy.GetWidgtEx<Text>("Base1Txt_Next"); |
|
60 |
Base2Txt_Current = proxy.GetWidgtEx<Text>("Base2Txt_Current"); |
|
61 |
Base2Txt_Next = proxy.GetWidgtEx<Text>("Base2Txt_Next"); |
|
62 |
LegendCurrent.Add(proxy.GetWidgtEx<Text>("Legend1Txt_Current")); |
|
63 |
LegendCurrent.Add(proxy.GetWidgtEx<Text>("Legend2Txt_Current")); |
|
64 |
LegendCurrent.Add(proxy.GetWidgtEx<Text>("Legend3Txt_Current")); |
|
65 |
LegendNext.Add(proxy.GetWidgtEx<Text>("Legend1Txt_Next")); |
|
66 |
LegendNext.Add(proxy.GetWidgtEx<Text>("Legend2Txt_Next")); |
|
67 |
LegendNext.Add(proxy.GetWidgtEx<Text>("Legend3Txt_Next")); |
|
68 |
PropertyLines.Add(proxy.GetWidgtEx<Transform>("PropertyLine_1")); |
|
69 |
PropertyLines.Add(proxy.GetWidgtEx<Transform>("PropertyLine_2")); |
|
70 |
PropertyLines.Add(proxy.GetWidgtEx<Transform>("PropertyLine_3")); |
|
71 |
BasePropertyLine_2 = proxy.GetWidgtEx<Transform>("BasePropertyLine_2"); |
|
72 |
LegendTitle = proxy.GetWidgtEx<Transform>("Img_Title"); |
|
73 |
} |
|
74 |
|
|
75 |
protected override void AddListeners() |
|
76 |
{ |
|
77 |
decomposeBtn.SetListener(()=> { |
|
78 |
WindowCenter.Instance.OpenIL<EquipShenDecomposeWin>(); |
|
79 |
}); |
|
80 |
|
|
81 |
evolveBtn.SetListener(OnEvolve); |
|
82 |
} |
|
83 |
|
|
84 |
/// <summary> |
|
85 |
/// 没有红点提示,可以定位第一件可进阶装备 |
|
86 |
/// </summary> |
|
87 |
protected override void OnPreOpen() |
|
88 |
{ |
|
89 |
equipID = 0; |
|
90 |
finalEquipID = 0; |
|
91 |
if (EquipEvolveModel.Instance.materialJumpPos == Int2.zero) |
|
92 |
{ |
|
93 |
var equipPos = EquipEvolveModel.Instance.FindSatisfyEquip(); |
|
94 |
EquipEvolveModel.Instance.selectLevelType = equipPos.x; |
|
95 |
EquipEvolveModel.Instance.selectPlaceType = equipPos.y; |
|
96 |
} |
|
97 |
else |
|
98 |
{ |
|
99 |
EquipEvolveModel.Instance.selectLevelType = EquipEvolveModel.Instance.materialJumpPos.x; |
|
100 |
EquipEvolveModel.Instance.selectPlaceType = EquipEvolveModel.Instance.materialJumpPos.y; |
|
101 |
EquipEvolveModel.Instance.materialJumpPos = Int2.zero; |
|
102 |
} |
|
103 |
|
|
104 |
scrollerRealm.OnRefreshCell += OnRefreshRealmCell; |
|
105 |
scrollerEquip.OnRefreshCell += OnRefreshEquipCell; |
|
106 |
EquipEvolveModel.Instance.SelectLevelEvent += SelectLevelEvent; |
|
107 |
EquipEvolveModel.Instance.SelectPlaceEvent += SelectPlaceEvent; |
|
108 |
packModel.refreshItemCountEvent += RefreshItemCount; |
|
109 |
scrollerProperty.OnRefreshCell += OnRefreshProperty; |
|
110 |
|
|
111 |
|
|
112 |
} |
|
113 |
|
|
114 |
protected override void OnAfterOpen() |
|
115 |
{ |
|
116 |
Display(); |
|
117 |
} |
|
118 |
|
|
119 |
protected override void OnPreClose() |
|
120 |
{ |
|
121 |
scrollerRealm.OnRefreshCell -= OnRefreshRealmCell; |
|
122 |
scrollerEquip.OnRefreshCell -= OnRefreshEquipCell; |
|
123 |
EquipEvolveModel.Instance.SelectLevelEvent -= SelectLevelEvent; |
|
124 |
EquipEvolveModel.Instance.SelectPlaceEvent -= SelectPlaceEvent; |
|
125 |
packModel.refreshItemCountEvent -= RefreshItemCount; |
|
126 |
scrollerProperty.OnRefreshCell -= OnRefreshProperty; |
|
127 |
} |
|
128 |
|
|
129 |
#endregion |
|
130 |
|
|
131 |
|
|
132 |
void Display() |
|
133 |
{ |
|
134 |
CreateLevelBehaviours(); |
|
135 |
CreateEquipBehaviours(); |
|
136 |
ShowEvolveItem(); |
|
137 |
} |
|
138 |
|
|
139 |
#region 境界装备 |
|
140 |
private void OnRefreshRealmCell(ScrollerDataType type, CellView cell) |
|
141 |
{ |
|
142 |
var _cell = cell.GetILBehaviour<EquipRealmCell>(); |
|
143 |
if (_cell == null) return; |
|
144 |
Debug.LogFormat("OnRefreshRealmCell: {0}", cell.index); |
|
145 |
_cell.Display(cell.index); |
|
146 |
} |
|
147 |
|
|
148 |
|
|
149 |
private void OnRefreshEquipCell(ScrollerDataType type, CellView cell) |
|
150 |
{ |
|
151 |
var _cell = cell.GetILBehaviour<EquipEvolveCell>(); |
|
152 |
if (_cell == null) return; |
|
153 |
_cell.Display(cell.index); |
|
154 |
} |
|
155 |
|
|
156 |
|
|
157 |
|
|
158 |
private void CreateLevelBehaviours() |
|
159 |
{ |
|
160 |
var levels = equipModel.GetUnLockedEquipSets(); |
|
161 |
|
|
162 |
scrollerRealm.Refresh(); |
|
163 |
for (int i = 0; i < levels.Count; i++) |
|
164 |
{ |
|
165 |
scrollerRealm.AddCell(ScrollerDataType.Header, levels[i]); |
|
166 |
} |
|
167 |
scrollerRealm.Restart(); |
|
168 |
|
|
169 |
} |
|
170 |
|
|
171 |
void CreateEquipBehaviours() |
|
172 |
{ |
|
173 |
scrollerEquip.Refresh(); |
|
174 |
for (int j = 1; j < 12; j++) |
|
175 |
{ |
|
176 |
scrollerEquip.AddCell(ScrollerDataType.Header, j); |
|
177 |
|
|
178 |
} |
|
179 |
scrollerEquip.Restart(); |
|
180 |
scrollerEquip.JumpIndex(EquipEvolveModel.Instance.selectPlaceType - 1); |
|
181 |
} |
|
182 |
|
|
183 |
void SelectLevelEvent() |
|
184 |
{ |
|
185 |
scrollerRealm.m_Scorller.RefreshActiveCellViews(); |
|
186 |
scrollerEquip.m_Scorller.RefreshActiveCellViews(); |
|
187 |
ShowEvolveItem(); |
|
188 |
} |
|
189 |
|
|
190 |
void SelectPlaceEvent() |
|
191 |
{ |
|
192 |
scrollerEquip.m_Scorller.RefreshActiveCellViews(); |
|
193 |
ShowEvolveItem(); |
|
194 |
} |
|
195 |
|
|
196 |
#endregion |
|
197 |
|
|
198 |
#region 装备材料区 |
|
199 |
void ShowEvolveItem() |
|
200 |
{ |
|
201 |
var position = new Int2(EquipEvolveModel.Instance.selectLevelType, EquipEvolveModel.Instance.selectPlaceType); |
|
202 |
var equipGuid = equipModel.GetEquip(position); |
|
203 |
for (int i = 0; i < materialItems.Count; i++) |
|
204 |
{ |
|
205 |
materialItems[i].SetActiveIL(false); |
|
206 |
countTexts[i].SetActiveIL(false); |
|
207 |
lockImages[i].SetActiveIL(true); |
|
208 |
} |
|
209 |
proEmpty.SetActiveIL(false); |
|
210 |
proShow.SetActiveIL(false); |
|
211 |
evolveShow.SetActiveIL(false); |
|
212 |
|
|
213 |
if (string.IsNullOrEmpty(equipGuid)) |
|
214 |
{ |
|
215 |
tagetItemCell.SetActiveIL(false); |
|
216 |
proEmpty.SetActiveIL(true); |
|
217 |
proShow.SetActiveIL(false); |
|
218 |
return; |
|
219 |
} |
|
220 |
tagetItemCell.SetActiveIL(true); |
|
221 |
var equipItem = packModel.GetItemByGuid(equipGuid); |
|
222 |
if (equipItem == null) |
|
223 |
return; |
|
224 |
|
|
225 |
equipID = equipItem.itemId; |
|
226 |
var model = new ItemCellModel(equipID, false, (ulong)equipItem.count); |
|
227 |
tagetItemCell.Init(model); |
|
228 |
tagetItemCell.button.SetListener(() => |
|
229 |
{ |
|
230 |
ItemTipUtility.Show(equipGuid, false); |
|
231 |
}); |
|
232 |
|
|
233 |
var materials = ILEquipShenEvolveConfig.TryGetMaterial(equipID); |
|
234 |
if (materials == null) |
|
235 |
{ |
|
236 |
proEmpty.SetActiveIL(true); |
|
237 |
proShow.SetActiveIL(false); |
|
238 |
return; |
|
239 |
} |
|
240 |
|
|
241 |
proEmpty.SetActiveIL(false); |
|
242 |
proShow.SetActiveIL(true); |
|
243 |
evolveShow.SetActiveIL(true); |
|
244 |
|
|
245 |
|
|
246 |
//材料 |
|
247 |
for (int i = 0; i < materials.Length; i++) |
|
248 |
{ |
|
249 |
if (i >= materialItems.Count) |
|
250 |
{ |
|
251 |
continue; |
|
252 |
} |
|
253 |
materialItems[i].SetActiveIL(true); |
|
254 |
var itemID = materials[i][0]; |
|
255 |
var count = packModel.GetItemCountByID(PackType.Item, itemID); |
|
256 |
var materialModel = new ItemCellModel(itemID, false, 1); |
|
257 |
materialItems[i].Init(materialModel); |
|
258 |
materialItems[i].button.SetListener(() => |
|
259 |
{ |
|
260 |
ItemTipUtility.Show(itemID); |
|
261 |
}); |
|
262 |
countTexts[i].SetActiveIL(true); |
|
263 |
countTexts[i].text = UIHelper.AppendColor(count >= materials[i][1] ? TextColType.Green : TextColType.Red, count + "/" + materials[i][1]); |
|
264 |
lockImages[i].SetActiveIL(false); |
|
265 |
} |
|
266 |
|
|
267 |
//显示下一进阶品质 |
|
268 |
fromText.text = Language.Get("ShenEquipText" + EquipEvolveModel.Instance.GetRedEquipQuality(equipID)); |
|
269 |
toText.text = Language.Get("ShenEquipText" + EquipEvolveModel.Instance.GetRedEquipQuality(ILEquipShenEvolveConfig.Get(equipID).EvolveID)); |
|
270 |
|
|
271 |
ShowPro(); |
|
272 |
} |
|
273 |
|
|
274 |
void RefreshItemCount(PackType packType, int index, int itemID) |
|
275 |
{ |
|
276 |
if (packType == PackType.Equip) |
|
277 |
{ |
|
278 |
ShowEvolveItem(); |
|
279 |
scrollerEquip.m_Scorller.RefreshActiveCellViews(); |
|
280 |
} |
|
281 |
} |
|
282 |
|
|
283 |
#endregion |
|
284 |
|
|
285 |
#region 属性区 |
|
286 |
void ShowPro() |
|
287 |
{ |
|
288 |
ShowBasePro(); |
|
289 |
ShowLegendPro(); |
|
290 |
CreateEvolveProperty(); |
|
291 |
} |
|
292 |
|
|
293 |
|
|
294 |
//基础 |
|
295 |
void ShowBasePro() |
|
296 |
{ |
|
297 |
var nextEquipID = ILEquipShenEvolveConfig.Get(equipID).EvolveID; |
|
298 |
var equipConfig = ItemConfig.Get(equipID); |
|
299 |
var nextEquipConfig = ItemConfig.Get(nextEquipID); |
|
300 |
Base1Txt_Current.text = StringUtility.Contact(PlayerPropertyConfig.Get(equipConfig.Effect1).Name, ":", PlayerPropertyConfig.GetValueDescription(equipConfig.Effect1, equipConfig.EffectValueA1)); |
|
301 |
Base1Txt_Next.text = PlayerPropertyConfig.GetValueDescription(nextEquipConfig.Effect1, nextEquipConfig.EffectValueA1); |
|
302 |
BasePropertyLine_2.SetActiveIL(false); |
|
303 |
if (equipConfig.Effect2 != 0) |
|
304 |
{ |
|
305 |
BasePropertyLine_2.SetActiveIL(true); |
|
306 |
Base2Txt_Current.text = StringUtility.Contact(PlayerPropertyConfig.Get(equipConfig.Effect2).Name, ":", PlayerPropertyConfig.GetValueDescription(equipConfig.Effect2, equipConfig.EffectValueA2)); |
|
307 |
Base2Txt_Next.text = PlayerPropertyConfig.GetValueDescription(nextEquipConfig.Effect2, nextEquipConfig.EffectValueA2); |
|
308 |
} |
|
309 |
|
|
310 |
} |
|
311 |
|
|
312 |
void ShowLegendPro() |
|
313 |
{ |
|
314 |
for (int i = 0; i < PropertyLines.Count; i++) |
|
315 |
{ |
|
316 |
PropertyLines[i].SetActiveIL(false); |
|
317 |
} |
|
318 |
var position = new Int2(EquipEvolveModel.Instance.selectLevelType, EquipEvolveModel.Instance.selectPlaceType); |
|
319 |
var equipGuid = equipModel.GetEquip(position); |
|
320 |
|
|
321 |
var nextEquipID = ILEquipShenEvolveConfig.Get(equipID).EvolveID; |
|
322 |
var config = EquipShenAttrConfig.Get(nextEquipID); |
|
323 |
if (config == null) |
|
324 |
{ |
|
325 |
return; |
|
326 |
} |
|
327 |
var curEquipLegends = ILItemCommon.GetLegendProperty(equipGuid); |
|
328 |
int index = 0; |
|
329 |
bool hasLegend = false; |
|
330 |
for (int i = 0; i < config.LegendAttrID.Length; i++) |
|
331 |
{ |
|
332 |
int curValue = 0; |
|
333 |
var proValue = config.LegendAttrValue[i]; |
|
334 |
var proID = config.LegendAttrID[i]; |
|
335 |
curEquipLegends.TryGetValue(proID, out curValue); |
|
336 |
if (curValue == proValue) |
|
337 |
{ |
|
338 |
continue; |
|
339 |
} |
|
340 |
PropertyLines[index].SetActiveIL(true); |
|
341 |
LegendCurrent[index].text = StringUtility.Contact(PlayerPropertyConfig.Get(proID).Name, ":", PlayerPropertyConfig.GetValueDescription(proID, curValue)); |
|
342 |
LegendNext[index].text = PlayerPropertyConfig.GetValueDescription(proID, proValue); |
|
343 |
index++; |
|
344 |
hasLegend = true; |
|
345 |
} |
|
346 |
|
|
347 |
LegendTitle.SetActiveIL(hasLegend); |
|
348 |
} |
|
349 |
|
|
350 |
|
|
351 |
void CreateEvolveProperty() |
|
352 |
{ |
|
353 |
finalEquipID = EquipEvolveModel.Instance.GetFinalEvolveEquip(equipID); |
|
354 |
var equipInfo = EquipShenAttrConfig.Get(finalEquipID); |
|
355 |
if (equipInfo == null) return; |
|
356 |
int count = equipInfo.ShenAttrID.Length + equipInfo.XianAttrID.Length + equipInfo.JiAttrID.Length; |
|
357 |
scrollerProperty.Refresh(); |
|
358 |
for (int i = 0; i < count; i++) |
|
359 |
{ |
|
360 |
scrollerProperty.AddCell(ScrollerDataType.Header, i); |
|
361 |
} |
|
362 |
scrollerProperty.Restart(); |
|
363 |
|
|
364 |
} |
|
365 |
|
|
366 |
void OnRefreshProperty(ScrollerDataType type, CellView cell) |
|
367 |
{ |
|
368 |
var _cell = cell.GetILBehaviour<EvolvePropertyCell>(); |
|
369 |
if (_cell == null) return; |
|
370 |
_cell.Display(finalEquipID, equipID, cell.index); |
|
371 |
} |
|
372 |
|
|
373 |
|
|
374 |
#endregion |
|
375 |
|
|
376 |
#region 操作区 |
|
377 |
|
|
378 |
void OnEvolve() |
|
379 |
{ |
|
380 |
var materials = ILEquipShenEvolveConfig.TryGetMaterial(equipID); |
|
381 |
if (materials == null) |
|
382 |
{ |
|
383 |
return; |
|
384 |
} |
|
385 |
for (int i = 0; i < materials.Length; i++) |
|
386 |
{ |
|
387 |
var count = packModel.GetItemCountByID(PackType.Item, materials[i][0]); |
|
388 |
if (count < materials[i][1]) |
|
389 |
{ |
|
390 |
//材料不足 |
|
391 |
SysNotifyMgr.Instance.ShowTip("NotEnoughMaterial"); |
|
392 |
return; |
|
393 |
}
|
|
394 |
LimitedTimeLuxuryGiftModel.Instance.IsItemIdShow(4, materials[i][0], materials[i][1], 1,0); |
|
395 |
} |
|
396 |
//记录用于成功后的展示 |
|
397 |
EquipEvolveModel.Instance.resultFromEquipID = equipID; |
|
398 |
EquipEvolveModel.Instance.resultToEquipID = ILEquipShenEvolveConfig.Get(equipID).EvolveID; |
|
399 |
var position = new Int2(EquipEvolveModel.Instance.selectLevelType, EquipEvolveModel.Instance.selectPlaceType); |
|
400 |
EquipEvolveModel.Instance.fromEquipLegends = ILItemCommon.GetLegendProperty(equipModel.GetEquip(position)); |
|
401 |
|
|
402 |
var pak = new IL_CA330_tagCMEquipEvolve(); |
|
403 |
pak.EquipIndex = (byte)EquipSet.ClientPlaceToServerPlace(new Int2(EquipEvolveModel.Instance.selectLevelType, |
|
404 |
EquipEvolveModel.Instance.selectPlaceType)); |
|
405 |
GameNetSystem.Instance.SendInfo(pak); |
|
406 |
} |
|
407 |
#endregion |
|
408 |
} |