summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/BattleCaptainPVPHandler.cs
blob: 888f20f0dd1b22c9da84fde6b8adb2afe76cc7b8 (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
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
using System;
using UILib;
using UnityEngine;
using XUtliPoolLib;

namespace XMainClient
{
	internal class BattleCaptainPVPHandler : DlgHandlerBase
	{
		protected override string FileName
		{
			get
			{
				return "Battle/BattleCaptainPVP";
			}
		}

		private XBattleCaptainPVPDocument _doc = null;

		private Vector3 NoVisible = new Vector3(2000f, 0f, 0f);

		private uint _StratTimerID = 0u;

		private uint _RefreshDataTimerID = 0u;

		private ulong BlueLeader = 0UL;

		private ulong RedLeader = 0UL;

		public string picPath = null;

		public IXUILabel m_Leader;

		public IXUILabel m_Blue;

		public IXUILabel m_Red;

		public IXUILabel m_AllEndTime;

		public IXUILabel m_RoundEndTime;

		public IXUILabel m_EndText;

		public IXUILabel m_ReliveTime;

		public IXUITweenTool m_Start;

		public IXUITweenTool m_Relive;

		public IXUITweenTool m_End;

		public IXUITexture m_EndIcon;

		public IXUISprite m_KillText;

		public Transform teamLeader;

		public IXUILabel m_BlueLeaderName;

		public IXUILabel m_BlueHpPer;

		public IXUIProgress m_BlueHpBar;

		public IXUILabel m_RedLeaderName;

		public IXUILabel m_RedHpPer;

		public IXUIProgress m_RedHpBar;

		public GameObject m_Win;

		public GameObject m_Draw;

		public GameObject m_Lose;

		public IXUITweenTool[] m_Killicon = new IXUITweenTool[XBattleCaptainPVPDocument.CONTINUOUS_KILL + 1u];

		private Vector3 infoDis;

		public XUIPool m_ShowIntoPool = new XUIPool(XSingleton<XGameUI>.singleton.m_uiTool);

		public IXUILabel[] m_Killer = new IXUILabel[XBattleCaptainPVPDocument.GAME_INFO];

		public IXUILabel[] m_Dead = new IXUILabel[XBattleCaptainPVPDocument.GAME_INFO];

		public IXUISprite[] m_InfoIcon = new IXUISprite[XBattleCaptainPVPDocument.GAME_INFO];

		protected override void Init()
		{
			base.Init();
			XBattleCaptainPVPDocument specificDocument = XDocuments.GetSpecificDocument<XBattleCaptainPVPDocument>(XBattleCaptainPVPDocument.uuID);
			specificDocument.Handler = this;
			this.m_Leader = (base.PanelObject.transform.Find("Start/Leader").GetComponent("XUILabel") as IXUILabel);
			this.m_Start = (base.PanelObject.transform.Find("Start").GetComponent("XUIPlayTween") as IXUITweenTool);
			this.m_Blue = (base.PanelObject.transform.Find("Sorce/Blue").GetComponent("XUILabel") as IXUILabel);
			this.m_Red = (base.PanelObject.transform.Find("Sorce/Red").GetComponent("XUILabel") as IXUILabel);
			this.m_End = (base.PanelObject.transform.Find("End").GetComponent("XUIPlayTween") as IXUITweenTool);
			this.m_Win = base.PanelObject.transform.Find("End/Win").gameObject;
			this.m_Draw = base.PanelObject.transform.Find("End/Draw").gameObject;
			this.m_Lose = base.PanelObject.transform.Find("End/Lose").gameObject;
			this.m_AllEndTime = (base.PanelObject.transform.Find("End/AllEndTime").GetComponent("XUILabel") as IXUILabel);
			this.m_RoundEndTime = (base.PanelObject.transform.Find("End/RoundEndTime").GetComponent("XUILabel") as IXUILabel);
			this.m_EndText = (base.PanelObject.transform.Find("End/T").GetComponent("XUILabel") as IXUILabel);
			this.m_ReliveTime = (base.PanelObject.transform.Find("ReliveTime").GetComponent("XUILabel") as IXUILabel);
			this.m_Relive = (base.PanelObject.transform.Find("ReliveTime").GetComponent("XUIPlayTween") as IXUITweenTool);
			this.m_EndIcon = (base.PanelObject.transform.Find("End/Icon").GetComponent("XUITexture") as IXUITexture);
			int num = 1;
			while ((long)num <= (long)((ulong)XBattleCaptainPVPDocument.CONTINUOUS_KILL))
			{
				this.m_Killicon[num] = (base.PanelObject.transform.Find("Continuous/Killicon" + num).GetComponent("XUIPlayTween") as IXUITweenTool);
				num++;
			}
			this.m_KillText = (base.PanelObject.transform.Find("Continuous/KillText").GetComponent("XUISprite") as IXUISprite);
			Transform transform = base.PanelObject.transform.Find("KillInfo/Bg/InfoTpl");
			this.m_ShowIntoPool.SetupPool(null, transform.gameObject, XDeck.GROUP_NEED_CARD_MAX, false);
			this.m_ShowIntoPool.FakeReturnAll();
			int num2 = 0;
			while ((long)num2 < (long)((ulong)XBattleCaptainPVPDocument.GAME_INFO))
			{
				GameObject gameObject = this.m_ShowIntoPool.FetchGameObject(false);
				IXUISprite ixuisprite = gameObject.GetComponent("XUISprite") as IXUISprite;
				this.infoDis = new Vector3(0f, (float)(-(float)ixuisprite.spriteHeight), 0f);
				gameObject.transform.localPosition = this.infoDis * (float)num2;
				this.m_Killer[num2] = (gameObject.transform.Find("killer").GetComponent("XUILabel") as IXUILabel);
				this.m_Dead[num2] = (gameObject.transform.Find("dead").GetComponent("XUILabel") as IXUILabel);
				this.m_InfoIcon[num2] = (gameObject.transform.Find("icon").GetComponent("XUISprite") as IXUISprite);
				num2++;
			}
			this.m_ShowIntoPool.ActualReturnAll(false);
			this._doc = XDocuments.GetSpecificDocument<XBattleCaptainPVPDocument>(XBattleCaptainPVPDocument.uuID);
			this.teamLeader = base.PanelObject.transform.Find("TeamLeader");
			this.m_BlueLeaderName = (this.teamLeader.Find("LeaderBlue").GetComponent("XUILabel") as IXUILabel);
			this.m_BlueHpPer = (this.teamLeader.Find("LeaderBlue/Per").GetComponent("XUILabel") as IXUILabel);
			this.m_BlueHpBar = (this.teamLeader.Find("LeaderBlue/HpBar").GetComponent("XUIProgress") as IXUIProgress);
			this.m_RedLeaderName = (this.teamLeader.transform.Find("LeaderRed").GetComponent("XUILabel") as IXUILabel);
			this.m_RedHpPer = (this.teamLeader.transform.Find("LeaderRed/Per").GetComponent("XUILabel") as IXUILabel);
			this.m_RedHpBar = (this.teamLeader.transform.Find("LeaderRed/HpBar").GetComponent("XUIProgress") as IXUIProgress);
		}

		public override void RegisterEvent()
		{
		}

		protected override void OnShow()
		{
			base.OnShow();
			this.InitShow();
			XSingleton<XTimerMgr>.singleton.KillTimer(this._StratTimerID);
			XSingleton<XTimerMgr>.singleton.KillTimer(this._RefreshDataTimerID);
		}

		protected override void OnHide()
		{
			XSingleton<XTimerMgr>.singleton.KillTimer(this._StratTimerID);
			XSingleton<XTimerMgr>.singleton.KillTimer(this._RefreshDataTimerID);
			this._StratTimerID = 0u;
			this._RefreshDataTimerID = 0u;
			this.m_EndIcon.SetTexturePath("");
			base.OnHide();
		}

		public override void OnUnload()
		{
			bool flag = base.PanelObject != null;
			if (flag)
			{
				base.PanelObject.SetActive(false);
			}
			this._doc.TeamBlood.Clear();
			this._doc.Handler = null;
			XSingleton<XTimerMgr>.singleton.KillTimer(this._StratTimerID);
			XSingleton<XTimerMgr>.singleton.KillTimer(this._RefreshDataTimerID);
			this._StratTimerID = 0u;
			this._RefreshDataTimerID = 0u;
			this._doc.myTeam = 0;
			this._doc.groupLeader1 = 0UL;
			this._doc.groupLeader2 = 0UL;
			this._doc.spectateInitTeam = 0;
			this._doc.spectateNowTeam = 0;
			this._doc.playedBigResult = false;
			base.OnUnload();
		}

		public override void OnUpdate()
		{
			base.OnUpdate();
		}

		private void InitShow()
		{
			this._doc.qInfo.Clear();
			this.m_Start.gameObject.SetActive(false);
			this.m_End.gameObject.SetActive(false);
			this.m_ReliveTime.gameObject.SetActive(false);
			this.ShowGameInfo();
			this.ShowConKill(0);
			this.m_Blue.SetText("0");
			this.m_Red.SetText("0");
			this.m_BlueLeaderName.SetText("");
			this.m_BlueHpPer.SetText("");
			this.m_BlueHpBar.value = 0f;
			this.m_RedLeaderName.SetText("");
			this.m_RedHpPer.SetText("");
			this.m_RedHpBar.value = 0f;
		}

		public void ShowGameInfo()
		{
			this.m_ShowIntoPool.FakeReturnAll();
			int num = 0;
			while ((long)num < (long)((ulong)XBattleCaptainPVPDocument.GAME_INFO))
			{
				GameObject gameObject = this.m_ShowIntoPool.FetchGameObject(false);
				bool flag = this._doc.qInfo.Count <= num;
				if (flag)
				{
					gameObject.transform.localPosition = this.NoVisible;
				}
				else
				{
					gameObject.transform.localPosition = this.infoDis * (float)num;
					int num2 = 0;
					foreach (XBattleCaptainPVPDocument.KillInfo killInfo in this._doc.qInfo)
					{
						bool flag2 = num2 == num;
						if (flag2)
						{
							this.m_Killer[num].SetText(killInfo.KillName);
							this.m_Dead[num].SetText(killInfo.DeadName);
							bool isDoodad = killInfo.IsDoodad;
							if (isDoodad)
							{
								this.m_InfoIcon[num].SetSprite("hall_zljt_0");
							}
							else
							{
								this.m_InfoIcon[num].SetSprite("klj");
							}
							break;
						}
						num2++;
					}
				}
				num++;
			}
			this.m_ShowIntoPool.ActualReturnAll(false);
		}

		public void ShowConKill(int count)
		{
			bool flag = count <= 1;
			if (flag)
			{
				this.m_KillText.SetAlpha(0f);
			}
			else
			{
				this.m_KillText.SetAlpha(1f);
				string arg = (count >= 9) ? "9" : count.ToString();
				this.m_KillText.SetSprite(string.Format("{0}{1}", "kill", arg));
				this.m_KillText.MakePixelPerfect();
			}
			bool flag2 = count > 0;
			if (flag2)
			{
				int param = (count >= 5) ? 5 : count;
				this.PlayAudio(param);
			}
			bool flag3 = (long)count >= (long)((ulong)XBattleCaptainPVPDocument.CONTINUOUS_KILL);
			if (flag3)
			{
				count = (int)XBattleCaptainPVPDocument.CONTINUOUS_KILL;
			}
			int num = 1;
			while ((long)num <= (long)((ulong)XBattleCaptainPVPDocument.CONTINUOUS_KILL))
			{
				bool flag4 = num <= count;
				if (flag4)
				{
					this.m_Killicon[num].gameObject.transform.localPosition = new Vector3((float)(((double)((float)(num - 1) + 0.5f) - (double)count / 2.0) * (double)XBattleCaptainPVPDocument.ConKillIconDis), 0f, 0f);
					this.m_Killicon[num].PlayTween(true, -1f);
				}
				else
				{
					this.m_Killicon[num].gameObject.transform.localPosition = this.NoVisible;
				}
				num++;
			}
		}

		public void PlayAudio(int param)
		{
			XSingleton<XAudioMgr>.singleton.PlayUISound(string.Format("Audio/VO/System/system{0}", param), true, AudioChannel.Action);
		}

		public void ShowReviveTime(float time, bool isClose)
		{
			bool flag = isClose && this.m_Relive.gameObject.activeSelf;
			if (flag)
			{
				this.m_Relive.PlayTween(true, -1f);
			}
			bool flag2 = time < 0f;
			if (flag2)
			{
				time = 0f;
			}
			int num = (int)time;
			this.m_ReliveTime.SetText(num.ToString());
		}

		public void ShowEndTime(float time, bool isClose, bool isEndAll)
		{
			bool flag = isClose && this.m_End.gameObject.activeSelf;
			if (flag)
			{
				if (isEndAll)
				{
					this.m_End.RegisterOnFinishEventHandler(new OnTweenFinishEventHandler(this.OnEndMoveOver));
				}
				else
				{
					this.m_End.RegisterOnFinishEventHandler(null);
				}
				this.m_End.PlayTween(true, -1f);
			}
			bool flag2 = time < 0f;
			if (flag2)
			{
				time = 0f;
			}
			int num = (int)time;
			bool playedBigResult = this._doc.playedBigResult;
			if (playedBigResult)
			{
				this.m_AllEndTime.Alpha = 1f;
				this.m_RoundEndTime.Alpha = 0f;
				this.m_AllEndTime.SetText(string.Format(XStringDefineProxy.GetString("CAPTAIN_END"), num.ToString()));
			}
			else
			{
				this.m_AllEndTime.Alpha = 0f;
				this.m_RoundEndTime.Alpha = 1f;
				this.m_RoundEndTime.SetText(string.Format(XStringDefineProxy.GetString("CAPTAIN_ROUND"), num.ToString()));
			}
		}

		private void OnEndMoveOver(IXUITweenTool tween)
		{
			this._doc.PlayBigResult();
		}

		public void ShowSorce(bool isMyWin)
		{
			if (isMyWin)
			{
				int num = int.Parse(this.m_Blue.GetText());
				this.m_Blue.SetText((num + 1).ToString());
			}
			else
			{
				int num2 = int.Parse(this.m_Red.GetText());
				this.m_Red.SetText((num2 + 1).ToString());
			}
		}

		public void ShowLeaderHpName(ulong blueLeader, ulong redLeader)
		{
			this.BlueLeader = blueLeader;
			this.RedLeader = redLeader;
			bool flag = blueLeader == 0UL;
			if (flag)
			{
				this.m_BlueLeaderName.SetText("");
			}
			else
			{
				XBattleCaptainPVPDocument.RoleData roleInfo = this._doc.GetRoleInfo(blueLeader);
				bool flag2 = roleInfo.roleID > 0UL;
				if (flag2)
				{
					this.m_BlueLeaderName.SetText(roleInfo.Name);
				}
				else
				{
					this.m_BlueLeaderName.SetText("");
				}
			}
			bool flag3 = redLeader == 0UL;
			if (flag3)
			{
				this.m_RedLeaderName.SetText("");
			}
			else
			{
				XBattleCaptainPVPDocument.RoleData roleInfo = this._doc.GetRoleInfo(redLeader);
				bool flag4 = roleInfo.roleID > 0UL;
				if (flag4)
				{
					this.m_RedLeaderName.SetText(roleInfo.Name);
				}
				else
				{
					this.m_RedLeaderName.SetText("");
				}
			}
		}

		public void RefreshLeaderHp()
		{
			bool isEnd = this._doc.isEnd;
			if (isEnd)
			{
				this.BlueLeader = 0UL;
				this.RedLeader = 0UL;
			}
			bool flag = this.BlueLeader == 0UL && this.RedLeader == 0UL;
			if (!flag)
			{
				XEntity entity = XSingleton<XEntityMgr>.singleton.GetEntity(this.BlueLeader);
				bool flag2 = entity != null;
				if (flag2)
				{
					double attr = entity.Attributes.GetAttr(XAttributeDefine.XAttr_CurrentHP_Total);
					double attr2 = entity.Attributes.GetAttr(XAttributeDefine.XAttr_MaxHP_Total);
					double num = attr / attr2;
					this.m_BlueHpPer.SetText(string.Format("{0}%", Math.Ceiling(num * 100.0).ToString()));
					this.m_BlueHpBar.value = (float)num;
				}
				else
				{
					this.m_BlueHpPer.SetText("");
					this.m_BlueHpBar.value = 0f;
				}
				entity = XSingleton<XEntityMgr>.singleton.GetEntity(this.RedLeader);
				bool flag3 = entity != null;
				if (flag3)
				{
					double attr = entity.Attributes.GetAttr(XAttributeDefine.XAttr_CurrentHP_Total);
					double attr2 = entity.Attributes.GetAttr(XAttributeDefine.XAttr_MaxHP_Total);
					double num = attr / attr2;
					this.m_RedHpPer.SetText(string.Format("{0}%", Math.Ceiling(num * 100.0).ToString()));
					this.m_RedHpBar.value = (float)num;
				}
				else
				{
					this.m_RedHpPer.SetText("");
					this.m_RedHpBar.value = 0f;
				}
			}
		}

		public void ShowStart()
		{
			this._StratTimerID = XSingleton<XTimerMgr>.singleton.SetTimer(1f, new XTimerMgr.ElapsedEventHandler(this._ShowStart), null);
		}

		private void _ShowStart(object param)
		{
			bool flag = base.IsVisible();
			if (flag)
			{
				this.m_Start.PlayTween(true, -1f);
			}
		}

		private void AutoRefresh(object param)
		{
			bool flag = base.IsVisible();
			if (flag)
			{
				this._doc.ReqBattleCaptainPVPRefreshInfo(false);
				this._RefreshDataTimerID = XSingleton<XTimerMgr>.singleton.SetTimer(5f, new XTimerMgr.ElapsedEventHandler(this.AutoRefresh), null);
			}
		}

		public void StartAutoRefresh(object param)
		{
			bool flag = base.IsVisible() && this._RefreshDataTimerID == 0u;
			if (flag)
			{
				this._RefreshDataTimerID = XSingleton<XTimerMgr>.singleton.SetTimer(3f, new XTimerMgr.ElapsedEventHandler(this.AutoRefresh), null);
			}
		}
	}
}