summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/UI/GuildCollectRewardDlg.cs
blob: 424dd77fa56f831df926ee4c1ff89392ab9525e3 (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
using System;
using UILib;
using UnityEngine;
using XMainClient.UI.UICommon;
using XUtliPoolLib;

namespace XMainClient.UI
{
	internal class GuildCollectRewardDlg : DlgBase<GuildCollectRewardDlg, GuildCollectRewardBehaviour>
	{
		public override bool autoload
		{
			get
			{
				return true;
			}
		}

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

		public override string fileName
		{
			get
			{
				return "Guild/GuildCollect/GuildCollectReward";
			}
		}

		private XGuildCollectDocument _doc = null;

		private string _tipsStr;

		protected override void Init()
		{
			base.Init();
			this._doc = XDocuments.GetSpecificDocument<XGuildCollectDocument>(XGuildCollectDocument.uuID);
			this._tipsStr = XStringDefineProxy.GetString("GuildCollectRewardTimeTips");
		}

		public override void RegisterEvent()
		{
			base.RegisterEvent();
			base.uiBehaviour.m_Close.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnCloseBtnClick));
			base.uiBehaviour.m_Help.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnHelpBtnClick));
		}

		protected override void OnShow()
		{
			base.OnShow();
			this._doc.QueryGetRewardCount();
			this.Refresh();
		}

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

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

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

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

		public void Refresh()
		{
			base.uiBehaviour.m_CollectPool.ReturnAll(false);
			base.uiBehaviour.m_ItemPool.ReturnAll(true);
			Vector3 tplPos = base.uiBehaviour.m_CollectPool.TplPos;
			for (int i = 0; i < this._doc.RewardReader.Table.Length; i++)
			{
				GuildCampPartyReward.RowData rowData = this._doc.RewardReader.Table[i];
				GameObject gameObject = base.uiBehaviour.m_CollectPool.FetchGameObject(false);
				gameObject.transform.localPosition = new Vector3(tplPos.x, tplPos.y - (float)(i * base.uiBehaviour.m_CollectPool.TplHeight));
				Transform parent = gameObject.transform.Find("CollectList");
				Transform parent2 = gameObject.transform.Find("RewardList");
				IXUIButton ixuibutton = gameObject.transform.Find("BtnFetch").GetComponent("XUIButton") as IXUIButton;
				GameObject gameObject2 = gameObject.transform.Find("Get").gameObject;
				bool grey = true;
				for (int j = 0; j < rowData.Items.Count; j++)
				{
					GameObject gameObject3 = base.uiBehaviour.m_ItemPool.FetchGameObject(false);
					gameObject3.transform.parent = parent;
					gameObject3.transform.localPosition = new Vector3((float)(j * base.uiBehaviour.m_ItemPool.TplWidth), 0f);
					XSingleton<XItemDrawerMgr>.singleton.normalItemDrawer.DrawItem(gameObject3, (int)rowData.Items[j, 0], (int)rowData.Items[j, 1], true);
					XSingleton<XItemDrawerMgr>.singleton.normalItemDrawer.OpenClickShowTooltipEvent(gameObject3, (int)rowData.Items[j, 0]);
					IXUILabel ixuilabel = gameObject3.transform.Find("Num").GetComponent("XUILabel") as IXUILabel;
					int num = (int)XBagDocument.BagDoc.GetItemCount((int)rowData.Items[j, 0]);
					ixuilabel.SetText(string.Format("{0}{1}/{2}", (num >= (int)rowData.Items[j, 1]) ? "[ffffff]" : "[fd4343]", num, (int)rowData.Items[j, 1]));
					bool flag = num < (int)rowData.Items[j, 1];
					if (flag)
					{
						grey = false;
					}
				}
				for (int k = 0; k < rowData.Reward.Count; k++)
				{
					GameObject gameObject4 = base.uiBehaviour.m_ItemPool.FetchGameObject(false);
					gameObject4.transform.parent = parent2;
					gameObject4.transform.localPosition = new Vector3((float)(k * base.uiBehaviour.m_ItemPool.TplWidth), 0f);
					XSingleton<XItemDrawerMgr>.singleton.normalItemDrawer.DrawItem(gameObject4, (int)rowData.Reward[k, 0], (int)rowData.Reward[k, 1], false);
					XSingleton<XItemDrawerMgr>.singleton.normalItemDrawer.OpenClickShowTooltipEvent(gameObject4, (int)rowData.Reward[k, 0]);
				}
				int num2 = 0;
				this._doc.CollectUseDict.TryGetValue(rowData.ID, out num2);
				bool flag2 = num2 > 0;
				if (flag2)
				{
					gameObject2.SetActive(true);
					ixuibutton.SetVisible(false);
				}
				else
				{
					gameObject2.SetActive(false);
					ixuibutton.SetVisible(true);
					ixuibutton.SetGrey(grey);
					ixuibutton.ID = (ulong)rowData.ID;
					ixuibutton.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnFetchBtnClick));
				}
			}
		}

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

		private bool OnFetchBtnClick(IXUIButton btn)
		{
			this._doc.QueryGetReward((uint)btn.ID);
			return true;
		}

		private bool OnHelpBtnClick(IXUIButton btn)
		{
			DlgBase<XCommonHelpTipView, XCommonHelpTipBehaviour>.singleton.ShowHelp(XSysDefine.XSys_GuildCollect);
			return true;
		}

		public void RefreshTime(int time)
		{
			base.uiBehaviour.m_LeftTime.SetText(string.Format(this._tipsStr, XSingleton<UiUtility>.singleton.TimeDuarationFormatString(time, 5)));
		}
	}
}