summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/XOptionsBattleHandler.cs
blob: 441b0b9a8ad28f2d4b7e2b686fd2e6b5bba9c33e (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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
using System;
using KKSG;
using UILib;
using UnityEngine;
using XMainClient.UI;
using XMainClient.UI.UICommon;
using XUpdater;
using XUtliPoolLib;

namespace XMainClient
{
	internal class XOptionsBattleHandler : DlgHandlerBase
	{
		protected override string FileName
		{
			get
			{
				return "Battle/BattleSetDlg";
			}
		}

		private XOptionsDocument doc = null;

		private XOptionsBattleDetailHandler m_DetailHandler;

		public OptionsBattleTab prefabTab = OptionsBattleTab.CameraTab;

		private IXUIButton m_Close;

		private IXUIButton m_Continue;

		private IXUIButton m_Leave;

		private IXUICheckBox m_CameraTab;

		private IXUICheckBox m_OperateTab;

		private IXUICheckBox m_OtherTab;

		private IXUILabel m_CameraTabLabel;

		private IXUILabel m_OperateTabLabel;

		private IXUILabel m_OtherTabTabLabel;

		private IXUILabel m_CameraSelecteTabLabel;

		private IXUILabel m_OperateSelecteTabLabel;

		private IXUILabel m_OtherSelecteTabTabLabel;

		protected override void Init()
		{
			base.Init();
			this.doc = XDocuments.GetSpecificDocument<XOptionsDocument>(XOptionsDocument.uuID);
			this.m_Close = (base.transform.Find("Bg/Close").GetComponent("XUIButton") as IXUIButton);
			this.m_Continue = (base.transform.Find("Bg/Btn/Continue").GetComponent("XUIButton") as IXUIButton);
			this.m_Leave = (base.transform.Find("Bg/Btn/Leave").GetComponent("XUIButton") as IXUIButton);
			Transform transform = base.transform.Find("Bg/Tabs");
			this.m_CameraTab = (transform.Find("CameraTab").GetComponent("XUICheckBox") as IXUICheckBox);
			this.m_OperateTab = (transform.Find("OperateTab").GetComponent("XUICheckBox") as IXUICheckBox);
			this.m_OtherTab = (transform.Find("OtherTab").GetComponent("XUICheckBox") as IXUICheckBox);
			this.m_CameraTabLabel = (transform.Find("CameraTab/T").GetComponent("XUILabel") as IXUILabel);
			this.m_OperateTabLabel = (transform.Find("OperateTab/T").GetComponent("XUILabel") as IXUILabel);
			this.m_OtherTabTabLabel = (transform.Find("OtherTab/T").GetComponent("XUILabel") as IXUILabel);
			this.m_CameraSelecteTabLabel = (transform.Find("CameraTab/Selected/T").GetComponent("XUILabel") as IXUILabel);
			this.m_OperateSelecteTabLabel = (transform.Find("OperateTab/Selected/T").GetComponent("XUILabel") as IXUILabel);
			this.m_OtherSelecteTabTabLabel = (transform.Find("OtherTab/Selected/T").GetComponent("XUILabel") as IXUILabel);
			DlgHandlerBase.EnsureCreate<XOptionsBattleDetailHandler>(ref this.m_DetailHandler, base.transform.Find("Bg/DetailPanel").gameObject, null, true);
		}

		public override void RegisterEvent()
		{
			this.m_Close.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnCloseClicked));
			this.m_Continue.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnCloseClicked));
			this.m_Leave.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnLeaveClicked));
			this.m_CameraTab.RegisterOnCheckEventHandler(new CheckBoxOnCheckEventHandler(this.OnCameraCheckBoxClicked));
			this.m_OperateTab.RegisterOnCheckEventHandler(new CheckBoxOnCheckEventHandler(this.OnOperateCheckBoxClicked));
			this.m_OtherTab.RegisterOnCheckEventHandler(new CheckBoxOnCheckEventHandler(this.OnOtherCheckBoxClicked));
		}

		public bool OnCloseClicked(IXUIButton sp)
		{
			base.SetVisible(false);
			bool flag = this.m_DetailHandler != null;
			if (flag)
			{
				this.m_DetailHandler.SaveOption();
				bool flag2 = this.m_DetailHandler.bDirty || XSingleton<XOperationData>.singleton.OperationMode != (XOperationMode)this.doc.GetValue(XOptionsDefine.OD_VIEW);
				if (flag2)
				{
					this.doc.SetBattleOptionValue();
					this.m_DetailHandler.bDirty = false;
				}
			}
			return true;
		}

		public bool OnLeaveClicked(IXUIButton sp)
		{
			base.SetVisible(false);
			bool flag = this.m_DetailHandler != null;
			if (flag)
			{
				this.m_DetailHandler.SaveOption();
			}
			bool syncMode = XSingleton<XGame>.singleton.SyncMode;
			if (syncMode)
			{
				bool flag2 = XSingleton<XScene>.singleton.SceneType == SceneType.SCENE_TOWER;
				if (flag2)
				{
					PtcC2G_SyncSceneFinish proto = new PtcC2G_SyncSceneFinish();
					XSingleton<XClientNetwork>.singleton.Send(proto);
				}
				else
				{
					bool flag3 = XSingleton<XScene>.singleton.SceneType == SceneType.SCENE_BOSSRUSH;
					if (flag3)
					{
						bool flag4 = DlgBase<BattleMain, BattleMainBehaviour>.singleton.IsLoaded();
						if (flag4)
						{
							DlgBase<BattleMain, BattleMainBehaviour>.singleton.ShowBossrushQuit();
						}
					}
					else
					{
						XSingleton<XScene>.singleton.ReqLeaveScene();
					}
				}
			}
			else
			{
				RpcC2G_ReportBattle rpcC2G_ReportBattle = new RpcC2G_ReportBattle();
				rpcC2G_ReportBattle.oArg.battledata = new BattleData();
				rpcC2G_ReportBattle.oArg.battledata.BeHit = 0;
				rpcC2G_ReportBattle.oArg.battledata.hppercent = 100u;
				rpcC2G_ReportBattle.oArg.battledata.Combo = 100;
				XSingleton<XLevelFinishMgr>.singleton.IsFastLevelFinish = true;
				XSingleton<XLevelDoodadMgr>.singleton.ReportServerList(rpcC2G_ReportBattle.oArg.battledata.pickDoodadWaveID);
				XLevelRewardDocument specificDocument = XDocuments.GetSpecificDocument<XLevelRewardDocument>(XLevelRewardDocument.uuID);
				specificDocument.RequestServer = true;
				XSingleton<XClientNetwork>.singleton.Send(rpcC2G_ReportBattle);
			}
			XSingleton<XGameSysMgr>.singleton.bStopBlockRedPoint = true;
			return true;
		}

		public void ShowUI()
		{
			bool flag = !base.IsVisible();
			if (flag)
			{
				base.SetVisible(true);
			}
			this.OnTabChanged(this.prefabTab);
			DlgBase<XChatMaqueeView, XChatMaqueeBehaviour>.singleton.SetMaqueeSwitch(false);
		}

		protected override void OnShow()
		{
			base.OnShow();
			this.ShowUI();
			XOptions.RowData optionData = XOptionsDocument.GetOptionData(XOptionsDefine.OD_VIEW);
			this.m_CameraTabLabel.SetText(optionData.Text);
			this.m_CameraSelecteTabLabel.SetText(optionData.Text);
			optionData = XOptionsDocument.GetOptionData(XOptionsDefine.OD_OPERATE);
			this.m_OperateTabLabel.SetText(optionData.Text);
			this.m_OperateSelecteTabLabel.SetText(optionData.Text);
			optionData = XOptionsDocument.GetOptionData(XOptionsDefine.OD_OTHER);
			this.m_OtherTabTabLabel.SetText(optionData.Text);
			this.m_OtherSelecteTabTabLabel.SetText(optionData.Text);
			SceneTable.RowData sceneData = XSingleton<XSceneMgr>.singleton.GetSceneData(XSingleton<XScene>.singleton.SceneID);
			bool flag = sceneData.IsCanQuit || XSingleton<XScene>.singleton.bSpectator;
			if (flag)
			{
				this.m_Leave.SetEnable(true, false);
			}
			else
			{
				this.m_Leave.SetEnable(true, false);
			}
		}

		protected override void OnHide()
		{
			XSingleton<XShell>.singleton.Pause = false;
			DlgBase<XChatMaqueeView, XChatMaqueeBehaviour>.singleton.SetMaqueeSwitch(true);
			base.OnHide();
		}

		public override void OnUnload()
		{
			DlgHandlerBase.EnsureUnload<XOptionsBattleDetailHandler>(ref this.m_DetailHandler);
			base.OnUnload();
		}

		private bool OnCameraCheckBoxClicked(IXUICheckBox box)
		{
			bool flag = !box.bChecked;
			bool result;
			if (flag)
			{
				result = false;
			}
			else
			{
				this.OnTabChanged(OptionsBattleTab.CameraTab);
				result = true;
			}
			return result;
		}

		private bool OnOperateCheckBoxClicked(IXUICheckBox box)
		{
			bool flag = !box.bChecked;
			bool result;
			if (flag)
			{
				result = false;
			}
			else
			{
				this.OnTabChanged(OptionsBattleTab.OperateTab);
				result = true;
			}
			return result;
		}

		private bool OnOtherCheckBoxClicked(IXUICheckBox box)
		{
			bool flag = !box.bChecked;
			bool result;
			if (flag)
			{
				result = false;
			}
			else
			{
				this.OnTabChanged(OptionsBattleTab.OtherTab);
				result = true;
			}
			return result;
		}

		public void OnTabChanged(OptionsBattleTab handler)
		{
			switch (handler)
			{
			case OptionsBattleTab.CameraTab:
			{
				bool flag = this.m_CameraTab != null;
				if (flag)
				{
					this.m_CameraTab.bChecked = true;
				}
				break;
			}
			case OptionsBattleTab.OperateTab:
			{
				bool flag2 = this.m_OperateTab != null;
				if (flag2)
				{
					this.m_OperateTab.bChecked = true;
				}
				break;
			}
			case OptionsBattleTab.OtherTab:
			{
				bool flag3 = this.m_OtherTab != null;
				if (flag3)
				{
					this.m_OtherTab.bChecked = true;
				}
				break;
			}
			}
			bool flag4 = this.m_DetailHandler != null;
			if (flag4)
			{
				this.m_DetailHandler.ShowUI(handler);
			}
			this.prefabTab = handler;
		}
	}
}