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

namespace XMainClient
{
	internal class WeekEndNestDlg : DlgBase<WeekEndNestDlg, WeekEndNestBehaviour>
	{
		public override string fileName
		{
			get
			{
				return "GameSystem/WeekEndNestDlg";
			}
		}

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

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

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

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

		private WeekEndNestDocument m_doc;

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

		public override void RegisterEvent()
		{
			base.RegisterEvent();
			base.uiBehaviour.m_closedBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnClosed));
			base.uiBehaviour.m_helpBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnHelp));
			base.uiBehaviour.m_getBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnGeted));
			base.uiBehaviour.m_gotoTeamBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnGotoTeam));
		}

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

		protected override void Init()
		{
			base.Init();
			this.m_doc = WeekEndNestDocument.Doc;
		}

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

		protected override void OnShow()
		{
			base.OnShow();
			this.FillContent();
			bool needLoginShow = this.m_doc.NeedLoginShow;
			if (needLoginShow)
			{
				this.m_doc.NeedLoginShow = false;
			}
		}

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

		public void Refresh()
		{
			this.FillContent();
		}

		private void FillContent()
		{
			base.uiBehaviour.m_tittleLab.SetText(this.m_doc.GetLevelName());
			base.uiBehaviour.m_rulesLab.SetText(this.m_doc.GetRules());
			base.uiBehaviour.m_tex.SetTexturePath(this.m_doc.GetTexName());
			base.uiBehaviour.m_timesLab.SetText(string.Format("{0}/{1}", this.m_doc.LeftCount, this.m_doc.MaxCount()));
			bool flag = this.m_doc.GetStatus == 1u;
			if (flag)
			{
				base.uiBehaviour.m_getSpr.SetGrey(true);
				base.uiBehaviour.m_reddotGo.SetActive(true);
			}
			else
			{
				base.uiBehaviour.m_getSpr.SetGrey(false);
				base.uiBehaviour.m_reddotGo.SetActive(false);
			}
			base.uiBehaviour.m_itemPool.ReturnAll(true);
			SeqListRef<uint> reward = this.m_doc.GetReward();
			for (int i = 0; i < (int)reward.count; i++)
			{
				GameObject gameObject = base.uiBehaviour.m_itemPool.FetchGameObject(false);
				gameObject.name = reward[i, 0].ToString();
				gameObject.transform.parent = base.uiBehaviour.m_parentTra;
				gameObject.transform.localPosition = new Vector3((float)(i * base.uiBehaviour.m_itemPool.TplWidth), 0f, 0f);
				XSingleton<XItemDrawerMgr>.singleton.normalItemDrawer.DrawItem(gameObject, (int)reward[i, 0], (int)reward[i, 1], false);
				IXUISprite ixuisprite = gameObject.transform.Find("Icon").GetComponent("XUISprite") as IXUISprite;
				ixuisprite.ID = (ulong)reward[i, 0];
				ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnShowTips));
			}
		}

		private bool OnClosed(IXUIButton btn)
		{
			this.SetVisible(false, true);
			return true;
		}

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

		private bool OnGeted(IXUIButton btn)
		{
			bool flag = this.m_doc.GetStatus != 1u;
			bool result;
			if (flag)
			{
				result = false;
			}
			else
			{
				this.m_doc.ReqGetReward();
				result = true;
			}
			return result;
		}

		private bool OnGotoTeam(IXUIButton btn)
		{
			int dnId = this.m_doc.GetDnId();
			bool flag = dnId == 0;
			bool result;
			if (flag)
			{
				result = false;
			}
			else
			{
				XTeamDocument specificDocument = XDocuments.GetSpecificDocument<XTeamDocument>(XTeamDocument.uuID);
				specificDocument.SetAndMatch(dnId);
				result = true;
			}
			return result;
		}

		private void OnShowTips(IXUISprite spr)
		{
			int itemID = (int)spr.ID;
			XItem mainItem = XBagDocument.MakeXItem(itemID, true);
			XSingleton<UiUtility>.singleton.ShowTooltipDialogWithSearchingCompare(mainItem, spr, true, 0u);
		}
	}
}