summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/UI/SuperRiskOnlineBoxHandler.cs
blob: ad829beaea4604881c5e5d0794a0ca3e31e0b1e1 (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
using System;
using UILib;
using XUtliPoolLib;

namespace XMainClient.UI
{
	internal class SuperRiskOnlineBoxHandler : DlgHandlerBase
	{
		private XSuperRiskDocument _doc;

		private IXUITweenTool m_BoxTween;

		private IXUIButton m_BuyBtn;

		private IXUIButton m_CancleBtn;

		private IXUILabel m_CostLab;

		private IXUISprite m_CostIcon;

		protected override void Init()
		{
			this._doc = XSuperRiskDocument.Doc;
			this.m_CancleBtn = (base.PanelObject.transform.Find("no").GetComponent("XUIButton") as IXUIButton);
			this.m_BuyBtn = (base.PanelObject.transform.Find("Buy").GetComponent("XUIButton") as IXUIButton);
			this.m_CostLab = (base.PanelObject.transform.Find("Buy/Cost").GetComponent("XUILabel") as IXUILabel);
			this.m_CostIcon = (base.PanelObject.transform.Find("Buy/Cost/b").GetComponent("XUISprite") as IXUISprite);
			this.m_BoxTween = (base.PanelObject.transform.Find("Box").GetComponent("XUIPlayTween") as IXUITweenTool);
		}

		public override void RegisterEvent()
		{
			this.m_CancleBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnCancleClick));
			this.m_BuyBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnBuyClick));
			base.RegisterEvent();
		}

		protected override void OnHide()
		{
			base.OnHide();
		}

		protected override void OnShow()
		{
			this.FillContent();
			base.OnShow();
		}

		private void FillContent()
		{
			bool flag = this._doc.OnlineBoxCost != null;
			if (flag)
			{
				this.m_CostLab.SetText(this._doc.OnlineBoxCost.itemCount.ToString());
				ItemList.RowData itemConf = XBagDocument.GetItemConf((int)this._doc.OnlineBoxCost.itemID);
				this.m_CostIcon.SetSprite(itemConf.ItemIcon1[0]);
			}
			XSingleton<XAudioMgr>.singleton.PlayUISound("Audio/UI/UI_Anim_DiceGame_OpenChest", true, AudioChannel.Action);
			this.m_BoxTween.SetTweenGroup(0);
			this.m_BoxTween.ResetTweenByGroup(true, 0);
			this.m_BoxTween.PlayTween(true, -1f);
		}

		private bool OnCancleClick(IXUIButton btn)
		{
			base.SetVisible(false);
			return true;
		}

		private bool OnBuyClick(IXUIButton btn)
		{
			bool flag = this._doc.OnlineBoxCost == null;
			bool result;
			if (flag)
			{
				result = true;
			}
			else
			{
				ulong itemCount = XBagDocument.BagDoc.GetItemCount((int)this._doc.OnlineBoxCost.itemID);
				bool flag2 = (ulong)this._doc.OnlineBoxCost.itemCount > itemCount;
				if (flag2)
				{
					XSingleton<UiUtility>.singleton.ShowItemAccess((int)this._doc.OnlineBoxCost.itemID, null);
					result = true;
				}
				else
				{
					this._doc.ReqBuyOnlineBox();
					result = true;
				}
			}
			return result;
		}
	}
}