summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/UI/GuildMiniReportHandler.cs
blob: 6a793bd1a0da290bb2c56f8b3c23ac5d664a6ce1 (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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
using System;
using System.Collections.Generic;
using KKSG;
using UILib;
using UnityEngine;
using XMainClient.UI.UICommon;
using XUtliPoolLib;

namespace XMainClient.UI
{
	internal class GuildMiniReportHandler : DlgHandlerBase
	{
		protected override string FileName
		{
			get
			{
				return "Battle/BattleMiniReportDlg";
			}
		}

		public readonly int max_count = 40;

		public static List<ReportMsg> msgs = new List<ReportMsg>();

		public string lastCahceMsg = string.Empty;

		public ILoopScrollView loopScrool;

		public IXUIButton m_btnReport;

		public IXUIButton m_btnHelp;

		public GameObject m_objpreparing;

		public IXUITweenTool m_tween;

		private Vector3 infoDis;

		public XUIPool m_ShowIntoPool = new XUIPool(XSingleton<XGameUI>.singleton.m_uiTool);

		public IXUILabel[] m_Killer = new IXUILabel[XBattleCaptainPVPDocument.GAME_INFO];

		public IXUILabel[] m_Dead = new IXUILabel[XBattleCaptainPVPDocument.GAME_INFO];

		public IXUISprite[] m_InfoIcon = new IXUISprite[XBattleCaptainPVPDocument.GAME_INFO];

		public Transform m_objMyinfo;

		public IXUILabel m_lblRank;

		public IXUILabel m_lblAttack;

		public IXUILabel m_lblAccupy;

		private XGuildTerritoryDocument _doc;

		private bool isopen = true;

		private Vector3 NoVisible = new Vector3(2000f, 0f, 0f);

		protected override void Init()
		{
			base.Init();
			this._doc = XDocuments.GetSpecificDocument<XGuildTerritoryDocument>(XGuildTerritoryDocument.uuID);
			this.m_btnReport = (base.transform.Find("Bg/Report").GetComponent("XUIButton") as IXUIButton);
			this.m_btnHelp = (base.transform.Find("Bg/help").GetComponent("XUIButton") as IXUIButton);
			this.loopScrool = (base.transform.Find("Bg/items").GetComponent("LoopScrollView") as ILoopScrollView);
			this.m_objpreparing = base.transform.Find("Bg/Preparing").gameObject;
			this.m_tween = (base.transform.Find("Bg/BeginFrame").GetComponent("XUIPlayTween") as IXUITweenTool);
			Transform transform = base.transform.Find("Bg/buffs/InfoTpl");
			this.m_ShowIntoPool.SetupPool(transform.parent.gameObject, transform.gameObject, 4u, false);
			this.m_ShowIntoPool.FakeReturnAll();
			int num = 0;
			while ((long)num < (long)((ulong)XGuildTerritoryDocument.GAME_INFO))
			{
				GameObject gameObject = this.m_ShowIntoPool.FetchGameObject(false);
				IXUISprite ixuisprite = gameObject.GetComponent("XUISprite") as IXUISprite;
				this.infoDis = new Vector3(0f, (float)(-(float)ixuisprite.spriteHeight), 0f);
				gameObject.transform.localPosition = this.infoDis * (float)num;
				this.m_Killer[num] = (gameObject.transform.Find("killer").GetComponent("XUILabel") as IXUILabel);
				this.m_Dead[num] = (gameObject.transform.Find("dead").GetComponent("XUILabel") as IXUILabel);
				this.m_InfoIcon[num] = (gameObject.transform.Find("icon").GetComponent("XUISprite") as IXUISprite);
				num++;
			}
			this.m_ShowIntoPool.ActualReturnAll(false);
			this.m_objMyinfo = base.transform.Find("Bg/MyInfo");
			this.m_lblRank = (this.m_objMyinfo.Find("Label_rank").GetComponent("XUILabel") as IXUILabel);
			this.m_lblAttack = (this.m_objMyinfo.Find("Label_attack").GetComponent("XUILabel") as IXUILabel);
			this.m_lblAccupy = (this.m_objMyinfo.Find("Label_accupy").GetComponent("XUILabel") as IXUILabel);
			this.m_objpreparing.SetActive(false);
			this.m_tween.gameObject.SetActive(false);
			this.m_objMyinfo.gameObject.SetActive(XSingleton<XScene>.singleton.SceneType == SceneType.SCENE_CASTLE_FIGHT);
			GameObject tpl = this.loopScrool.GetTpl();
			bool flag = tpl != null && tpl.GetComponent<GuildMiniReportItem>() == null;
			if (flag)
			{
				tpl.AddComponent<GuildMiniReportItem>();
			}
			bool flag2 = XSingleton<XScene>.singleton.SceneType != SceneType.SCENE_CASTLE_WAIT && XSingleton<XScene>.singleton.SceneType != SceneType.SCENE_CASTLE_FIGHT;
			if (flag2)
			{
				GuildMiniReportHandler.msgs.Clear();
			}
		}

		public override void RegisterEvent()
		{
			base.RegisterEvent();
			this.m_btnReport.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnReportClick));
			this.m_btnHelp.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnHelpClick));
		}

		protected override void OnShow()
		{
			base.OnShow();
			this._doc.qInfo.Clear();
			this.ShowList();
			this.ShowBuffs();
		}

		public void Push(GCFG2CSynType type, GCFG2CSynPara para)
		{
			string text = string.Empty;
			switch (type)
			{
			case GCFG2CSynType.GCF_G2C_SYN_MUL_POINT:
			{
				TerritoryBattle.RowData byID = XGuildTerritoryDocument.mGuildTerritoryList.GetByID(para.territoryid);
				GuildTransfer.RowData bySceneID = this.GetBySceneID(para.mapid);
				bool flag = byID == null;
				if (flag)
				{
					XSingleton<XDebug>.singleton.AddErrorLog("territory id: " + para.territoryid, null, null, null, null, null);
				}
				else
				{
					bool flag2 = byID.territorylevel == 1u;
					if (flag2)
					{
						text = XStringDefineProxy.GetString("TERRITORY_TYPE3", new object[]
						{
							bySceneID.name,
							byID.territoryname,
							para.mulpoint
						});
					}
					else
					{
						bool flag3 = byID.territorylevel == 2u;
						if (flag3)
						{
							text = XStringDefineProxy.GetString("TERRITORY_TYPE4", new object[]
							{
								bySceneID.name,
								byID.territoryname,
								para.mulpoint
							});
						}
						else
						{
							bool flag4 = byID.territorylevel == 3u;
							if (flag4)
							{
								text = XStringDefineProxy.GetString("TERRITORY_TYPE5", new object[]
								{
									bySceneID.name,
									byID.territoryname,
									para.mulpoint
								});
							}
						}
					}
				}
				break;
			}
			case GCFG2CSynType.GCF_G2C_SYN_OCCUPY:
			{
				int num = XFastEnumIntEqualityComparer<GCFJvDianType>.ToInt(para.jvdian.type);
				XEntity entity = XSingleton<XEntityMgr>.singleton.GetEntity(para.roleid);
				bool flag5 = entity != null;
				if (flag5)
				{
					string @string = XStringDefineProxy.GetString("Territory_judian" + num);
					text = XStringDefineProxy.GetString("TERRITORY_TYPE2", new object[]
					{
						entity.Name,
						para.jvdian.guildname,
						@string
					});
				}
				else
				{
					XSingleton<XDebug>.singleton.AddWarningLog("entity is null, roleid: ", para.roleid.ToString(), null, null, null, null);
				}
				break;
			}
			}
			bool flag6 = !string.IsNullOrEmpty(text);
			if (flag6)
			{
				this.Push(text);
			}
		}

		public GuildTransfer.RowData GetBySceneID(uint sceneid)
		{
			for (int i = 0; i < XGuildTerritoryDocument.mGuildTransfer.Table.Length; i++)
			{
				bool flag = XGuildTerritoryDocument.mGuildTransfer.Table[i].sceneid == sceneid;
				if (flag)
				{
					return XGuildTerritoryDocument.mGuildTransfer.Table[i];
				}
			}
			return null;
		}

		public void Push(string content)
		{
			ReportMsg reportMsg = new ReportMsg();
			reportMsg.LoopID = XSingleton<XCommon>.singleton.XHash(content + DateTime.Now.ToString());
			reportMsg.content = content;
			GuildMiniReportHandler.msgs.Add(reportMsg);
			this.ShowList();
		}

		public void ShowPrepare(bool show)
		{
			bool flag = this.m_objpreparing != null;
			if (flag)
			{
				this.m_objpreparing.SetActive(show);
			}
			bool flag2 = this.m_objMyinfo != null;
			if (flag2)
			{
				this.m_objMyinfo.gameObject.SetActive(!show);
			}
		}

		public void ShowBegin(bool open)
		{
			bool flag = this.m_tween != null;
			if (flag)
			{
				bool flag2 = open && open != this.isopen;
				if (flag2)
				{
					this.m_tween.gameObject.SetActive(true);
					this.m_tween.ResetTween(true);
					this.m_tween.PlayTween(true, -1f);
				}
				this.isopen = open;
			}
		}

		public void ShowList()
		{
			bool flag = base.IsVisible();
			if (flag)
			{
				List<LoopItemData> list = new List<LoopItemData>();
				string b = string.Empty;
				for (int i = 0; i < GuildMiniReportHandler.msgs.Count; i++)
				{
					ReportMsg reportMsg = new ReportMsg();
					reportMsg.LoopID = XSingleton<XCommon>.singleton.XHash(GuildMiniReportHandler.msgs[i].content + i);
					reportMsg.content = GuildMiniReportHandler.msgs[i].content;
					list.Add(reportMsg);
					b = reportMsg.content;
				}
				bool flag2 = string.IsNullOrEmpty(this.lastCahceMsg) || this.lastCahceMsg != b;
				if (flag2)
				{
					this.loopScrool.Init(list, new DelegateHandler(this.RefreshItem), null, (GuildMiniReportHandler.msgs.Count < 4) ? 0 : 1, false);
				}
				bool flag3 = GuildMiniReportHandler.msgs != null && GuildMiniReportHandler.msgs.Count > 0;
				if (flag3)
				{
					int index = GuildMiniReportHandler.msgs.Count - 1;
					this.lastCahceMsg = GuildMiniReportHandler.msgs[index].content;
				}
			}
		}

		public void ShowBuffs()
		{
			bool flag = this._doc == null;
			if (flag)
			{
				this._doc = XDocuments.GetSpecificDocument<XGuildTerritoryDocument>(XGuildTerritoryDocument.uuID);
			}
			this.m_ShowIntoPool.FakeReturnAll();
			int num = 0;
			while ((long)num < (long)((ulong)XGuildTerritoryDocument.GAME_INFO))
			{
				GameObject gameObject = this.m_ShowIntoPool.FetchGameObject(false);
				bool flag2 = this._doc.qInfo.Count <= num;
				if (flag2)
				{
					gameObject.transform.localPosition = this.NoVisible;
				}
				else
				{
					gameObject.transform.localPosition = this.infoDis * (float)num;
					int num2 = 0;
					foreach (XBattleCaptainPVPDocument.KillInfo killInfo in this._doc.qInfo)
					{
						bool flag3 = num2 == num;
						if (flag3)
						{
							this.m_Killer[num].SetText(killInfo.KillName);
							this.m_Dead[num].SetText(killInfo.DeadName);
							this.m_InfoIcon[num].SetSprite("hall_zljt_0");
							break;
						}
						num2++;
					}
				}
				num++;
			}
			this.m_ShowIntoPool.ActualReturnAll(false);
		}

		private void RefreshItem(ILoopItemObject item, LoopItemData data)
		{
			ReportMsg reportMsg = data as ReportMsg;
			bool flag = reportMsg != null;
			if (flag)
			{
				GameObject obj = item.GetObj();
				bool flag2 = obj != null;
				if (flag2)
				{
					GuildMiniReportItem component = obj.GetComponent<GuildMiniReportItem>();
					bool flag3 = component != null;
					if (flag3)
					{
						component.Refresh(reportMsg.content);
					}
				}
			}
			else
			{
				XSingleton<XDebug>.singleton.AddErrorLog("GuildMiniReportItem info is null", null, null, null, null, null);
			}
		}

		private bool OnReportClick(IXUIButton btn)
		{
			DlgBase<GuildTerritoryReportDlg, GuildTerritoryBahaviour>.singleton.SetVisible(true, true);
			return true;
		}

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

		public void RefreshMyInfo(GCFRoleBrief info)
		{
			bool flag = info != null;
			if (flag)
			{
				uint rank = info.rank;
				this.m_lblRank.SetText((rank == 0u) ? "-" : rank.ToString());
				this.m_lblAttack.SetText(info.killcount.ToString());
				this.m_lblAccupy.SetText(info.occupycount.ToString());
			}
		}
	}
}