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

namespace XMainClient
{
	internal class LevelRewardPVPHandler : DlgHandlerBase
	{
		protected override string FileName
		{
			get
			{
				return "Battle/LevelReward/LevelRewardPVPFrame";
			}
		}

		private XLevelRewardDocument doc = null;

		private XUIPool m_item_pool = new XUIPool(XSingleton<XGameUI>.singleton.m_uiTool);

		private Transform m_win;

		private Transform m_lose;

		private Transform m_draw;

		private IXUIButton m_battle_data_button;

		private IXUIButton m_return_button;

		private IXUILabel m_watch;

		private IXUILabel m_like;

		private XUIPool m_team1_pool = new XUIPool(XSingleton<XGameUI>.singleton.m_uiTool);

		private XUIPool m_team2_pool = new XUIPool(XSingleton<XGameUI>.singleton.m_uiTool);

		private Transform m_pvp_data_frame;

		private XUIPool m_battle_data_pool = new XUIPool(XSingleton<XGameUI>.singleton.m_uiTool);

		private IXUIButton m_battle_data_close_button;

		protected override void Init()
		{
			base.Init();
			this.doc = XDocuments.GetSpecificDocument<XLevelRewardDocument>(XLevelRewardDocument.uuID);
			this.InitUI();
			this.InitDetailUI();
		}

		private void InitUI()
		{
			Transform transform = base.PanelObject.transform.Find("ItemList/ItemTpl");
			this.m_item_pool.SetupPool(transform.parent.gameObject, transform.gameObject, 4u, true);
			this.m_win = base.PanelObject.transform.Find("Win");
			this.m_lose = base.PanelObject.transform.Find("Lose");
			this.m_draw = base.PanelObject.transform.Find("Draw");
			this.m_battle_data_button = (base.PanelObject.transform.Find("BattleData").GetComponent("XUIButton") as IXUIButton);
			this.m_return_button = (base.PanelObject.transform.Find("Return").GetComponent("XUIButton") as IXUIButton);
			transform = base.PanelObject.transform.Find("Team1/DetailTpl");
			this.m_team1_pool.SetupPool(transform.parent.gameObject, transform.gameObject, 4u, true);
			transform = base.PanelObject.transform.Find("Team2/DetailTpl");
			this.m_team2_pool.SetupPool(transform.parent.gameObject, transform.gameObject, 4u, true);
		}

		private void InitDetailUI()
		{
			this.m_pvp_data_frame = base.PanelObject.transform.Find("PVPDataFrame");
			Transform transform = this.m_pvp_data_frame.Find("Panel/MemberTpl");
			this.m_battle_data_pool.SetupPool(transform.parent.gameObject, transform.gameObject, 8u, false);
			this.m_battle_data_close_button = (this.m_pvp_data_frame.Find("Close").GetComponent("XUIButton") as IXUIButton);
			this.m_watch = (this.m_pvp_data_frame.transform.Find("Watch").GetComponent("XUILabel") as IXUILabel);
			this.m_like = (this.m_pvp_data_frame.transform.Find("Like").GetComponent("XUILabel") as IXUILabel);
		}

		public override void RegisterEvent()
		{
			base.RegisterEvent();
			this.m_battle_data_button.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnBattleDataButtonClicked));
			this.m_return_button.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnReturnButtonClicked));
			this.m_battle_data_close_button.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnDetailCloseButtonClicked));
		}

		private bool OnBattleDataButtonClicked(IXUIButton button)
		{
			this.m_pvp_data_frame.gameObject.SetActive(true);
			return true;
		}

		private bool OnReturnButtonClicked(IXUIButton button)
		{
			this.doc.SendLeaveScene();
			return true;
		}

		private bool OnDetailCloseButtonClicked(IXUIButton button)
		{
			this.m_pvp_data_frame.gameObject.SetActive(false);
			return true;
		}

		private void OnAddFriendClick(IXUISprite sp)
		{
			DlgBase<XFriendsView, XFriendsBehaviour>.singleton.AddFriendById(sp.ID);
		}

		private void OnAddOtherServerFriendClick(IXUISprite sp)
		{
			XSingleton<UiUtility>.singleton.ShowSystemTip(XSingleton<XStringTable>.singleton.GetString("ADD_OTHER_SERVER_FRIEND"), "fece00");
		}

		protected override void OnShow()
		{
			base.OnShow();
			this.OnShowUI();
			this.SetupBattleDataUI();
		}

		private void OnShowUI()
		{
			this.m_pvp_data_frame.gameObject.SetActive(false);
			this.m_win.gameObject.SetActive(this.doc.PvpBattleData.PVPResult == 1);
			this.m_lose.gameObject.SetActive(this.doc.PvpBattleData.PVPResult == 2);
			this.m_draw.gameObject.SetActive(this.doc.PvpBattleData.PVPResult == 3);
			this.m_team1_pool.ReturnAll(false);
			for (int i = 0; i < this.doc.PvpBattleData.Team1Data.Count; i++)
			{
				GameObject gameObject = this.m_team1_pool.FetchGameObject(false);
				this.SetupDetailUI(gameObject, this.doc.PvpBattleData.Team1Data[i]);
				gameObject.transform.localPosition = this.m_team1_pool.TplPos - new Vector3(0f, (float)(this.m_team1_pool.TplHeight * i));
			}
			this.m_team2_pool.ReturnAll(false);
			for (int j = 0; j < this.doc.PvpBattleData.Team2Data.Count; j++)
			{
				GameObject gameObject2 = this.m_team2_pool.FetchGameObject(false);
				this.SetupDetailUI(gameObject2, this.doc.PvpBattleData.Team2Data[j]);
				gameObject2.transform.localPosition = this.m_team2_pool.TplPos - new Vector3(0f, (float)(this.m_team2_pool.TplHeight * j));
			}
			this.m_item_pool.ReturnAll(false);
			int num = this.doc.PvpBattleData.DayJoinReward.Count + this.doc.PvpBattleData.WinReward.Count;
			Vector3 vector = this.m_item_pool.TplPos + new Vector3(0.5f * (float)(1 - num) * (float)this.m_item_pool.TplWidth, 0f);
			for (int k = 0; k < this.doc.PvpBattleData.DayJoinReward.Count; k++)
			{
				GameObject gameObject3 = this.m_item_pool.FetchGameObject(false);
				IXUILabel ixuilabel = gameObject3.transform.Find("Day").GetComponent("XUILabel") as IXUILabel;
				XSingleton<XItemDrawerMgr>.singleton.normalItemDrawer.DrawItem(gameObject3, (int)this.doc.PvpBattleData.DayJoinReward[k].itemID, (int)this.doc.PvpBattleData.DayJoinReward[k].itemCount, false);
				ixuilabel.Alpha = 1f;
				gameObject3.transform.localPosition = vector;
				vector += new Vector3((float)this.m_item_pool.TplWidth, 0f);
			}
			for (int l = 0; l < this.doc.PvpBattleData.WinReward.Count; l++)
			{
				GameObject gameObject4 = this.m_item_pool.FetchGameObject(false);
				IXUILabel ixuilabel2 = gameObject4.transform.Find("Day").GetComponent("XUILabel") as IXUILabel;
				XSingleton<XItemDrawerMgr>.singleton.normalItemDrawer.DrawItem(gameObject4, (int)this.doc.PvpBattleData.WinReward[l].itemID, (int)this.doc.PvpBattleData.WinReward[l].itemCount, false);
				ixuilabel2.Alpha = 0f;
				gameObject4.transform.localPosition = vector;
				vector += new Vector3((float)this.m_item_pool.TplWidth, 0f);
			}
		}

		private void SetupDetailUI(GameObject go, XLevelRewardDocument.PVPRoleInfo data)
		{
			IXUISprite ixuisprite = go.transform.Find("Avatar").GetComponent("XUISprite") as IXUISprite;
			IXUISprite ixuisprite2 = go.transform.Find("MVP").GetComponent("XUISprite") as IXUISprite;
			IXUILabelSymbol ixuilabelSymbol = go.transform.Find("Name").GetComponent("XUILabelSymbol") as IXUILabelSymbol;
			IXUILabel ixuilabel = go.transform.Find("Level").GetComponent("XUILabel") as IXUILabel;
			IXUILabel ixuilabel2 = go.transform.Find("Kill").GetComponent("XUILabel") as IXUILabel;
			IXUILabel ixuilabel3 = go.transform.Find("Death").GetComponent("XUILabel") as IXUILabel;
			IXUISprite ixuisprite3 = go.transform.Find("AddFriend").GetComponent("XUISprite") as IXUISprite;
			ixuisprite.SetSprite(XSingleton<XProfessionSkillMgr>.singleton.GetProfHeadIcon(data.Prof));
			ixuisprite2.SetAlpha((float)(data.IsMvp ? 1 : 0));
			ixuilabelSymbol.InputText = XMilitaryRankDocument.GetMilitaryRankWithFormat(data.militaryRank, data.Name, true);
			ixuilabel.SetText(string.Format("Lv.{0}", data.Level.ToString()));
			ixuilabel2.SetText(data.KillCount.ToString());
			ixuilabel3.SetText(data.DeathCount.ToString());
			ixuisprite3.ID = data.uID;
			bool flag = data.uID == XSingleton<XAttributeMgr>.singleton.XPlayerData.RoleID || DlgBase<XFriendsView, XFriendsBehaviour>.singleton.IsMyFriend(ixuisprite3.ID);
			if (flag)
			{
				ixuisprite3.SetVisible(false);
			}
			else
			{
				bool flag2 = XSingleton<XClientNetwork>.singleton.ServerID == data.ServerID;
				if (flag2)
				{
					ixuisprite3.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnAddFriendClick));
				}
				else
				{
					ixuisprite3.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnAddOtherServerFriendClick));
				}
			}
		}

		private void SetupBattleDataUI()
		{
			bool flag = XSpectateSceneDocument.WhetherWathchNumShow((int)this.doc.WatchCount, (int)this.doc.LikeCount, (int)this.doc.CurrentStage);
			if (flag)
			{
				this.m_watch.SetVisible(true);
				this.m_like.SetVisible(true);
				this.m_watch.SetText(this.doc.WatchCount.ToString());
				this.m_like.SetText(this.doc.LikeCount.ToString());
			}
			else
			{
				this.m_watch.SetVisible(false);
				this.m_like.SetVisible(false);
			}
			this.m_battle_data_pool.ReturnAll(false);
			Vector3 vector = this.m_battle_data_pool.TplPos;
			for (int i = 0; i < this.doc.PvpBattleData.Team1Data.Count; i++)
			{
				GameObject gameObject = this.m_battle_data_pool.FetchGameObject(false);
				this.SetupBattleDataDetailUI(gameObject, this.doc.PvpBattleData.Team1Data[i], true);
				gameObject.transform.localPosition = vector;
				vector += new Vector3(0f, (float)(-(float)this.m_battle_data_pool.TplHeight));
			}
			for (int j = 0; j < this.doc.PvpBattleData.Team2Data.Count; j++)
			{
				GameObject gameObject2 = this.m_battle_data_pool.FetchGameObject(false);
				this.SetupBattleDataDetailUI(gameObject2, this.doc.PvpBattleData.Team2Data[j], false);
				gameObject2.transform.localPosition = vector;
				vector += new Vector3(0f, (float)(-(float)this.m_battle_data_pool.TplHeight));
			}
		}

		private void SetupBattleDataDetailUI(GameObject go, XLevelRewardDocument.PVPRoleInfo data, bool isteam1)
		{
			IXUISprite ixuisprite = go.transform.Find("Detail/Avatar").GetComponent("XUISprite") as IXUISprite;
			IXUILabel ixuilabel = go.transform.Find("Detail/Name").GetComponent("XUILabel") as IXUILabel;
			Transform transform = go.transform.Find("Detail/Team1");
			Transform transform2 = go.transform.Find("Detail/Team2");
			IXUILabel ixuilabel2 = go.transform.Find("KillTotal").GetComponent("XUILabel") as IXUILabel;
			IXUILabel ixuilabel3 = go.transform.Find("MaxKill").GetComponent("XUILabel") as IXUILabel;
			IXUILabel ixuilabel4 = go.transform.Find("DeathCount").GetComponent("XUILabel") as IXUILabel;
			IXUILabel ixuilabel5 = go.transform.Find("DamageTotal").GetComponent("XUILabel") as IXUILabel;
			IXUILabel ixuilabel6 = go.transform.Find("HealTotal").GetComponent("XUILabel") as IXUILabel;
			ixuisprite.SetSprite(XSingleton<XProfessionSkillMgr>.singleton.GetProfHeadIcon(data.Prof));
			ixuilabel.SetText(data.Name);
			transform.gameObject.SetActive(isteam1);
			transform2.gameObject.SetActive(!isteam1);
			ixuilabel2.SetText(data.KillCount.ToString());
			ixuilabel3.SetText(data.MaxKillCount.ToString());
			ixuilabel4.SetText(data.DeathCount.ToString());
			ixuilabel5.SetText(XSingleton<UiUtility>.singleton.NumberFormat(data.Damage));
			ixuilabel6.SetText(XSingleton<UiUtility>.singleton.NumberFormat(data.Heal));
		}
	}
}