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

namespace XMainClient.UI
{
	internal class CustomBattleView : TabDlgBase<CustomBattleView>
	{
		public override string fileName
		{
			get
			{
				return "GameSystem/CustomBattle/CustomBattleDlg";
			}
		}

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

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

		public override int sysid
		{
			get
			{
				return XFastEnumIntEqualityComparer<XSysDefine>.ToInt(XSysDefine.XSys_CustomBattle);
			}
		}

		protected override bool bHorizontal
		{
			get
			{
				return false;
			}
		}

		private XCustomBattleDocument _doc = null;

		public CustomBattleBountyModeDetailHandler _BountyModeDetailHandler = null;

		public CustomBattleBountyModeListHandler _BountyModeListHandler = null;

		public CustomBattleBriefHandler _CustomModeBriefHandler = null;

		public CustomBattleChestHandler _ChestHandler = null;

		public CustomBattleCustomModeCreateHandler _CustomModeCreateHandler = null;

		public CustomBattleCustomModeDetailHandler _CustomModeDetailHandler = null;

		public CustomBattleCustomModeListHandler _CustomModeListHandler = null;

		public CustomBattleMatchingHandler _MatchingHandler = null;

		public CustomBattlePasswordSettingHandler _PasswordSettingHandler = null;

		private IXUIButton _help;

		private IXUIButton _shop;

		protected override void Init()
		{
			base.Init();
			this._doc = XDocuments.GetSpecificDocument<XCustomBattleDocument>(XCustomBattleDocument.uuID);
			this._help = (base.uiBehaviour.transform.Find("Bg/Help").GetComponent("XUIButton") as IXUIButton);
			this._shop = (base.uiBehaviour.transform.Find("Bg/BtnShop").GetComponent("XUIButton") as IXUIButton);
			base.RegisterSubSysRedPointMgr(XSysDefine.XSys_CustomBattle);
		}

		protected override void OnUnload()
		{
			DlgHandlerBase.EnsureUnload<CustomBattleBountyModeDetailHandler>(ref this._BountyModeDetailHandler);
			DlgHandlerBase.EnsureUnload<CustomBattleBountyModeListHandler>(ref this._BountyModeListHandler);
			DlgHandlerBase.EnsureUnload<CustomBattleBriefHandler>(ref this._CustomModeBriefHandler);
			DlgHandlerBase.EnsureUnload<CustomBattleChestHandler>(ref this._ChestHandler);
			DlgHandlerBase.EnsureUnload<CustomBattleCustomModeCreateHandler>(ref this._CustomModeCreateHandler);
			DlgHandlerBase.EnsureUnload<CustomBattleCustomModeDetailHandler>(ref this._CustomModeDetailHandler);
			DlgHandlerBase.EnsureUnload<CustomBattleCustomModeListHandler>(ref this._CustomModeListHandler);
			DlgHandlerBase.EnsureUnload<CustomBattleMatchingHandler>(ref this._MatchingHandler);
			DlgHandlerBase.EnsureUnload<CustomBattlePasswordSettingHandler>(ref this._PasswordSettingHandler);
			base.OnUnload();
		}

		public override void RegisterEvent()
		{
			base.RegisterEvent();
			this._help.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnHelpClicked));
			this._shop.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnShopClicked));
		}

		private bool OnCloseClicked(IXUIButton button)
		{
			this.SetVisible(false, true);
			return true;
		}

		private bool OnHelpClicked(IXUIButton button)
		{
			DlgBase<XCommonHelpTipView, XCommonHelpTipBehaviour>.singleton.ShowHelp(XSysDefine.XSys_CustomBattle);
			return true;
		}

		private bool OnShopClicked(IXUIButton button)
		{
			XSingleton<XGameSysMgr>.singleton.OpenSystem(XSysDefine.XSys_Mall_AllPkMatch, 0UL);
			return true;
		}

		public void ShowBountyModeDetailHandler()
		{
			DlgHandlerBase.EnsureCreate<CustomBattleBountyModeDetailHandler>(ref this._BountyModeDetailHandler, base.uiBehaviour.m_root, true, null);
		}

		public void ShowBountyModeListHandler()
		{
			this.HideAll();
			DlgHandlerBase.EnsureCreate<CustomBattleBountyModeListHandler>(ref this._BountyModeListHandler, base.uiBehaviour.m_root, true, null);
		}

		public void ShowCustomModeBriefHandler()
		{
			DlgHandlerBase.EnsureCreate<CustomBattleBriefHandler>(ref this._CustomModeBriefHandler, base.uiBehaviour.m_root, true, null);
		}

		public void ShowChestHandler()
		{
			DlgHandlerBase.EnsureCreate<CustomBattleChestHandler>(ref this._ChestHandler, base.uiBehaviour.m_root, true, null);
		}

		public void ShowCustomModeCreateHandler()
		{
			DlgHandlerBase.EnsureCreate<CustomBattleCustomModeCreateHandler>(ref this._CustomModeCreateHandler, base.uiBehaviour.m_root, true, null);
		}

		public void ShowCustomModeDetailHandler()
		{
			this.HideAll();
			DlgHandlerBase.EnsureCreate<CustomBattleCustomModeDetailHandler>(ref this._CustomModeDetailHandler, base.uiBehaviour.m_root, true, null);
		}

		public void ShowCustomModeListHandler()
		{
			this.HideAll();
			DlgHandlerBase.EnsureCreate<CustomBattleCustomModeListHandler>(ref this._CustomModeListHandler, base.uiBehaviour.m_root, true, null);
		}

		public void ShowMatchingHandler()
		{
			DlgHandlerBase.EnsureCreate<CustomBattleMatchingHandler>(ref this._MatchingHandler, base.uiBehaviour.m_root, true, null);
		}

		public void ShowPasswordSettingHandler()
		{
			DlgHandlerBase.EnsureCreate<CustomBattlePasswordSettingHandler>(ref this._PasswordSettingHandler, base.uiBehaviour.m_root, true, null);
		}

		private void HideHandler(DlgHandlerBase handler)
		{
			bool flag = handler == null;
			if (!flag)
			{
				handler.SetVisible(false);
			}
		}

		private void HideAll()
		{
			this.HideHandler(this._BountyModeDetailHandler);
			this.HideHandler(this._BountyModeListHandler);
			this.HideHandler(this._CustomModeBriefHandler);
			this.HideHandler(this._ChestHandler);
			this.HideHandler(this._CustomModeCreateHandler);
			this.HideHandler(this._CustomModeDetailHandler);
			this.HideHandler(this._CustomModeListHandler);
			this.HideHandler(this._MatchingHandler);
			this.HideHandler(this._PasswordSettingHandler);
		}

		public override void SetupHandlers(XSysDefine sys)
		{
			if (sys != XSysDefine.XSys_CustomBattle_BountyMode)
			{
				if (sys == XSysDefine.XSys_CustomBattle_CustomMode)
				{
					bool flag = this._doc.SelfCustomData != null;
					if (flag)
					{
						this._doc.CurrentCustomData = this._doc.SelfCustomData;
						this.ShowCustomModeDetailHandler();
					}
					else
					{
						this.ShowCustomModeListHandler();
					}
				}
			}
			else
			{
				bool flag2 = this._doc.CurrentBountyData != null && this._doc.CurrentBountyData.gameID == this._doc.CacheGameID;
				if (flag2)
				{
					this.ShowBountyModeListHandler();
					this.ShowBountyModeDetailHandler();
				}
				else
				{
					this.ShowBountyModeListHandler();
				}
			}
			this._doc.CacheGameID = 0UL;
		}

		public override void OnUpdate()
		{
			base.OnUpdate();
			bool flag = this._BountyModeListHandler != null;
			if (flag)
			{
				this._BountyModeListHandler.OnUpdate();
			}
			bool flag2 = this._BountyModeDetailHandler != null;
			if (flag2)
			{
				this._BountyModeDetailHandler.OnUpdate();
			}
			bool flag3 = this._CustomModeDetailHandler != null;
			if (flag3)
			{
				this._CustomModeDetailHandler.OnUpdate();
			}
			bool flag4 = this._ChestHandler != null;
			if (flag4)
			{
				this._ChestHandler.OnUpdate();
			}
			bool flag5 = this._CustomModeBriefHandler != null;
			if (flag5)
			{
				this._CustomModeBriefHandler.OnUpdate();
			}
		}
	}
}