summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/UI/ItemAccessDlg.cs
blob: 4d6dbf608c175542cfabf12952983965706e2295 (plain)
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
using System;
using System.Collections.Generic;
using UILib;
using UnityEngine;
using XMainClient.UI.UICommon;
using XUtliPoolLib;

namespace XMainClient.UI
{
	internal class ItemAccessDlg : DlgBase<ItemAccessDlg, ItemAccessDlgBehaviour>
	{
		public override string fileName
		{
			get
			{
				return "Common/ItemAccessDlg";
			}
		}

		public override int layer
		{
			get
			{
				return 100;
			}
		}

		public override bool autoload
		{
			get
			{
				return true;
			}
		}

		private XFPStrengthenDocument _bqDocument;

		private AccessCallback _callback;

		private int _access_item = 0;

		private Dictionary<int, int> _idParam = new Dictionary<int, int>();

		protected override void Init()
		{
			this._bqDocument = XDocuments.GetSpecificDocument<XFPStrengthenDocument>(XFPStrengthenDocument.uuID);
		}

		public override void RegisterEvent()
		{
			base.uiBehaviour.m_Close.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnCloseClicked));
		}

		protected bool OnCloseClicked(IXUIButton go)
		{
			this.SetVisible(false, true);
			return true;
		}

		public void ShowAccess(int itemid, List<int> ids, List<int> param, AccessCallback callback = null)
		{
			this.SetVisible(true, true);
			this._idParam.Clear();
			this._callback = callback;
			this._access_item = itemid;
			base.uiBehaviour.m_Item.SetActive(true);
			base.uiBehaviour.m_BossItem.SetActive(false);
			XSingleton<XItemDrawerMgr>.singleton.normalItemDrawer.DrawItem(base.uiBehaviour.m_Item, itemid, 0, false);
			this.SetScrollViewItems(ids, param);
		}

		public void ShowMonsterAccess(uint monsterID, List<int> BQList, List<int> param, AccessCallback callback = null)
		{
			this.SetVisible(true, true);
			base.uiBehaviour.m_Item.SetActive(false);
			base.uiBehaviour.m_BossItem.SetActive(true);
			XEntityStatistics.RowData byID = XSingleton<XEntityMgr>.singleton.EntityStatistics.GetByID(monsterID);
			XEntityPresentation.RowData byPresentID = XSingleton<XEntityMgr>.singleton.EntityInfo.GetByPresentID(byID.PresentID);
			bool flag = byPresentID == null;
			if (!flag)
			{
				IXUISprite ixuisprite = base.uiBehaviour.m_BossItem.GetComponent("XUISprite") as IXUISprite;
				ixuisprite.SetSprite(byPresentID.Avatar, byPresentID.Atlas, false);
				bool flag2 = param != null && param.Count > 0;
				if (flag2)
				{
					SceneTable.RowData sceneData = XSingleton<XSceneMgr>.singleton.GetSceneData((uint)param[0]);
					bool flag3 = sceneData != null;
					if (flag3)
					{
						base.uiBehaviour.m_bossDec.SetText(sceneData.Comment);
					}
				}
				else
				{
					bool flag4 = byID != null;
					if (flag4)
					{
						base.uiBehaviour.m_bossDec.SetText(byID.Name);
					}
				}
				this._idParam.Clear();
				this._callback = callback;
				this._access_item = (int)monsterID;
				this.SetScrollViewItems(BQList, param);
			}
		}

		private void SetScrollViewItems(List<int> BQList, List<int> param)
		{
			bool flag = BQList == null || param == null;
			if (!flag)
			{
				List<AccessData> list = new List<AccessData>();
				for (int i = 0; i < BQList.Count; i++)
				{
					FpStrengthenTable.RowData strengthData = this._bqDocument.GetStrengthData(BQList[i]);
					bool flag2 = strengthData == null;
					if (!flag2)
					{
						bool flag3 = this._idParam.ContainsKey(BQList[i]);
						if (!flag3)
						{
							this._idParam.Add(BQList[i], param[i]);
							AccessData accessData = new AccessData();
							accessData.Row = strengthData;
							accessData.BQid = BQList[i];
							FpStrengthenTable.RowData strengthData2 = this._bqDocument.GetStrengthData(BQList[i]);
							XSysDefine bqsystem = (XSysDefine)strengthData2.BQSystem;
							accessData.SysType = bqsystem;
							bool flag4 = XSingleton<XGameSysMgr>.singleton.IsSystemOpened(bqsystem);
							accessData.OpenLevel = XSingleton<XGameSysMgr>.singleton.GetSysOpenLevel(XFastEnumIntEqualityComparer<XSysDefine>.ToInt(bqsystem));
							bool flag5 = flag4;
							if (flag5)
							{
								bool flag6 = XSysDefine.XSys_Level_Normal == bqsystem;
								if (flag6)
								{
									XLevelDocument xlevelDocument = XSingleton<XGame>.singleton.Doc.GetXComponent(XLevelDocument.uuID) as XLevelDocument;
									bool flag7 = param[i] > 0;
									if (flag7)
									{
										flag4 = (SceneRefuseReason.Admit == xlevelDocument.CanLevelOpen((uint)param[i]));
									}
									SceneTable.RowData sceneData = XSingleton<XSceneMgr>.singleton.GetSceneData((uint)param[i]);
									bool flag8 = sceneData != null;
									if (flag8)
									{
										accessData.OpenLevel = (int)sceneData.RequiredLevel;
									}
								}
								else
								{
									bool flag9 = XSysDefine.XSys_Level_Elite == bqsystem;
									if (flag9)
									{
										bool flag10 = 0 < param[i];
										if (flag10)
										{
											XLevelDocument xlevelDocument2 = XSingleton<XGame>.singleton.Doc.GetXComponent(XLevelDocument.uuID) as XLevelDocument;
											bool flag11 = param[i] < 10;
											if (!flag11)
											{
												flag4 = (SceneRefuseReason.Admit == xlevelDocument2.CanLevelOpen((uint)param[i]));
											}
										}
										SceneTable.RowData sceneData2 = XSingleton<XSceneMgr>.singleton.GetSceneData((uint)param[i]);
										bool flag12 = sceneData2 != null;
										if (flag12)
										{
											accessData.OpenLevel = (int)sceneData2.RequiredLevel;
										}
									}
									else
									{
										bool flag13 = XSysDefine.XSys_Activity_Nest == bqsystem;
										if (flag13)
										{
											XExpeditionDocument xexpeditionDocument = XSingleton<XGame>.singleton.Doc.GetXComponent(XExpeditionDocument.uuID) as XExpeditionDocument;
											int expIDBySceneID = xexpeditionDocument.GetExpIDBySceneID((uint)param[i]);
											ExpeditionTable.RowData expeditionDataByID = xexpeditionDocument.GetExpeditionDataByID(expIDBySceneID);
											bool flag14 = expeditionDataByID != null;
											if (flag14)
											{
												flag4 = xexpeditionDocument.TeamCategoryMgr.IsExpOpened(expeditionDataByID);
												accessData.OpenLevel = expeditionDataByID.RequiredLevel;
											}
											else
											{
												flag4 = false;
											}
										}
									}
								}
							}
							accessData.IsOpen = flag4;
							accessData.DescStr = strengthData.BQTips;
							bool flag15 = param[i] > 0;
							if (flag15)
							{
								SceneTable.RowData sceneData3 = XSingleton<XSceneMgr>.singleton.GetSceneData((uint)param[i]);
								bool flag16 = sceneData3 != null;
								if (flag16)
								{
									accessData.DescStr = string.Format(strengthData.BQTips, sceneData3.Comment);
									accessData.SceStr = sceneData3.Comment;
								}
								else
								{
									XSingleton<XDebug>.singleton.AddErrorLog(string.Concat(new object[]
									{
										"SceneId not exist ",
										i,
										"  ",
										param[i]
									}), null, null, null, null, null);
								}
							}
							list.Add(accessData);
						}
					}
				}
				list.Sort(new Comparison<AccessData>(this.Compare));
				base.uiBehaviour.m_RecordPool.ReturnAll(false);
				for (int j = 0; j < list.Count; j++)
				{
					AccessData accessData2 = list[j];
					bool flag17 = accessData2 == null;
					if (!flag17)
					{
						GameObject gameObject = base.uiBehaviour.m_RecordPool.FetchGameObject(false);
						gameObject.name = XSingleton<XCommon>.singleton.StringCombine("access", accessData2.BQid.ToString());
						gameObject.transform.localPosition = base.uiBehaviour.m_RecordPool.TplPos + new Vector3(0f, (float)(-(float)base.uiBehaviour.m_RecordPool.TplHeight * j), 0f);
						IXUISprite ixuisprite = gameObject.transform.Find("icon").GetComponent("XUISprite") as IXUISprite;
						IXUILabel ixuilabel = gameObject.transform.Find("name").GetComponent("XUILabel") as IXUILabel;
						IXUILabel ixuilabel2 = gameObject.transform.Find("desc").GetComponent("XUILabel") as IXUILabel;
						IXUILabel ixuilabel3 = gameObject.transform.Find("scene").GetComponent("XUILabel") as IXUILabel;
						IXUIButton ixuibutton = gameObject.transform.Find("goto").GetComponent("XUIButton") as IXUIButton;
						IXUILabel ixuilabel4 = gameObject.transform.Find("notopen").GetComponent("XUILabel") as IXUILabel;
						ixuisprite.SetSprite(accessData2.Row.BQImageID);
						ixuilabel.SetText(accessData2.Row.BQName);
						ixuilabel2.SetText(accessData2.DescStr);
						ixuilabel3.SetText(accessData2.SceStr);
						bool isOpen = accessData2.IsOpen;
						if (isOpen)
						{
							ixuibutton.gameObject.SetActive(true);
							ixuilabel4.gameObject.SetActive(false);
							ixuibutton.ID = (ulong)((long)accessData2.BQid);
							ixuibutton.RegisterClickEventHandler(new ButtonClickEventHandler(this.GoToAccessSys));
						}
						else
						{
							ixuibutton.gameObject.SetActive(false);
							ixuilabel4.gameObject.SetActive(true);
							bool flag18 = XSysDefine.XSys_Level_Elite == accessData2.SysType || XSysDefine.XSys_Level_Normal == accessData2.SysType;
							if (flag18)
							{
								bool flag19 = (long)accessData2.OpenLevel > (long)((ulong)XSingleton<XAttributeMgr>.singleton.XPlayerData.Level);
								if (flag19)
								{
									ixuilabel4.SetText(string.Format(XSingleton<XStringTable>.singleton.GetString("SKILL_LEARN"), accessData2.OpenLevel));
								}
								else
								{
									ixuilabel4.SetText(XSingleton<XStringTable>.singleton.GetString("ShouldFinishMainTask"));
								}
							}
							else
							{
								ixuilabel4.SetText(string.Format(XSingleton<XStringTable>.singleton.GetString("SKILL_LEARN"), accessData2.OpenLevel));
							}
						}
						bool flag20 = XSingleton<XGame>.singleton.CurrentStage.Stage != EXStage.Hall;
						if (flag20)
						{
							ixuibutton.SetVisible(false);
						}
					}
				}
				base.uiBehaviour.m_RecordScrollView.ResetPosition();
			}
		}

		private int Compare(AccessData left, AccessData right)
		{
			bool isOpen = left.IsOpen;
			int result;
			if (isOpen)
			{
				result = -1;
			}
			else
			{
				result = 1;
			}
			return result;
		}

		public bool GoToAccessSys(IXUIButton sp)
		{
			int num = (int)sp.ID;
			FpStrengthenTable.RowData strengthData = this._bqDocument.GetStrengthData(num);
			bool flag = strengthData == null;
			bool result;
			if (flag)
			{
				result = false;
			}
			else
			{
				XSysDefine bqsystem = (XSysDefine)strengthData.BQSystem;
				XSysDefine xsysDefine = bqsystem;
				if (xsysDefine <= XSysDefine.XSys_Mall_Mall)
				{
					if (xsysDefine == XSysDefine.XSys_Level_Normal)
					{
						XLevelDocument specificDocument = XDocuments.GetSpecificDocument<XLevelDocument>(XLevelDocument.uuID);
						specificDocument.AutoGoBattle(this._idParam[num], 0, 0u);
						goto IL_284;
					}
					if (xsysDefine == XSysDefine.XSys_Level_Elite)
					{
						XLevelDocument specificDocument2 = XDocuments.GetSpecificDocument<XLevelDocument>(XLevelDocument.uuID);
						bool flag2 = this._idParam[num] < 10;
						if (flag2)
						{
							specificDocument2.AutoGoBattle(0, this._idParam[num], 1u);
						}
						else
						{
							specificDocument2.AutoGoBattle(this._idParam[num], 0, 1u);
						}
						goto IL_284;
					}
					if (xsysDefine != XSysDefine.XSys_Mall_Mall)
					{
						goto IL_261;
					}
				}
				else
				{
					if (xsysDefine == XSysDefine.XSys_Mall_Guild)
					{
						XGuildDocument specificDocument3 = XDocuments.GetSpecificDocument<XGuildDocument>(XGuildDocument.uuID);
						this.SetVisible(false, true);
						bool flag3 = !specificDocument3.bInGuild;
						if (flag3)
						{
							XSingleton<XGameSysMgr>.singleton.OpenSystem(XSysDefine.XSys_Guild, 0UL);
						}
						else
						{
							XSingleton<XGameSysMgr>.singleton.OpenSystem((XSysDefine)strengthData.BQSystem, (ulong)((long)this._access_item));
						}
						goto IL_284;
					}
					if (xsysDefine == XSysDefine.XSys_Activity_Nest)
					{
						this.SetVisible(false, true);
						bool flag4 = 0 <= this._idParam[num];
						if (flag4)
						{
							XExpeditionDocument xexpeditionDocument = XSingleton<XGame>.singleton.Doc.GetXComponent(XExpeditionDocument.uuID) as XExpeditionDocument;
							int expIDBySceneID = xexpeditionDocument.GetExpIDBySceneID((uint)this._idParam[num]);
							ExpeditionTable.RowData expeditionDataByID = xexpeditionDocument.GetExpeditionDataByID(expIDBySceneID);
							bool flag5 = expeditionDataByID != null;
							if (flag5)
							{
								ExpeditionTable.RowData expeditionDataByID2 = xexpeditionDocument.GetExpeditionDataByID(this._idParam[num]);
								bool flag6 = expeditionDataByID2 != null;
								if (flag6)
								{
									DlgBase<TheExpView, TheExpBehaviour>.singleton.ShowView(expeditionDataByID2.DNExpeditionID);
								}
								else
								{
									DlgBase<TheExpView, TheExpBehaviour>.singleton.ShowView(-1);
								}
							}
						}
						else
						{
							DlgBase<TheExpView, TheExpBehaviour>.singleton.ShowViewByExpID(this._idParam[num]);
						}
						goto IL_284;
					}
					if (xsysDefine != XSysDefine.XSys_Activity_TeamTower)
					{
						goto IL_261;
					}
				}
				this.SetVisible(false, true);
				bool flag7 = this._callback != null;
				if (flag7)
				{
					this._callback();
				}
				XSingleton<XGameSysMgr>.singleton.OpenSystem(bqsystem, 0UL);
				goto IL_284;
				IL_261:
				this.SetVisible(false, true);
				XSingleton<XGameSysMgr>.singleton.OpenSystem((XSysDefine)strengthData.BQSystem, (ulong)((long)this._access_item));
				IL_284:
				result = true;
			}
			return result;
		}
	}
}