summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/UI/DramaDlg.cs
blob: cd5b318d97fd339c02caee9e210990e9cdce67c0 (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
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
using System;
using System.Collections.Generic;
using KKSG;
using UILib;
using UnityEngine;
using XMainClient.UI.UICommon;
using XUtliPoolLib;

namespace XMainClient.UI
{
	internal class DramaDlg : DlgBase<DramaDlg, DramaDlgBehaviour>
	{
		public override string fileName
		{
			get
			{
				return "Hall/DramaDlg";
			}
		}

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

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

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

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

		public XNpc m_npc;

		protected XNpcAttributes m_npcAttr;

		public Queue<XDialogSentence> m_DialogQueue = new Queue<XDialogSentence>();

		private XDummy m_npcDummy;

		private XTaskDocument taskDoc;

		private XTaskInfo m_RelativeTask;

		private uint m_RelativeTaskID;

		private XDramaDocument doc;

		private XNPCFavorDramaSend sendHandler = null;

		private XNPCFavorDramaExchange exchangeHandler = null;

		protected override void Init()
		{
			this._TogglePage(DramaPage.DP_MAX);
			this.taskDoc = XDocuments.GetSpecificDocument<XTaskDocument>(XTaskDocument.uuID);
			this.doc = XDocuments.GetSpecificDocument<XDramaDocument>(XDramaDocument.uuID);
			DlgHandlerBase.EnsureCreate<XNPCFavorDramaSend>(ref this.sendHandler, base.uiBehaviour.m_FavorFrame, false, this);
			DlgHandlerBase.EnsureCreate<XNPCFavorDramaExchange>(ref this.exchangeHandler, base.uiBehaviour.m_FavorFrame, false, this);
		}

		public override void RegisterEvent()
		{
			IXUISprite ixuisprite = base.uiBehaviour.m_TaskArea.GetComponent("XUISprite") as IXUISprite;
			ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.GotoNextTalk));
			ixuisprite = (base.uiBehaviour.m_OperateArea.GetComponent("XUISprite") as IXUISprite);
			ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this._OnCloseClicked));
			ixuisprite = (base.uiBehaviour.m_FavorGB.GetComponent("XUISprite") as IXUISprite);
			ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this._OnCloseClicked));
			base.uiBehaviour.m_RewardBg.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnRewardClick));
			base.uiBehaviour.m_FuncArea.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnNormalFuncClick));
			base.uiBehaviour.m_BtnAccept.RegisterClickEventHandler(new ButtonClickEventHandler(this._OnBtnAcceptTaskClicked));
			base.uiBehaviour.m_BtnReject.RegisterClickEventHandler(new ButtonClickEventHandler(this._OnBtnRejectTaskClicked));
		}

		protected void OnNormalFuncClick(IXUISprite sp)
		{
			bool flag = !base.IsLoaded();
			if (!flag)
			{
				bool flag2 = this.m_npc != null && !this.m_npc.Deprecated;
				if (flag2)
				{
					XNpcInfo.RowData byNPCID = XSingleton<XEntityMgr>.singleton.NpcInfo.GetByNPCID(this.m_npc.TypeID);
					bool flag3 = byNPCID != null && byNPCID.NPCType == 3u;
					if (flag3)
					{
						HomePlantDocument.Doc.HomeSprite.SetNextStepOperation();
					}
					bool flag4 = byNPCID != null && byNPCID.NPCType == 4u;
					if (flag4)
					{
						XGuildCollectDocument specificDocument = XDocuments.GetSpecificDocument<XGuildCollectDocument>(XGuildCollectDocument.uuID);
						specificDocument.OnMeetNpc(this.m_npc.TypeID);
					}
				}
				this.SetVisible(false, true);
			}
		}

		protected override void OnShow()
		{
			base.OnShow();
			base.Alloc3DAvatarPool("DramaDlg");
			this.m_npc = null;
			this.m_npcAttr = null;
			this._TogglePage(DramaPage.DP_MAX);
			XSingleton<XGameUI>.singleton.HpbarRoot.gameObject.SetActive(false);
			XSingleton<XGameUI>.singleton.NpcHpbarRoot.gameObject.SetActive(false);
			XSingleton<XPostEffectMgr>.singleton.MakeEffectEnable(XPostEffect.GausBlur, false);
			XSingleton<XAudioMgr>.singleton.StopUISound();
		}

		protected override void OnHide()
		{
			this.doc.OnUIClose();
			this.m_RelativeTask = null;
			XSingleton<X3DAvatarMgr>.singleton.EnableMainDummy(false, null);
			bool flag = base.uiBehaviour.m_leftSnapshot != null;
			if (flag)
			{
				base.uiBehaviour.m_rightSnapshot.RefreshRenderQueue = null;
			}
			bool flag2 = base.uiBehaviour.m_leftSnapshot != null;
			if (flag2)
			{
				base.uiBehaviour.m_leftSnapshot.RefreshRenderQueue = null;
			}
			base.Return3DAvatarPool();
			this.m_npcDummy = null;
			XCameraCloseUpEndEventArgs @event = XEventPool<XCameraCloseUpEndEventArgs>.GetEvent();
			@event.Firer = XSingleton<XScene>.singleton.GameCamera;
			XSingleton<XEventMgr>.singleton.FireEvent(@event);
			DlgBase<XMainInterface, XMainInterfaceBehaviour>.singleton.DramaDlgCloseTime = Time.time;
			XSingleton<XGameUI>.singleton.HpbarRoot.gameObject.SetActive(true);
			XSingleton<XGameUI>.singleton.NpcHpbarRoot.gameObject.SetActive(true);
			bool flag3 = this.sendHandler != null;
			if (flag3)
			{
				this.sendHandler.SetVisible(false);
			}
			bool flag4 = this.exchangeHandler != null;
			if (flag4)
			{
				this.exchangeHandler.SetVisible(false);
			}
			XNPCFavorDocument specificDocument = XDocuments.GetSpecificDocument<XNPCFavorDocument>(XNPCFavorDocument.uuID);
			DlgBase<XMainInterface, XMainInterfaceBehaviour>.singleton.SetSystemRedPointState(XSysDefine.XSys_NPCFavor, specificDocument.IsNeedShowRedpoint);
			base.OnHide();
		}

		protected override void OnUnload()
		{
			DlgHandlerBase.EnsureUnload<XNPCFavorDramaSend>(ref this.sendHandler);
			DlgHandlerBase.EnsureUnload<XNPCFavorDramaExchange>(ref this.exchangeHandler);
			base.Return3DAvatarPool();
			this.doc.OnUIClose();
			base.OnUnload();
		}

		public override void OnUpdate()
		{
			base.OnUpdate();
			for (int i = 0; i < base.uiBehaviour.MAX_OPERATE_BTN_COUNT; i++)
			{
				base.uiBehaviour.m_OperateBtns[i].Update();
			}
			for (int j = 0; j < base.uiBehaviour.MAX_OPERATE_LIST_COUNT; j++)
			{
				base.uiBehaviour.m_OperateLists[j].Update();
			}
		}

		private void _TogglePage(DramaPage page)
		{
			base.uiBehaviour.m_TaskArea.gameObject.SetActive(page == DramaPage.DP_DIALOG || page == DramaPage.DP_ACCEPT);
			base.uiBehaviour.m_RewardArea.gameObject.SetActive(page == DramaPage.DP_REWARD);
			base.uiBehaviour.m_FuncArea.gameObject.SetActive(page == DramaPage.DP_FUNC);
			base.uiBehaviour.m_TaskAcceptArea.SetActive(page == DramaPage.DP_ACCEPT);
			base.uiBehaviour.m_OperateArea.SetActive(page == DramaPage.DP_OPERATE);
			base.uiBehaviour.m_FavorGB.SetActive(page == DramaPage.DP_FAVOR);
		}

		public void ShowNpcDialog(XNpc npc)
		{
			bool flag = !XEntity.ValideEntity(npc);
			if (!flag)
			{
				XSingleton<XGameUI>.singleton.OnGenericClick();
				bool flag2 = XSingleton<XChatIFlyMgr>.singleton.IsRecording();
				if (flag2)
				{
					XCameraCloseUpEndEventArgs @event = XEventPool<XCameraCloseUpEndEventArgs>.GetEvent();
					@event.Firer = XSingleton<XScene>.singleton.GameCamera;
					XSingleton<XEventMgr>.singleton.FireEvent(@event);
				}
				else
				{
					this.SetVisible(true, true);
					this.m_npc = npc;
					this.m_npcAttr = (npc.Attributes as XNpcAttributes);
					bool flag3 = this.m_npcAttr == null;
					if (flag3)
					{
						this.SetVisible(false, true);
					}
					else
					{
						this.SetupTalkerName(this.m_npcAttr.Name);
						npc.ShowUp(null);
						NpcTaskState npcTaskState = this.taskDoc.GetNpcTaskState(npc.TypeID, ref this.m_RelativeTask);
						bool flag4 = this.m_RelativeTask != null;
						if (flag4)
						{
							this.m_RelativeTaskID = this.m_RelativeTask.ID;
						}
						else
						{
							this.m_RelativeTaskID = 0u;
						}
						bool flag5 = npcTaskState == NpcTaskState.Normal || npc.NPCType == 3u;
						if (flag5)
						{
							int index = this.PlayNpcVoice();
							this.SetupNpcNormalDialog(index, npc.NPCType);
						}
						else
						{
							this.m_DialogQueue.Clear();
							XTaskDialog curDialog = this.m_RelativeTask.CurDialog;
							for (int i = 0; i < curDialog.Dialog.Count; i++)
							{
								this.m_DialogQueue.Enqueue(curDialog.Dialog[i]);
							}
							this.SetupNpcTaskDialog();
						}
					}
				}
			}
		}

		protected void OnRewardClick(IXUISprite sp)
		{
			bool flag = !base.IsLoaded();
			if (!flag)
			{
				XTaskInfo xtaskInfo = null;
				NpcTaskState npcTaskState = this.taskDoc.GetNpcTaskState(this.m_npc.TypeID, ref xtaskInfo);
				bool flag2 = npcTaskState == NpcTaskState.TaskEnd;
				if (flag2)
				{
					RpcC2G_TaskOperate rpcC2G_TaskOperate = new RpcC2G_TaskOperate();
					rpcC2G_TaskOperate.oArg.taskID = (int)xtaskInfo.ID;
					rpcC2G_TaskOperate.oArg.taskOP = 2;
					XSingleton<XClientNetwork>.singleton.Send(rpcC2G_TaskOperate);
					XSingleton<XOperationRecord>.singleton.DoScriptRecord("finishtask+" + xtaskInfo.ID);
					DlgBase<DramaDlg, DramaDlgBehaviour>.singleton.SetVisible(false, true);
				}
			}
		}

		protected void _PlayVoice(string voice, bool isNPC)
		{
			if (isNPC)
			{
				bool flag = XSingleton<XEntityMgr>.singleton.Player != null && XSingleton<XAudioMgr>.singleton.IsPlayingSound(XSingleton<XEntityMgr>.singleton.Player, AudioChannel.Motion);
				if (flag)
				{
					XSingleton<XAudioMgr>.singleton.StopSound(XSingleton<XEntityMgr>.singleton.Player, AudioChannel.Motion);
				}
				bool flag2 = this.m_npc != null && !string.IsNullOrEmpty(voice);
				if (flag2)
				{
					XSingleton<XAudioMgr>.singleton.PlaySound(this.m_npc, AudioChannel.Motion, voice);
				}
			}
			else
			{
				bool flag3 = this.m_npc != null && XSingleton<XAudioMgr>.singleton.IsPlayingSound(this.m_npc, AudioChannel.Motion);
				if (flag3)
				{
					XSingleton<XAudioMgr>.singleton.StopSound(this.m_npc, AudioChannel.Motion);
				}
				bool flag4 = XSingleton<XEntityMgr>.singleton.Player != null && !string.IsNullOrEmpty(voice);
				if (flag4)
				{
					XSingleton<XAudioMgr>.singleton.PlaySound(XSingleton<XEntityMgr>.singleton.Player, AudioChannel.Motion, voice);
				}
			}
		}

		public void StopVoice()
		{
			bool flag = XSingleton<XEntityMgr>.singleton.Player != null && XSingleton<XAudioMgr>.singleton.IsPlayingSound(XSingleton<XEntityMgr>.singleton.Player, AudioChannel.Motion);
			if (flag)
			{
				XSingleton<XAudioMgr>.singleton.StopSound(XSingleton<XEntityMgr>.singleton.Player, AudioChannel.Motion);
			}
			bool flag2 = this.m_npc != null && XSingleton<XAudioMgr>.singleton.IsPlayingSound(this.m_npc, AudioChannel.Motion);
			if (flag2)
			{
				XSingleton<XAudioMgr>.singleton.StopSound(this.m_npc, AudioChannel.Motion);
			}
		}

		protected void GotoNextTalk(IXUISprite sp)
		{
			bool flag = !base.IsLoaded();
			if (!flag)
			{
				bool activeSelf = base.uiBehaviour.m_TaskAcceptArea.activeSelf;
				if (!activeSelf)
				{
					bool flag2 = this.m_DialogQueue.Count > 0;
					if (flag2)
					{
						XDialogSentence xdialogSentence = this.m_DialogQueue.Dequeue();
						bool flag3 = xdialogSentence.bCanReject && this.m_RelativeTask.Status == TaskStatus.TaskStatus_CanTake;
						if (flag3)
						{
							this._TogglePage(DramaPage.DP_ACCEPT);
							this.ShowTaskAccept(ref xdialogSentence);
						}
						else
						{
							this._TogglePage(DramaPage.DP_DIALOG);
						}
						bool flag4 = xdialogSentence.Talker == 1;
						if (flag4)
						{
							this.SetupNpcText(this.m_npc, XSingleton<UiUtility>.singleton.ReplaceReturn(xdialogSentence.Content));
							this._PlayVoice(xdialogSentence.Voice, true);
						}
						else
						{
							this.SetupPlayerText(XSingleton<UiUtility>.singleton.ReplaceReturn(xdialogSentence.Content));
							this._PlayVoice(xdialogSentence.Voice, false);
						}
					}
					else
					{
						this.SetupNpcText(this.m_npc, "");
						NpcTaskState npcTaskState = NpcTaskState.Normal;
						this.m_RelativeTask = this.taskDoc.GetTaskInfo(this.m_RelativeTaskID);
						bool flag5 = this.m_RelativeTask != null;
						if (flag5)
						{
							npcTaskState = this.m_RelativeTask.NpcState;
						}
						bool flag6 = npcTaskState == NpcTaskState.TaskBegin;
						if (flag6)
						{
							RpcC2G_TaskOperate rpcC2G_TaskOperate = new RpcC2G_TaskOperate();
							rpcC2G_TaskOperate.oArg.taskID = (int)this.m_RelativeTask.ID;
							rpcC2G_TaskOperate.oArg.taskOP = 1;
							XSingleton<XClientNetwork>.singleton.Send(rpcC2G_TaskOperate);
							XSingleton<XOperationRecord>.singleton.DoScriptRecord("accepttask+" + this.m_RelativeTask.ID);
							bool flag7 = !this.CanAutoContinue(this.m_RelativeTask);
							if (flag7)
							{
								this.SetVisible(false, true);
							}
						}
						else
						{
							bool flag8 = npcTaskState == NpcTaskState.TaskEnd;
							if (flag8)
							{
								this.ShowTaskReward(this.m_RelativeTask.ID);
							}
							else
							{
								this.SetVisible(false, true);
							}
						}
					}
				}
			}
		}

		public bool CanAutoContinue(XTaskInfo taskInfo)
		{
			return (taskInfo != null & taskInfo.Conds.Count == 0) && XSingleton<UiUtility>.singleton.ChooseProfData<uint>(taskInfo.TableData.BeginTaskNPCID, 0u) == XSingleton<UiUtility>.singleton.ChooseProfData<uint>(taskInfo.TableData.EndTaskNPCID, 0u);
		}

		protected void ShowTaskAccept(ref XDialogSentence dialog)
		{
			bool flag = this.m_RelativeTask == null || this.m_RelativeTask.TableData == null;
			if (!flag)
			{
				this._TogglePage(DramaPage.DP_ACCEPT);
				TaskTableNew.RowData tableData = this.m_RelativeTask.TableData;
				bool flag2 = tableData.RewardItem.Count > 0;
				if (flag2)
				{
					base.uiBehaviour.m_AcceptItemBg.SetActive(true);
					base.uiBehaviour.m_AcceptItemPool.FakeReturnAll();
					for (int i = 0; i < tableData.RewardItem.Count; i++)
					{
						GameObject gameObject = base.uiBehaviour.m_AcceptItemPool.FetchGameObject(false);
						gameObject.transform.localPosition = new Vector3(base.uiBehaviour.m_AcceptItemPool.TplPos.x + (float)(i * base.uiBehaviour.m_AcceptItemPool.TplWidth), base.uiBehaviour.m_AcceptItemPool.TplPos.y, base.uiBehaviour.m_AcceptItemPool.TplPos.z);
						XSingleton<XItemDrawerMgr>.singleton.normalItemDrawer.DrawItem(gameObject, (int)tableData.RewardItem[i, 0], (int)tableData.RewardItem[i, 1], false);
					}
					base.uiBehaviour.m_AcceptItemPool.ActualReturnAll(false);
				}
				else
				{
					base.uiBehaviour.m_AcceptItemBg.SetActive(false);
				}
			}
		}

		protected void ShowTaskReward(uint taskID)
		{
			TaskTableNew.RowData taskData = XTaskDocument.GetTaskData(taskID);
			base.uiBehaviour.m_RewardGold.SetText("0");
			base.uiBehaviour.m_RewardExp.SetText("0");
			bool flag = taskData != null;
			if (flag)
			{
				this._TogglePage(DramaPage.DP_REWARD);
				bool flag2 = taskData.RewardItem.Count > 0;
				if (flag2)
				{
					base.uiBehaviour.m_RewardItemBg.gameObject.SetActive(true);
					Vector3 localPosition = base.uiBehaviour.m_RewardItemPool._tpl.transform.localPosition;
					float num = (float)(base.uiBehaviour.m_RewardItemPool.TplWidth + 5);
					base.uiBehaviour.m_RewardItemPool.ReturnAll(false);
					int i = 0;
					int num2 = 0;
					while (i < taskData.RewardItem.Count)
					{
						int num3 = (int)taskData.RewardItem[i, 0];
						int itemCount = (int)taskData.RewardItem[i, 1];
						bool flag3 = num3 == 1;
						if (flag3)
						{
							base.uiBehaviour.m_RewardGold.SetText(itemCount.ToString());
						}
						else
						{
							bool flag4 = num3 == 4;
							if (flag4)
							{
								base.uiBehaviour.m_RewardExp.SetText(itemCount.ToString());
							}
							else
							{
								GameObject gameObject = base.uiBehaviour.m_RewardItemPool.FetchGameObject(false);
								gameObject.transform.localPosition = localPosition + new Vector3((float)num2 * num, 0f, 0f);
								num2++;
								XSingleton<XItemDrawerMgr>.singleton.normalItemDrawer.DrawItem(gameObject, num3, itemCount, false);
								XSingleton<XItemDrawerMgr>.singleton.normalItemDrawer.OpenClickShowTooltipEvent(gameObject, num3);
							}
						}
						i++;
					}
				}
				else
				{
					base.uiBehaviour.m_RewardItemBg.gameObject.SetActive(false);
				}
			}
		}

		protected void SetupNpcTaskDialog()
		{
			bool flag = this.m_DialogQueue.Count > 0;
			if (flag)
			{
				this.GotoNextTalk(null);
			}
		}

		protected void SetupNPCAvatar(uint presentID, bool playtween)
		{
			base.uiBehaviour.m_rightSnapshot.transform.localPosition = base.uiBehaviour.m_rightDummyPos;
			base.uiBehaviour.m_leftSnapshot.transform.localPosition = XGameUI.Far_Far_Away;
			this.m_npcDummy = XSingleton<X3DAvatarMgr>.singleton.CreateCommonEntityDummy(this.m_dummPool, presentID, base.uiBehaviour.m_rightSnapshot, this.m_npcDummy, 1f);
			XEntityPresentation.RowData byPresentID = XSingleton<XEntityMgr>.singleton.EntityInfo.GetByPresentID(presentID);
			bool flag = byPresentID != null && byPresentID.AvatarPos != null;
			if (flag)
			{
				int num = XSingleton<XCommon>.singleton.RandomInt(0, byPresentID.AvatarPos.Length);
				this.m_npcDummy.SetAnimation(byPresentID.AvatarPos[num]);
			}
		}

		protected void SetupTalkerName(string name)
		{
			base.uiBehaviour.m_name.SetText(name);
		}

		protected void SetupNpcNormalDialog(int index, uint npcType)
		{
			this._TogglePage(DramaPage.DP_FUNC);
			bool flag = npcType == 3u;
			if (flag)
			{
				HomePlantDocument homePlantDocument = HomePlantDocument.Doc;
				base.uiBehaviour.m_FuncText.SetText(homePlantDocument.HomeSprite.GetDialogue());
				this.SetupNPCAvatar(this.m_npcAttr.PresentID, true);
			}
			else
			{
				index = ((this.m_npcAttr.Content != null && index >= this.m_npcAttr.Content.Length) ? 0 : index);
				base.uiBehaviour.m_FuncText.SetText(this.m_npcAttr.Content[index]);
				this.SetupNPCAvatar(this.m_npcAttr.PresentID, true);
				Vector3 localPosition = base.uiBehaviour.m_FuncPool._tpl.transform.localPosition;
				float num = (float)(base.uiBehaviour.m_FuncPool.TplHeight + 2);
				base.uiBehaviour.m_FuncPool.ReturnAll(false);
				bool flag2 = this.m_npcAttr.Content != null && this.m_npcAttr.FunctionList != null;
				if (flag2)
				{
					for (int i = 0; i < this.m_npcAttr.FunctionList.Length; i++)
					{
						GameObject gameObject = base.uiBehaviour.m_FuncPool.FetchGameObject(false);
						gameObject.transform.localPosition = localPosition + new Vector3(0f, (float)(-(float)i) * num);
						IXUILabel ixuilabel = gameObject.GetComponent("XUILabel") as IXUILabel;
						ixuilabel.SetText(XSingleton<XGameSysMgr>.singleton.GetSysName(this.m_npcAttr.FunctionList[i]));
						ixuilabel.ID = (ulong)((long)this.m_npcAttr.FunctionList[i]);
					}
				}
				bool flag3 = this.m_npcAttr.FunctionList == null || this.m_npcAttr.FunctionList.Length == 0;
				if (flag3)
				{
					base.uiBehaviour.m_FuncTplBg.gameObject.SetActive(false);
				}
				else
				{
					base.uiBehaviour.m_FuncTplBg.gameObject.SetActive(true);
				}
			}
		}

		protected int PlayNpcVoice()
		{
			bool flag = this.m_npcAttr.Voice == null || this.m_npcAttr.Voice.Length == 0;
			int result;
			if (flag)
			{
				result = 0;
			}
			else
			{
				bool flag2 = !XSingleton<XAudioMgr>.singleton.IsPlayingSound(this.m_npc, AudioChannel.Motion);
				if (flag2)
				{
					int num = XSingleton<XCommon>.singleton.RandomInt(0, this.m_npcAttr.Voice.Length);
					XSingleton<XAudioMgr>.singleton.PlaySound(this.m_npc, AudioChannel.Motion, this.m_npcAttr.Voice[num]);
					result = num;
				}
				else
				{
					result = 0;
				}
			}
			return result;
		}

		protected void SetupNpcText(XNpc npc, string text)
		{
			base.uiBehaviour.m_NpcText.gameObject.SetActive(true);
			base.uiBehaviour.m_PlayerText.gameObject.SetActive(false);
			base.uiBehaviour.m_name.gameObject.transform.parent.gameObject.SetActive(true);
			this.SetupNPCAvatar(this.m_npcAttr.PresentID, false);
			base.uiBehaviour.m_NpcText.SetText(text);
		}

		protected void SetupPlayerText(string text)
		{
			base.uiBehaviour.m_NpcText.gameObject.SetActive(false);
			base.uiBehaviour.m_PlayerText.gameObject.SetActive(true);
			base.uiBehaviour.m_name.gameObject.transform.parent.gameObject.SetActive(false);
			base.uiBehaviour.m_PlayerText.SetText(text);
			base.uiBehaviour.m_rightSnapshot.transform.localPosition = XGameUI.Far_Far_Away;
			base.uiBehaviour.m_leftSnapshot.transform.localPosition = base.uiBehaviour.m_leftDummyPos;
			XSingleton<X3DAvatarMgr>.singleton.EnableMainDummy(true, base.uiBehaviour.m_leftSnapshot);
			XEntityPresentation.RowData byPresentID = XSingleton<XEntityMgr>.singleton.EntityInfo.GetByPresentID(XSingleton<XAttributeMgr>.singleton.XPlayerData.PresentID);
			bool flag = byPresentID != null && byPresentID.AvatarPos != null;
			if (flag)
			{
				int num = XSingleton<XCommon>.singleton.RandomInt(0, byPresentID.AvatarPos.Length);
				XSingleton<X3DAvatarMgr>.singleton.SetMainAnimation(byPresentID.AvatarPos[num]);
			}
		}

		private bool _OnBtnAcceptTaskClicked(IXUIButton btn)
		{
			bool flag = !base.IsLoaded();
			bool result;
			if (flag)
			{
				result = true;
			}
			else
			{
				bool flag2 = this.m_RelativeTask == null;
				if (flag2)
				{
					result = true;
				}
				else
				{
					RpcC2G_TaskOperate rpcC2G_TaskOperate = new RpcC2G_TaskOperate();
					rpcC2G_TaskOperate.oArg.taskID = (int)this.m_RelativeTask.ID;
					rpcC2G_TaskOperate.oArg.taskOP = 1;
					XSingleton<XClientNetwork>.singleton.Send(rpcC2G_TaskOperate);
					XSingleton<XOperationRecord>.singleton.DoScriptRecord("accepttask+" + this.m_RelativeTask.ID);
					this.SetVisible(false, true);
					result = true;
				}
			}
			return result;
		}

		private bool _OnBtnRejectTaskClicked(IXUIButton btn)
		{
			bool flag = !base.IsLoaded();
			bool result;
			if (flag)
			{
				result = true;
			}
			else
			{
				this.SetVisible(false, true);
				result = true;
			}
			return result;
		}

		private void _OnCloseClicked(IXUISprite iSp)
		{
			bool flag = !base.IsLoaded();
			if (!flag)
			{
				bool bBlockClose = this.doc.bBlockClose;
				if (!bBlockClose)
				{
					this.SetVisible(false, true);
				}
			}
		}

		public void SetupOperate(XDramaOperateParam param)
		{
			bool flag = !base.IsLoaded();
			if (!flag)
			{
				this._TogglePage(DramaPage.DP_OPERATE);
				bool flag2 = param.Npc != null;
				if (flag2)
				{
					this.m_npc = param.Npc;
					this.m_npcAttr = (this.m_npc.Attributes as XNpcAttributes);
					this.SetupTalkerName(this.m_npcAttr.Name);
					this.m_npc.ShowUp(null);
					this.SetupNPCAvatar(this.m_npcAttr.PresentID, true);
				}
				bool flag3 = param.Text != null;
				if (flag3)
				{
					base.uiBehaviour.m_OperateText.SetText(param.Text);
				}
				bool flag4 = param.ButtonCount > 0;
				if (flag4)
				{
					base.uiBehaviour.m_OperateBtnPanel.SetActive(true);
					int i = 0;
					while (i < param.ButtonCount && i < base.uiBehaviour.MAX_OPERATE_BTN_COUNT)
					{
						XDramaOperateButton xdramaOperateButton = param.Buttons[i];
						DramaDlgBehaviour.OperateButton operateButton = base.uiBehaviour.m_OperateBtns[i];
						operateButton.SetActive(true);
						operateButton.SetButton(xdramaOperateButton.Name, xdramaOperateButton.RID, xdramaOperateButton.ClickEvent, xdramaOperateButton.StateEnable);
						operateButton.SetLeftTime(xdramaOperateButton.TargetTime - Time.realtimeSinceStartup, xdramaOperateButton.TimeNote);
						i++;
					}
					while (i < base.uiBehaviour.MAX_OPERATE_BTN_COUNT)
					{
						base.uiBehaviour.m_OperateBtns[i].SetActive(false);
						i++;
					}
				}
				else
				{
					base.uiBehaviour.m_OperateBtnPanel.SetActive(false);
				}
				bool flag5 = param.ListCount > 0;
				if (flag5)
				{
					base.uiBehaviour.m_OperateListPanel.SetActive(true);
					int j = 0;
					while (j < param.ListCount && j < base.uiBehaviour.MAX_OPERATE_LIST_COUNT)
					{
						XDramaOperateList xdramaOperateList = param.Lists[j];
						DramaDlgBehaviour.OperateList operateList = base.uiBehaviour.m_OperateLists[j];
						operateList.SetActive(true);
						SpriteClickEventHandler spriteClickEventHandler = new SpriteClickEventHandler(xdramaOperateList.ClickEvent.Invoke);
						spriteClickEventHandler = (SpriteClickEventHandler)Delegate.Combine(spriteClickEventHandler, new SpriteClickEventHandler(this._OnOperateListClicked));
						operateList.SetList(xdramaOperateList.Name, xdramaOperateList.RID, spriteClickEventHandler);
						operateList.SetLeftTime(xdramaOperateList.TargetTime - Time.realtimeSinceStartup, xdramaOperateList.TimeNote);
						this._ToggleOperateListSelection(j, false);
						j++;
					}
					while (j < base.uiBehaviour.MAX_OPERATE_LIST_COUNT)
					{
						base.uiBehaviour.m_OperateLists[j].SetActive(false);
						j++;
					}
				}
				else
				{
					base.uiBehaviour.m_OperateListPanel.SetActive(false);
				}
			}
		}

		private void _OnOperateListClicked(IXUISprite iSp)
		{
			bool flag = !base.IsLoaded();
			if (!flag)
			{
				this._SelectOperateList((int)iSp.ID);
			}
		}

		private void _ToggleOperateListSelection(int index, bool bSelect)
		{
			base.uiBehaviour.m_OperateLists[index].SetSelect(bSelect);
		}

		private void _SelectOperateList(int index)
		{
			for (int i = 0; i < base.uiBehaviour.MAX_OPERATE_LIST_COUNT; i++)
			{
				this._ToggleOperateListSelection(i, index == i);
			}
		}

		public void SetUpFavorParam(XFavorParam param)
		{
			bool flag = !base.IsLoaded();
			if (!flag)
			{
				this._TogglePage(DramaPage.DP_FAVOR);
				bool flag2 = param.Npc != null;
				if (flag2)
				{
					this.m_npc = param.Npc;
					this.m_npcAttr = (this.m_npc.Attributes as XNpcAttributes);
					this.SetupTalkerName(this.m_npcAttr.Name);
					this.m_npc.ShowUp(null);
					this.SetupNPCAvatar(this.m_npcAttr.PresentID, true);
				}
				bool flag3 = param.Text != null;
				if (flag3)
				{
					base.uiBehaviour.m_FavorText.SetText(param.Text);
				}
				base.uiBehaviour.m_SendBtn.gameObject.SetActive(param.isShowSend);
				base.uiBehaviour.m_SendBtn.RegisterClickEventHandler(param.sendCallback);
				base.uiBehaviour.m_ExchangeBtn.gameObject.SetActive(param.isShowExchange);
				base.uiBehaviour.m_ExchangeBtn.RegisterClickEventHandler(param.exchangeCallback);
				base.uiBehaviour.m_ExchangeRedPoint.SetActive(param.isShowExchangeRedpoint);
				base.uiBehaviour.m_FavorBtnList.Refresh();
			}
		}

		public void NtfSendDramaRefresh()
		{
			bool flag = this.sendHandler.IsVisible();
			if (flag)
			{
				this.sendHandler.RefreshData();
			}
		}

		public void NtfExchangeDramaRefresh()
		{
			bool flag = this.exchangeHandler.IsVisible();
			if (flag)
			{
				this.exchangeHandler.RefreshData();
			}
		}

		public void NtfExchangeDlgClose()
		{
			bool flag = this.exchangeHandler.IsVisible();
			if (flag)
			{
				this.exchangeHandler.SetVisible(false);
			}
		}

		public void ShowNPCFavorSend()
		{
			bool flag = this.exchangeHandler.IsVisible();
			if (flag)
			{
				this.exchangeHandler.SetVisible(false);
			}
			this.sendHandler.SetVisible(true);
		}

		public void ShowNPCFavorExchnage()
		{
			bool flag = this.sendHandler.IsVisible();
			if (flag)
			{
				this.sendHandler.SetVisible(false);
			}
			this.exchangeHandler.SetVisible(true);
		}

		public bool IsSendDilogVisible()
		{
			return this.sendHandler != null && this.sendHandler.IsVisible();
		}

		public bool IsChangeDialogVisible()
		{
			return this.exchangeHandler != null && this.exchangeHandler.IsVisible();
		}
	}
}