提交 | 用户 | age
|
a27c7f
|
1 |
//-------------------------------------------------------- |
H |
2 |
// [Author]: 第二世界 |
|
3 |
// [ Date ]: Tuesday, June 11, 2019 |
|
4 |
//-------------------------------------------------------- |
|
5 |
|
|
6 |
using UnityEngine.UI; |
|
7 |
using System.Collections.Generic; |
|
8 |
using vnxbqy.UI; |
|
9 |
using UnityEngine; |
|
10 |
using LitJson; |
|
11 |
|
|
12 |
|
|
13 |
public class TreasurePavilionTipWin : ILWindow |
|
14 |
{ |
|
15 |
Text name; |
|
16 |
Image gubaoImg; |
|
17 |
Button m_Close; |
|
18 |
List<Transform> starObjs = new List<Transform>(); |
|
19 |
Text pieceCnt; |
|
20 |
Text scoreText; |
|
21 |
RichText descText; |
|
22 |
List<Text> baseAttrList = new List<Text>(); |
|
23 |
List<Text> starAttrList = new List<Text>(); |
|
24 |
Button showWayBtn; |
|
25 |
Button activeBtn; |
|
26 |
Button starUpBtn; |
|
27 |
Button lvUpBtn; |
|
28 |
TipGetWaysWidget getWaysTips; |
|
29 |
RedpointBehaviour lvRedpoint; |
|
30 |
RedpointBehaviour starRedpoint; |
|
31 |
RedpointBehaviour activeRedpoint; |
|
32 |
|
|
33 |
RedpointBehaviour getRedpoint; |
|
34 |
Transform awardObj; |
|
35 |
Button getAwardBtn; |
|
36 |
ItemCell awardItem; |
|
37 |
Text awardText; |
4a006e
|
38 |
//古宝共鸣相关 |
L |
39 |
Transform Content1; |
|
40 |
ScrollerController scroller; |
|
41 |
ScrollerController scroller1; |
|
42 |
TextEx txtTitle; |
a27c7f
|
43 |
PackModel packModel { get { return ModelCenter.Instance.GetModelEx<PackModel>(); } } |
H |
44 |
|
|
45 |
#region Built-in |
|
46 |
protected override void BindController() |
|
47 |
{ |
|
48 |
name = proxy.GetWidgtEx<Text>("Txt_Name"); |
|
49 |
gubaoImg = proxy.GetWidgtEx<Image>("Icon"); |
|
50 |
var canvas = gubaoImg.AddMissingComponent<Canvas>(); |
|
51 |
canvas.sortingLayerName = "UI"; //使图片在特效上层 |
|
52 |
m_Close = proxy.GetWidgtEx<Button>("Btn_Close"); |
|
53 |
for (int i = 0; i < 10; i++) |
|
54 |
{ |
|
55 |
starObjs.Add(proxy.GetWidgtEx<Transform>("starBG" + i)); |
|
56 |
} |
|
57 |
pieceCnt = proxy.GetWidgtEx<Text>("cnt"); |
|
58 |
scoreText = proxy.GetWidgtEx<Text>("score"); |
|
59 |
descText = proxy.GetWidgtEx<RichText>("Txt_Description"); |
|
60 |
for (int i = 0; i < 3; i++) |
|
61 |
{ |
|
62 |
baseAttrList.Add(proxy.GetWidgtEx<Text>("Txt_BaseAttr" + i)); |
|
63 |
} |
d9b91a
|
64 |
for (int i = 0; i < 4; i++) |
a27c7f
|
65 |
{ |
H |
66 |
starAttrList.Add(proxy.GetWidgtEx<Text>("Txt_StarAttr" + i)); |
|
67 |
} |
|
68 |
showWayBtn = proxy.GetWidgtEx<Button>("GetItemBtn"); |
|
69 |
activeBtn = proxy.GetWidgtEx<Button>("Btn_Operate_3"); |
|
70 |
starUpBtn = proxy.GetWidgtEx<Button>("Btn_Operate_2"); |
|
71 |
lvUpBtn = proxy.GetWidgtEx<Button>("Btn_Operate_1"); |
|
72 |
getWaysTips = proxy.GetWidgtEx<TipGetWaysWidget>("GetWaysTips"); |
|
73 |
lvRedpoint = proxy.GetWidgtEx<RedpointBehaviour>("RedPointLV"); |
|
74 |
starRedpoint = proxy.GetWidgtEx<RedpointBehaviour>("RedPointStar"); |
|
75 |
activeRedpoint = proxy.GetWidgtEx<RedpointBehaviour>("RedPointActive"); |
|
76 |
|
|
77 |
getRedpoint = proxy.GetWidgtEx<RedpointBehaviour>("RedPointGet"); |
|
78 |
awardObj = proxy.GetWidgtEx<Transform>("Widget_Item"); |
|
79 |
getAwardBtn = proxy.GetWidgtEx<Button>("Btn_Operate_4"); |
|
80 |
awardItem = proxy.GetWidgtEx<ItemCell>("itemCell"); |
|
81 |
awardText = proxy.GetWidgtEx<Text>("Txt_GetTip"); |
|
82 |
|
4a006e
|
83 |
//古宝共鸣相关 |
L |
84 |
Content1 = proxy.GetWidgtEx<Transform>("Content1"); |
|
85 |
scroller = proxy.GetWidgtEx<ScrollerController>("scroller"); |
|
86 |
scroller1 = proxy.GetWidgtEx<ScrollerController>("scroller1"); |
|
87 |
txtTitle = proxy.GetWidgtEx<TextEx>("txtTitle"); |
a27c7f
|
88 |
} |
H |
89 |
|
|
90 |
protected override void AddListeners() |
|
91 |
{ |
a7792b
|
92 |
m_Close.SetListener(() =>
|
L |
93 |
{ |
a27c7f
|
94 |
CloseWin<TreasurePavilionTipWin>(); |
H |
95 |
}); |
|
96 |
|
a7792b
|
97 |
showWayBtn.SetListener(() =>
|
L |
98 |
{ |
a27c7f
|
99 |
if (getWaysTips.gameObject.activeSelf) |
H |
100 |
{ |
|
101 |
getWaysTips.SetActiveIL(false); |
|
102 |
} |
|
103 |
else |
|
104 |
{ |
|
105 |
getWaysTips.Bind("TreasurePavilionTipWin"); |
|
106 |
var config = ILGubaoConfig.Get(TreasurePavilionModel.Instance.selectGubao); |
|
107 |
getWaysTips.Display(ILItemCommon.GetGetWay(config.UnlockItemID)); |
|
108 |
} |
|
109 |
}); |
|
110 |
|
a7792b
|
111 |
activeBtn.SetListener(() =>
|
L |
112 |
{ |
a27c7f
|
113 |
TreasurePavilionModel.Instance.ActiveGubao(TreasurePavilionModel.Instance.selectGubao); |
H |
114 |
CloseWin<TreasurePavilionTipWin>(); |
|
115 |
}); |
|
116 |
|
a7792b
|
117 |
starUpBtn.SetListener(() =>
|
L |
118 |
{ |
a27c7f
|
119 |
CloseWin<TreasurePavilionTipWin>(); |
27c692
|
120 |
CloseWin<TreasurePavilionWin>(); |
a27c7f
|
121 |
TreasurePavilionModel.Instance.upgradeFuncOrder = 0; |
H |
122 |
TreasurePavilionModel.Instance.upgradeGubao = TreasurePavilionModel.Instance.selectGubao; |
f79687
|
123 |
WindowJumpMgr.Instance.ClearJumpData(); |
a27c7f
|
124 |
WindowCenter.Instance.OpenIL<TreasurePavilionUpgradeWin>(); |
H |
125 |
}); |
|
126 |
|
a7792b
|
127 |
lvUpBtn.SetListener(() =>
|
L |
128 |
{ |
a27c7f
|
129 |
CloseWin<TreasurePavilionTipWin>(); |
27c692
|
130 |
CloseWin<TreasurePavilionWin>(); |
a27c7f
|
131 |
TreasurePavilionModel.Instance.upgradeFuncOrder = 1; |
H |
132 |
TreasurePavilionModel.Instance.upgradeGubao = TreasurePavilionModel.Instance.selectGubao; |
f79687
|
133 |
WindowJumpMgr.Instance.ClearJumpData(); |
a27c7f
|
134 |
WindowCenter.Instance.OpenIL<TreasurePavilionUpgradeWin>(); |
H |
135 |
}); |
|
136 |
} |
|
137 |
|
|
138 |
protected override void OnPreOpen() |
|
139 |
{ |
4a006e
|
140 |
scroller.OnRefreshCell += OnRefreshCell; |
L |
141 |
scroller1.OnRefreshCell += OnRefreshCell1; |
a27c7f
|
142 |
getWaysTips.SetActiveIL(false); |
H |
143 |
var gubaoID = TreasurePavilionModel.Instance.selectGubao; |
|
144 |
var gubaoInfo = TreasurePavilionModel.Instance.TryGetGubaoInfo(gubaoID); |
|
145 |
var config = ILGubaoConfig.Get(gubaoID); |
3cb17f
|
146 |
Debug.LogFormat("古宝ID:{0} 物品ID:{1}", gubaoID, config.UnlockItemID); |
a27c7f
|
147 |
if (gubaoInfo.Count > 0 && gubaoInfo[1] > 0) |
H |
148 |
{ |
|
149 |
name.text = config.Name + "+" + gubaoInfo[1]; |
|
150 |
} |
|
151 |
else |
|
152 |
{ |
|
153 |
name.text = config.Name; |
|
154 |
} |
|
155 |
name.color = UIHelper.GetUIColor(config.GubaoQuality); |
|
156 |
gubaoImg.SetSprite(config.Icon); |
|
157 |
|
|
158 |
var maxStar = ILGubaoStarConfig.GetMaxStar(gubaoID); |
|
159 |
for (int i = 0; i < starObjs.Count; i++) |
|
160 |
{ |
|
161 |
if (i < maxStar) |
|
162 |
{ |
|
163 |
starObjs[i].SetActiveIL(true); |
|
164 |
if (gubaoInfo.Count > 0 && gubaoInfo[0] > i) |
|
165 |
{ |
|
166 |
starObjs[i].Find("star").GetComponent<Image>().SetActiveIL(true); |
|
167 |
} |
|
168 |
else |
|
169 |
{ |
|
170 |
starObjs[i].Find("star").GetComponent<Image>().SetActiveIL(false); |
|
171 |
} |
|
172 |
} |
|
173 |
else |
|
174 |
{ |
|
175 |
starObjs[i].SetActiveIL(false); |
|
176 |
} |
|
177 |
} |
|
178 |
var hasCnt = TreasurePavilionModel.Instance.GetGubaoItemCount(gubaoID);//packModel.GetItemCountByID(PackType.Item, config.UnlockItemID); |
|
179 |
pieceCnt.text = hasCnt.ToString(); |
|
180 |
var score = TreasurePavilionModel.Instance.GetGubaoScore(gubaoID); |
|
181 |
scoreText.SetActiveIL(score != 0); |
|
182 |
scoreText.text = Language.Get("DogzFunc106", score); |
|
183 |
descText.text = config.Desc; |
|
184 |
var showLV = gubaoInfo.Count == 0 ? 1 : gubaoInfo[1]; //未激活显示0级 |
|
185 |
var lvConfig = ILGubaoLVConfig.Get(ILGubaoLVConfig.GetGubaoQualityLVIndex(config.GubaoType, config.GubaoQuality, showLV)); |
|
186 |
for (int i = 0; i < baseAttrList.Count; i++) |
|
187 |
{ |
|
188 |
if (i < lvConfig.LVAttrTypeList.Length) |
|
189 |
{ |
|
190 |
baseAttrList[i].SetActiveIL(true); |
|
191 |
baseAttrList[i].text = PlayerPropertyConfig.GetFullDescription(lvConfig.LVAttrTypeList[i], lvConfig.LVAttrValueList[i]); |
|
192 |
} |
|
193 |
else |
|
194 |
{ |
|
195 |
baseAttrList[i].SetActiveIL(false); |
|
196 |
} |
|
197 |
} |
|
198 |
|
d9b91a
|
199 |
var starEffectsInfo = TreasurePavilionModel.Instance.GetGubaoEffects(gubaoID); |
a7792b
|
200 |
|
d9b91a
|
201 |
for (int i = 0; i < starAttrList.Count; i++) |
H |
202 |
{ |
|
203 |
if (i < starEffectsInfo.Count) |
a27c7f
|
204 |
{ |
d9b91a
|
205 |
starAttrList[i].SetActiveIL(true); |
H |
206 |
starAttrList[i].text = starEffectsInfo[i]; |
|
207 |
} |
|
208 |
else |
|
209 |
{ |
|
210 |
starAttrList[i].SetActiveIL(false); |
a27c7f
|
211 |
} |
H |
212 |
} |
|
213 |
|
|
214 |
activeBtn.SetActiveIL(gubaoInfo.Count == 0 && hasCnt >= config.UnlockItemCnt); |
|
215 |
starUpBtn.SetActiveIL(gubaoInfo.Count != 0 && maxStar > 1); |
|
216 |
lvUpBtn.SetActiveIL(gubaoInfo.Count != 0); |
|
217 |
|
|
218 |
activeRedpoint.redpointId = (MainRedPoint.cbgRedpoint * 10000 + TreasurePavilionModel.Instance.selectGubao) * 10; |
|
219 |
starRedpoint.redpointId = (MainRedPoint.cbgRedpoint * 10000 + TreasurePavilionModel.Instance.selectGubao) * 10 + 1; |
|
220 |
lvRedpoint.redpointId = (MainRedPoint.cbgRedpoint * 10000 + TreasurePavilionModel.Instance.selectGubao) * 10 + 2; |
d9b91a
|
221 |
getRedpoint.redpointId = (MainRedPoint.cbgRedpoint * 10000 + TreasurePavilionModel.Instance.selectGubao) * 10 + 3;
|
H |
222 |
|
|
223 |
|
|
224 |
var showStar = gubaoInfo.Count == 0 ? 1 : gubaoInfo[0]; |
|
225 |
var starConfig = ILGubaoStarConfig.Get(ILGubaoStarConfig.GetGubaoStarIndex(gubaoID, showStar)); |
a27c7f
|
226 |
|
H |
227 |
int effID = starConfig.StarEffIDList[0]; |
|
228 |
if (effID != 0 && ILGubaoEffAttrConfig.Get(effID).EffItemAwardList.Length > 2) |
|
229 |
{ |
|
230 |
awardObj.SetActiveIL(true); |
|
231 |
var effConfig = ILGubaoEffAttrConfig.Get(effID); |
|
232 |
var items = JsonMapper.ToObject<int[][]>(effConfig.EffItemAwardList); |
|
233 |
int itemID = items[0][0]; |
|
234 |
awardItem.Init(new ItemCellModel(itemID, false, (ulong)items[0][1])); |
a7792b
|
235 |
|
L |
236 |
awardItem.itemIcon.SetSprite(""); |
a27c7f
|
237 |
var count = 0; |
H |
238 |
if (TreasurePavilionModel.Instance.gubaoAwardDict.ContainsKey(gubaoID)) |
|
239 |
{ |
|
240 |
count = TreasurePavilionModel.Instance.gubaoAwardDict[gubaoID] / effConfig.EffCond; |
|
241 |
} |
|
242 |
awardText.text = Language.Get("gubaoGet", count); |
|
243 |
|
|
244 |
getAwardBtn.SetActiveIL(count > 0); |
a7792b
|
245 |
getAwardBtn.SetListener(() =>
|
L |
246 |
{ |
a27c7f
|
247 |
var pak = new IL_CA504_tagCMPlayerGetReward(); |
H |
248 |
pak.RewardType = 58; |
|
249 |
pak.DataEx = (uint)gubaoID; |
|
250 |
pak.DataExStr = effID.ToString(); |
|
251 |
pak.DataExStrLen = (byte)effID.ToString().Length; |
a7792b
|
252 |
GameNetSystem.Instance.SendInfo(pak);
|
L |
253 |
|
a27c7f
|
254 |
CloseWin<TreasurePavilionTipWin>(); |
H |
255 |
}); |
|
256 |
|
|
257 |
|
|
258 |
} |
|
259 |
else |
|
260 |
{ |
|
261 |
getAwardBtn.SetActiveIL(false); |
|
262 |
awardObj.SetActiveIL(false); |
|
263 |
} |
|
264 |
|
4a006e
|
265 |
var dict = GubaoResonanceConfig.GetGubaoIDToResonanceIDDict(); |
L |
266 |
if (dict.ContainsKey(TreasurePavilionModel.Instance.selectGubao))
|
|
267 |
{
|
|
268 |
int resonanceID = GubaoResonanceConfig.GetGubaoIDToResonanceIDDict()[TreasurePavilionModel.Instance.selectGubao];
|
|
269 |
Content1.SetActive(true);
|
a7792b
|
270 |
|
4a006e
|
271 |
scroller.Refresh();
|
L |
272 |
var gubaoIDArr = GubaoResonanceConfig.Get(resonanceID).GubaoIDList;
|
|
273 |
for (int i = 0; i < gubaoIDArr.Length; i++)
|
|
274 |
{
|
|
275 |
scroller.AddCell(ScrollerDataType.Header, gubaoIDArr[i]);
|
|
276 |
}
|
|
277 |
scroller.Restart();
|
|
278 |
|
|
279 |
scroller1.Refresh();
|
|
280 |
var starDict = GubaoResonanceAttrConfig.GetResonanceStarDict();
|
|
281 |
var allIdDict = GubaoResonanceAttrConfig.GetDict();
|
|
282 |
var starList = starDict[resonanceID];
|
|
283 |
for (int j = 0; j < starList.Count; j++)
|
|
284 |
{
|
|
285 |
int star = starList[j];
|
|
286 |
var id = allIdDict[resonanceID][star];
|
|
287 |
scroller1.AddCell(ScrollerDataType.Header, id);
|
|
288 |
}
|
|
289 |
scroller1.Restart();
|
|
290 |
txtTitle.text = GubaoResonanceConfig.Get(resonanceID).ResonanceName;
|
|
291 |
}
|
|
292 |
else
|
|
293 |
{
|
|
294 |
Content1.SetActive(false);
|
a7792b
|
295 |
}
|
L |
296 |
|
|
297 |
|
a27c7f
|
298 |
} |
H |
299 |
|
4a006e
|
300 |
protected override void OnPreClose() |
L |
301 |
{ |
|
302 |
scroller.OnRefreshCell -= OnRefreshCell; |
|
303 |
scroller1.OnRefreshCell -= OnRefreshCell1; |
|
304 |
}
|
|
305 |
|
|
306 |
void OnRefreshCell(ScrollerDataType type, CellView cell) |
|
307 |
{
|
a7792b
|
308 |
var _cell = cell as TreasurePavilionTipCell;
|
L |
309 |
_cell?.Display(_cell.index); |
4a006e
|
310 |
}
|
L |
311 |
|
|
312 |
void OnRefreshCell1(ScrollerDataType type, CellView cell) |
a7792b
|
313 |
{ |
L |
314 |
var _cell = cell as TreasurePavilionTipScrollerCell;
|
|
315 |
_cell?.Display(_cell.index); |
4a006e
|
316 |
}
|
a27c7f
|
317 |
#endregion |
4a006e
|
318 |
|
L |
319 |
|
|
320 |
|
a27c7f
|
321 |
} |