summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/XCaptainPVPView.cs
blob: 66d038bc90ac111748b467ddab0285cf3a5332c7 (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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
using System;
using System.Collections.Generic;
using KKSG;
using UILib;
using UnityEngine;
using XMainClient.UI;
using XMainClient.UI.UICommon;
using XUtliPoolLib;

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

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

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

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

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

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

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

		private XCaptainPVPDocument _doc = null;

		public BattleRecordHandler m_CaptainBattleRecordHandler;

		private uint _DataTimerID = 0u;

		protected override void Init()
		{
			this._doc = XDocuments.GetSpecificDocument<XCaptainPVPDocument>(XCaptainPVPDocument.uuID);
			this._doc.View = this;
			DlgHandlerBase.EnsureCreate<BattleRecordHandler>(ref this.m_CaptainBattleRecordHandler, base.uiBehaviour.m_BattleRecordFrame, null, false);
		}

		public override void RegisterEvent()
		{
			base.uiBehaviour.m_Close.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnCloseClicked));
			base.uiBehaviour.m_Help.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnHelpClicked));
			base.uiBehaviour.m_BtnShop.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnShopClicked));
			base.uiBehaviour.m_BtnRecord.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnRecordClicked));
			base.uiBehaviour.m_BtnStartSingle.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnStartSingleClicked));
			base.uiBehaviour.m_BtnStartTeam.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnStartTeamClicked));
		}

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

		protected override void OnShow()
		{
			base.OnShow();
			this.InitShow();
			XSingleton<XTimerMgr>.singleton.KillTimer(this._DataTimerID);
			this._AutoRefresh(null);
		}

		protected override void OnHide()
		{
			base.OnHide();
			this.m_CaptainBattleRecordHandler.SetVisible(false);
			XSingleton<XTimerMgr>.singleton.KillTimer(this._DataTimerID);
			this._DataTimerID = 0u;
		}

		protected override void OnUnload()
		{
			DlgHandlerBase.EnsureUnload<BattleRecordHandler>(ref this.m_CaptainBattleRecordHandler);
			XSingleton<XTimerMgr>.singleton.KillTimer(this._DataTimerID);
			this._DataTimerID = 0u;
			this._doc.View = null;
			base.OnUnload();
		}

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

		public void RefreshButtonState()
		{
			bool flag = !base.IsLoaded();
			if (!flag)
			{
				XTeamDocument specificDocument = XDocuments.GetSpecificDocument<XTeamDocument>(XTeamDocument.uuID);
				bool flag2 = specificDocument.SoloMatchType == KMatchType.KMT_PVP;
				if (flag2)
				{
					DlgBase<XCaptainPVPView, XCaptainPVPBehaviour>.singleton.uiBehaviour.m_BtnStartSingleLabel.SetText(string.Format("{0}...", XStringDefineProxy.GetString("MATCHING")));
					DlgBase<XCaptainPVPView, XCaptainPVPBehaviour>.singleton.uiBehaviour.m_BtnStartTeam.SetEnable(false, false);
				}
				else
				{
					DlgBase<XCaptainPVPView, XCaptainPVPBehaviour>.singleton.uiBehaviour.m_BtnStartSingleLabel.SetText(string.Format(XStringDefineProxy.GetString("CAPTAINPVP_SINGLE"), new object[0]));
					DlgBase<XCaptainPVPView, XCaptainPVPBehaviour>.singleton.uiBehaviour.m_BtnStartTeam.SetEnable(true, false);
				}
			}
		}

		public bool OnCloseClicked(IXUIButton sp)
		{
			this.SetVisibleWithAnimation(false, null);
			return true;
		}

		public bool OnRoleClicked(IXUISprite sp)
		{
			return true;
		}

		private bool OnItemListCloseClicked(IXUIButton sp)
		{
			return true;
		}

		private void OnBoxClicked(IXUITexture sp)
		{
			bool canGetWeekReward = this._doc.canGetWeekReward;
			if (canGetWeekReward)
			{
				this._doc.ReqGetWeekReward();
			}
			else
			{
				bool flag = !this._doc.isEmptyBox;
				if (flag)
				{
					this.RefreshWeekReward();
				}
				else
				{
					XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("SRS_FETCHED"), "fece00");
				}
			}
		}

		public bool OnGetWeekRewardClicked(IXUIButton sp)
		{
			bool canGetWeekReward = this._doc.canGetWeekReward;
			if (canGetWeekReward)
			{
				this._doc.ReqGetWeekReward();
			}
			return true;
		}

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

		private bool OnRecordClicked(IXUIButton sp)
		{
			this._doc.ReqGetHistory();
			this.m_CaptainBattleRecordHandler.SetupRecord(this._doc.RecordList);
			return true;
		}

		private bool OnStartSingleClicked(IXUIButton sp)
		{
			XTeamDocument specificDocument = XDocuments.GetSpecificDocument<XTeamDocument>(XTeamDocument.uuID);
			bool bInTeam = specificDocument.bInTeam;
			bool result;
			if (bInTeam)
			{
				XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("CAPTAIN_SINGLE_MATCH_TIP"), "fece00");
				result = false;
			}
			else
			{
				KMatchOp op = (specificDocument.SoloMatchType != KMatchType.KMT_PVP) ? KMatchOp.KMATCH_OP_START : KMatchOp.KMATCH_OP_STOP;
				specificDocument.ReqMatchStateChange(KMatchType.KMT_PVP, op, false);
				result = true;
			}
			return result;
		}

		private bool OnStartTeamClicked(IXUIButton sp)
		{
			this.OnCloseClicked(sp);
			XExpeditionDocument specificDocument = XDocuments.GetSpecificDocument<XExpeditionDocument>(XExpeditionDocument.uuID);
			List<ExpeditionTable.RowData> expeditionList = specificDocument.GetExpeditionList(TeamLevelType.TeamLevelCaptainPVP);
			XTeamDocument specificDocument2 = XDocuments.GetSpecificDocument<XTeamDocument>(XTeamDocument.uuID);
			bool flag = expeditionList.Count > 0;
			if (flag)
			{
				specificDocument2.SetAndMatch(expeditionList[0].DNExpeditionID);
			}
			return true;
		}

		public void InitShow()
		{
			base.uiBehaviour.m_BattleRecord.SetText("");
			base.uiBehaviour.m_BoxLabel.SetText("0/0");
			base.uiBehaviour.m_MatchNum.SetText("");
			base.uiBehaviour.m_ExRewardLabel.SetText("");
			base.uiBehaviour.m_BtnStartSingleLabel.SetText(string.Format(XStringDefineProxy.GetString("CAPTAINPVP_SINGLE"), new object[0]));
			base.uiBehaviour.m_BtnStartTeam.SetEnable(true, false);
			this.RefreshButtonState();
		}

		public void RefreshWeekReward()
		{
			bool flag = !base.IsVisible();
			if (!flag)
			{
				int weekWinCount = this._doc.weekWinCount;
				string arg = (weekWinCount == this._doc.weekMax) ? "[00ff37]" : "[ffffff]";
				string text = string.Format("{0}{1}[-]", arg, weekWinCount);
				base.uiBehaviour.m_WeekRewardLabel.SetText(string.Format(XStringDefineProxy.GetString("CAPTAIN_WEEK_REWARD"), this._doc.weekMax, this._doc.weekWinCount, this._doc.weekMax));
				base.uiBehaviour.m_WeekRewardPool.ReturnAll(false);
				string[] array = XSingleton<XGlobalConfig>.singleton.GetValue("PVPWeekRewards").Split(XGlobalConfig.AllSeparators);
				int num = array.Length / 2;
				for (int i = 0; i < num; i++)
				{
					GameObject gameObject = base.uiBehaviour.m_WeekRewardPool.FetchGameObject(false);
					XSingleton<XItemDrawerMgr>.singleton.normalItemDrawer.DrawItem(gameObject, int.Parse(array[i * 2]), int.Parse(array[i * 2 + 1]), false);
					XSingleton<XItemDrawerMgr>.singleton.normalItemDrawer.OpenClickShowTooltipEvent(gameObject, int.Parse(array[i * 2]));
					IXUISprite ixuisprite = gameObject.GetComponent("XUISprite") as IXUISprite;
					gameObject.transform.localPosition = new Vector3((float)(i * ixuisprite.spriteWidth), 0f, 0f);
					gameObject.transform.Find("HadGet").gameObject.SetActive(this._doc.isEmptyBox);
					IXUIButton ixuibutton = gameObject.transform.Find("GetRewardBtn").GetComponent("XUIButton") as IXUIButton;
					ixuibutton.gameObject.SetActive(this._doc.canGetWeekReward);
					ixuibutton.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnGetWeekRewardClicked));
				}
			}
		}

		public void RefreshExReward(int joinNum, int joinNumMax)
		{
			bool flag = !base.IsVisible();
			if (!flag)
			{
				int num = Math.Max(joinNumMax - joinNum, 0);
				string arg = (num == 0) ? "[ff3e3e]" : "[00ff37]";
				string text = string.Format("{0}{1}[-]", arg, num);
				DlgBase<XCaptainPVPView, XCaptainPVPBehaviour>.singleton.uiBehaviour.m_ExRewardLabel.SetText(string.Format(XStringDefineProxy.GetString("CAPTAINPVP_EXTRA"), new object[]
				{
					XSingleton<XGlobalConfig>.singleton.GetValue("PVPDayOpenTime"),
					joinNumMax.ToString(),
					text,
					joinNumMax.ToString()
				}));
				base.uiBehaviour.m_ExRewardPool.ReturnAll(false);
				string[] array = XSingleton<XGlobalConfig>.singleton.GetValue("PVPDayRewards").Split(XGlobalConfig.AllSeparators);
				int num2 = array.Length / 2;
				for (int i = 0; i < num2; i++)
				{
					GameObject gameObject = base.uiBehaviour.m_ExRewardPool.FetchGameObject(false);
					XSingleton<XItemDrawerMgr>.singleton.normalItemDrawer.DrawItem(gameObject, int.Parse(array[i * 2]), int.Parse(array[i * 2 + 1]), false);
					XSingleton<XItemDrawerMgr>.singleton.normalItemDrawer.OpenClickShowTooltipEvent(gameObject, int.Parse(array[i * 2]));
					IXUISprite ixuisprite = gameObject.GetComponent("XUISprite") as IXUISprite;
					gameObject.transform.localPosition = new Vector3((float)(i * ixuisprite.spriteWidth), 0f, 0f);
				}
			}
		}

		private void _AutoRefresh(object param)
		{
			bool flag = base.IsVisible();
			if (flag)
			{
				this._doc.ReqGetShowInfo();
				this._DataTimerID = XSingleton<XTimerMgr>.singleton.SetTimer(3.1f, new XTimerMgr.ElapsedEventHandler(this._AutoRefresh), null);
			}
		}
	}
}