summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/UI/XBuyCountView.cs
blob: 6bbac21123dc01303d89bc9975042e529a4dc008 (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
using System;
using KKSG;
using UILib;
using XMainClient.UI.UICommon;
using XUtliPoolLib;

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

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

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

		private TeamLevelType m_Type;

		private XExpeditionDocument m_ExpDoc;

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

		public override void RegisterEvent()
		{
			base.uiBehaviour.m_CancelButton.RegisterClickEventHandler(new ButtonClickEventHandler(this._DoCancel));
			base.uiBehaviour.m_OKButton.RegisterClickEventHandler(new ButtonClickEventHandler(this._DoOK));
		}

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

		public void ActiveShow(TeamLevelType dungeonType)
		{
			this._ShowBuyCountAndBuyConfirm("ACTIVE_BUYCOUNT_CONFIRM", dungeonType);
		}

		public void PassiveShow(TeamLevelType dungeonType)
		{
			this._ShowBuyCountAndBuyConfirm("PASSIVE_BUYCOUNT_CONFIRM", dungeonType);
		}

		private void _ShowBuyCountAndBuyConfirm(string reason, TeamLevelType dungeonType)
		{
			base.Load();
			int num;
			int num2;
			bool flag = this.m_ExpDoc.CanBuy(dungeonType, out num, out num2);
			if (flag)
			{
				CostInfo buyCost = this.m_ExpDoc.GetBuyCost(dungeonType);
				base.uiBehaviour.m_ContentLabelSymbol.InputText = XStringDefineProxy.GetString(reason, new object[]
				{
					XLabelSymbolHelper.FormatCostWithIcon((int)buyCost.count, buyCost.type),
					XStringDefineProxy.GetString(dungeonType.ToString())
				});
				base.uiBehaviour.m_LeftBuyCount.SetText((num2 - num).ToString());
				this.m_Type = dungeonType;
				this.SetVisibleWithAnimation(true, null);
			}
			else
			{
				bool flag2 = this.m_ExpDoc.GetBuyLimit(dungeonType) > 0;
				if (flag2)
				{
					XSingleton<UiUtility>.singleton.ShowSystemTip(ErrorCode.ERR_TEAMBUY_COUNT_MAX, "fece00");
				}
			}
		}

		private bool _DoOK(IXUIButton go)
		{
			this.SetVisibleWithAnimation(false, null);
			this.m_ExpDoc.ReqBuyCount(this.m_Type);
			return true;
		}

		private bool _DoCancel(IXUIButton go)
		{
			this.SetVisibleWithAnimation(false, null);
			return true;
		}
	}
}