summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/UI/PandoraView.cs
blob: 45ac3886c851d861783eec6b293e1f2a3734e94c (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
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
using System;
using System.Collections.Generic;
using KKSG;
using UILib;
using UnityEngine;
using XMainClient.UI.UICommon;
using XUtliPoolLib;

namespace XMainClient.UI
{
	internal class PandoraView : DlgBase<PandoraView, PandoraBehaviour>
	{
		private OutLook outLook
		{
			get
			{
				bool flag = this.m_outLook == null;
				if (flag)
				{
					this.m_outLook = new OutLook();
				}
				bool flag2 = this.m_outLook.display_fashion == null;
				if (flag2)
				{
					this.m_outLook.display_fashion = new OutLookDisplayFashion();
				}
				return this.m_outLook;
			}
		}

		public override string fileName
		{
			get
			{
				return "GameSystem/PandoraDlg";
			}
		}

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

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

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

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

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

		public override int sysid
		{
			get
			{
				return XFastEnumIntEqualityComparer<XSysDefine>.ToInt(XSysDefine.XSys_Pandora);
			}
		}

		private PandoraDocument _doc;

		private XShowGetItemDocument _showItemDoc;

		private ItemListHandler _itemListHandler;

		private XFx m_OpenFx = null;

		private List<XFx> m_FxList = new List<XFx>();

		private XDummy[] m_Dummy = new XDummy[3];

		private Vector3[] m_DummyAngle = new Vector3[3];

		private Vector3[] m_DummyScale = new Vector3[3];

		private const int _avatarSlot = 8;

		private uint _fxTimeToken = 0u;

		private OutLook m_outLook;

		protected override void Init()
		{
			base.Init();
			this._doc = XDocuments.GetSpecificDocument<PandoraDocument>(PandoraDocument.uuID);
			this._showItemDoc = XDocuments.GetSpecificDocument<XShowGetItemDocument>(XShowGetItemDocument.uuID);
		}

		public override int[] GetTitanBarItems()
		{
			return new int[]
			{
				(int)this._doc.PandoraData.PandoraID,
				(int)this._doc.PandoraData.FireID
			};
		}

		protected override void OnShow()
		{
			base.OnShow();
			base.Alloc3DAvatarPool("PandoraView");
			this._showItemDoc.bIgonre = true;
			this.m_DummyAngle[0] = new Vector3(this._doc.PandoraData.DisplayAngle0[0], this._doc.PandoraData.DisplayAngle0[1], this._doc.PandoraData.DisplayAngle0[2]);
			this.m_DummyAngle[1] = new Vector3(this._doc.PandoraData.DisplayAngle1[0], this._doc.PandoraData.DisplayAngle1[1], this._doc.PandoraData.DisplayAngle1[2]);
			this.m_DummyAngle[2] = new Vector3(this._doc.PandoraData.DisplayAngle2[0], this._doc.PandoraData.DisplayAngle2[1], this._doc.PandoraData.DisplayAngle2[2]);
			this.m_DummyScale[0] = new Vector3(this._doc.PandoraData.DisplayAngle0[3], this._doc.PandoraData.DisplayAngle0[4], this._doc.PandoraData.DisplayAngle0[5]);
			this.m_DummyScale[1] = new Vector3(this._doc.PandoraData.DisplayAngle1[3], this._doc.PandoraData.DisplayAngle1[4], this._doc.PandoraData.DisplayAngle1[5]);
			this.m_DummyScale[2] = new Vector3(this._doc.PandoraData.DisplayAngle2[3], this._doc.PandoraData.DisplayAngle2[4], this._doc.PandoraData.DisplayAngle2[5]);
			base.uiBehaviour.m_DisplayLabel[0].SetText(this._doc.PandoraData.DisplayName0);
			base.uiBehaviour.m_DisplayLabel[1].SetText(this._doc.PandoraData.DisplayName1);
			base.uiBehaviour.m_DisplayLabel[2].SetText(this._doc.PandoraData.DisplayName2);
			this.ShowDisplayFrame();
		}

		protected override void OnHide()
		{
			this._showItemDoc.bIgonre = false;
			this.ClearAllFx();
			this._doc.DestroyFx(this.m_OpenFx);
			this.m_OpenFx = null;
			base.Return3DAvatarPool();
			XSingleton<XTimerMgr>.singleton.KillTimer(this._fxTimeToken);
			base.OnHide();
		}

		public override void StackRefresh()
		{
			base.StackRefresh();
			base.Alloc3DAvatarPool("PandoraView");
			this._showItemDoc.bIgonre = true;
		}

		public override void LeaveStackTop()
		{
			base.LeaveStackTop();
			this._showItemDoc.bIgonre = false;
		}

		protected override void OnUnload()
		{
			this.ClearAllFx();
			this._doc.DestroyFx(this.m_OpenFx);
			this.m_OpenFx = null;
			this.m_outLook = null;
			base.Return3DAvatarPool();
			XSingleton<XTimerMgr>.singleton.KillTimer(this._fxTimeToken);
			DlgHandlerBase.EnsureUnload<ItemListHandler>(ref this._itemListHandler);
			base.OnUnload();
		}

		public override void RegisterEvent()
		{
			base.RegisterEvent();
			base.uiBehaviour.m_BackButton.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnBackClicked));
			base.uiBehaviour.m_OnceButton.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnOnceButtonClicked));
			base.uiBehaviour.m_TenButton.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnTenButtonClicked));
			base.uiBehaviour.m_OKButton.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnOKButtonClicked));
			base.uiBehaviour.m_ItemListButton.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnItemListButtonClicked));
			base.uiBehaviour.m_DisplayPoint[0].RegisterSpriteDragEventHandler(new SpriteDragEventHandler(this.OnAvatarDrag0));
			base.uiBehaviour.m_DisplayPoint[1].RegisterSpriteDragEventHandler(new SpriteDragEventHandler(this.OnAvatarDrag1));
			base.uiBehaviour.m_DisplayPoint[2].RegisterSpriteDragEventHandler(new SpriteDragEventHandler(this.OnAvatarDrag2));
		}

		private void OnBackClicked(IXUISprite sp)
		{
			this.SetVisible(false, true);
		}

		private bool OnOnceButtonClicked(IXUIButton button)
		{
			this._doc.SendPandoraLottery(true);
			return true;
		}

		private bool OnTenButtonClicked(IXUIButton button)
		{
			this._doc.SendPandoraLottery(false);
			return true;
		}

		private bool OnOKButtonClicked(IXUIButton button)
		{
			this.ShowDisplayFrame();
			XScreenShotShareDocument specificDocument = XDocuments.GetSpecificDocument<XScreenShotShareDocument>(XScreenShotShareDocument.uuID);
			bool flag = specificDocument.CurShareBgType == ShareBgType.LuckyPandora && specificDocument.SpriteID > 0u;
			if (flag)
			{
				XSingleton<PDatabase>.singleton.shareCallbackType = ShareCallBackType.GloryPic;
				DlgBase<DungeonShareView, DungeonShareBehavior>.singleton.SetVisibleWithAnimation(true, null);
			}
			return true;
		}

		private bool OnItemListButtonClicked(IXUIButton button)
		{
			DlgHandlerBase.EnsureCreate<ItemListHandler>(ref this._itemListHandler, base.uiBehaviour.transform, false, null);
			this._itemListHandler.ShowItemList(PandoraDocument.ItemList);
			return true;
		}

		private bool OnAvatarDrag0(Vector2 delta)
		{
			bool flag = this.m_Dummy[0] != null;
			if (flag)
			{
				this.m_Dummy[0].EngineObject.Rotate(Vector3.up, -delta.x / 2f);
				this.m_DummyAngle[0] = this.m_Dummy[0].EngineObject.LocalEulerAngles;
			}
			return true;
		}

		private bool OnAvatarDrag1(Vector2 delta)
		{
			bool flag = this.m_Dummy[1] != null;
			if (flag)
			{
				this.m_Dummy[1].EngineObject.Rotate(Vector3.up, -delta.x / 2f);
				this.m_DummyAngle[1] = this.m_Dummy[1].EngineObject.LocalEulerAngles;
			}
			return true;
		}

		private bool OnAvatarDrag2(Vector2 delta)
		{
			bool flag = this.m_Dummy[2] != null;
			if (flag)
			{
				this.m_Dummy[2].EngineObject.Rotate(Vector3.up, -delta.x / 2f);
				this.m_DummyAngle[2] = this.m_Dummy[2].EngineObject.LocalEulerAngles;
			}
			return true;
		}

		public void ShowDisplayFrame()
		{
			base.uiBehaviour.m_DisplayFrame.gameObject.SetActive(true);
			base.uiBehaviour.m_RewardFrame.gameObject.SetActive(false);
			base.uiBehaviour.m_BackButton.SetVisible(true);
			base.uiBehaviour.m_OnceButton.SetVisible(true);
			base.uiBehaviour.m_TenButton.SetVisible(true);
			this.RefreshDummy();
		}

		private void RefreshDummy()
		{
			for (int i = 0; i < 3; i++)
			{
				uint[] array = null;
				switch (i)
				{
				case 0:
					array = this._doc.PandoraData.DisplaySlot0;
					break;
				case 1:
					array = this._doc.PandoraData.DisplaySlot1;
					break;
				case 2:
					array = this._doc.PandoraData.DisplaySlot2;
					break;
				}
				bool flag = array == null;
				if (!flag)
				{
					base.uiBehaviour.m_DisplayAvatar[i].transform.localScale = this.m_DummyScale[i];
					uint num = array[0];
					if (num != 0u)
					{
						if (num == 1u)
						{
							uint presentID = this.TransItemToPresentID(array[1]);
							string rideAnim = this.GetRideAnim(array[1]);
							this.m_Dummy[i] = XSingleton<X3DAvatarMgr>.singleton.CreateCommonEntityDummy(this.m_dummPool, presentID, base.uiBehaviour.m_DisplayAvatar[i], this.m_Dummy[i], 1f);
							this.m_Dummy[i].SetAnimation(rideAnim);
							this.m_Dummy[i].EngineObject.LocalEulerAngles = this.m_DummyAngle[i];
						}
					}
					else
					{
						List<uint> list = new List<uint>();
						for (int j = 1; j < array.Length; j++)
						{
							list.Add(array[j]);
						}
						XPlayerAttributes xplayerData = XSingleton<XAttributeMgr>.singleton.XPlayerData;
						bool flag2 = xplayerData != null;
						if (flag2)
						{
							this.outLook.display_fashion.display_fashions.Clear();
							this.outLook.display_fashion.display_fashions.AddRange(list);
							this.m_Dummy[i] = XSingleton<X3DAvatarMgr>.singleton.CreateCommonRoleDummy(this.m_dummPool, xplayerData.RoleID, (uint)XFastEnumIntEqualityComparer<RoleType>.ToInt(xplayerData.Profession), this.outLook, base.uiBehaviour.m_DisplayAvatar[i], this.m_Dummy[i]);
							this.m_Dummy[i].EngineObject.LocalEulerAngles = this.m_DummyAngle[i];
						}
					}
				}
			}
		}

		private uint TransItemToPresentID(uint itemid)
		{
			uint petID = XPetDocument.GetPetID(itemid);
			return XPetDocument.GetPresentID(petID);
		}

		private string GetRideAnim(uint itemid)
		{
			uint petID = XPetDocument.GetPetID(itemid);
			XPetDocument specificDocument = XDocuments.GetSpecificDocument<XPetDocument>(XPetDocument.uuID);
			PetBubble.RowData petBubble = specificDocument.GetPetBubble(XPetActionFile.IDLE, petID);
			bool flag = petBubble == null;
			string result;
			if (flag)
			{
				XSingleton<XDebug>.singleton.AddErrorLog(string.Concat(new object[]
				{
					"PetBubble No Find\nitemid:",
					itemid,
					" petid:",
					petID
				}), null, null, null, null, null);
				result = null;
			}
			else
			{
				result = petBubble.ActionFile;
			}
			return result;
		}

		public void PlayOpenFx()
		{
			base.uiBehaviour.m_BackButton.SetVisible(false);
			base.uiBehaviour.m_OnceButton.SetVisible(false);
			base.uiBehaviour.m_TenButton.SetVisible(false);
			this._doc.DestroyFx(this.m_OpenFx);
			this.m_OpenFx = null;
			this.m_OpenFx = this._doc.CreateAndPlayFx("Effects/FX_Particle/UIfx/UI_pdlzx_Clip01", base.uiBehaviour.m_FxPoint);
			XSingleton<XAudioMgr>.singleton.PlayUISound("Audio/UI/UI_PandoraHeart_Ten", true, AudioChannel.Action);
			this._fxTimeToken = XSingleton<XTimerMgr>.singleton.SetTimer((float)XSingleton<XGlobalConfig>.singleton.GetInt("PandoraFxTime") / 10f, new XTimerMgr.ElapsedEventHandler(this.ShowRewardFrame), null);
		}

		public void ShowRewardFrame(object o = null)
		{
			base.uiBehaviour.m_DisplayFrame.gameObject.SetActive(false);
			base.uiBehaviour.m_RewardFrame.gameObject.SetActive(true);
			this.ClearAllFx();
			this._doc.DestroyFx(this.m_OpenFx);
			this.m_OpenFx = null;
			base.uiBehaviour.m_ResultPool.FakeReturnAll();
			for (int i = 0; i < this._doc.ItemCache.Count; i++)
			{
				this.SetupItem(i);
			}
			base.uiBehaviour.m_ResultPool.ActualReturnAll(false);
		}

		private void SetupItem(int index)
		{
			GameObject gameObject = base.uiBehaviour.m_ResultPool.FetchGameObject(false);
			IXUITweenTool ixuitweenTool = gameObject.GetComponent("XUIPlayTween") as IXUITweenTool;
			GameObject gameObject2 = gameObject.transform.Find("ItemTpl").gameObject;
			IXUISprite ixuisprite = gameObject2.transform.Find("Icon").GetComponent("XUISprite") as IXUISprite;
			XSingleton<XItemDrawerMgr>.singleton.normalItemDrawer.DrawItem(gameObject2, (int)this._doc.ItemCache[index].itemID, (int)this._doc.ItemCache[index].itemCount, false);
			Transform parent = gameObject.transform.Find("Fx");
			ixuisprite.ID = (ulong)this._doc.ItemCache[index].itemID;
			bool isbind = this._doc.ItemCache[index].isbind;
			if (isbind)
			{
				ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(XSingleton<UiUtility>.singleton.OnBindItemClick));
			}
			else
			{
				ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(XSingleton<UiUtility>.singleton.OnItemClick));
			}
			ItemList.RowData itemConf = XBagDocument.GetItemConf((int)this._doc.ItemCache[index].itemID);
			switch (itemConf.ItemQuality)
			{
			case 3:
				this.m_FxList.Add(this._doc.CreateAndPlayFx("Effects/FX_Particle/UIfx/UI_jl_04_orange", parent));
				break;
			case 4:
				this.m_FxList.Add(this._doc.CreateAndPlayFx("Effects/FX_Particle/UIfx/UI_jl_04_purple", parent));
				break;
			case 5:
				this.m_FxList.Add(this._doc.CreateAndPlayFx("Effects/FX_Particle/UIfx/UI_jl_04_red", parent));
				break;
			}
			gameObject.transform.localPosition = this.GetItemPos(index, this._doc.ItemCache.Count, 5, (float)base.uiBehaviour.m_ResultPool.TplWidth, (float)base.uiBehaviour.m_ResultPool.TplHeight, base.uiBehaviour.m_ResultPool.TplPos);
			ixuitweenTool.ResetTween(true);
			ixuitweenTool.PlayTween(true, -1f);
		}

		private Vector3 GetItemPos(int index, int totalCount, int lineCount, float width, float height, Vector3 centerPos)
		{
			float num = centerPos.x - (float)(lineCount - 1) * width / 2f;
			float num2 = centerPos.y + (float)((totalCount + lineCount - 1) / lineCount) * height / 2f;
			bool flag = totalCount / lineCount == index / lineCount;
			if (flag)
			{
				num += (float)(lineCount - totalCount % lineCount) * width / 2f;
			}
			float num3 = num + (float)(index % lineCount) * width;
			float num4 = num2 - (float)(index / lineCount) * height;
			return new Vector3(num3, num4);
		}

		private void ClearAllFx()
		{
			for (int i = 0; i < this.m_FxList.Count; i++)
			{
				this._doc.DestroyFx(this.m_FxList[i]);
			}
			this.m_FxList.Clear();
		}
	}
}