summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/Team/XTeamPartnerBonusHandler.cs
blob: 06ae58c81f54098fb9312196b6ad1f04cba005f3 (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
using System;
using System.Collections.Generic;
using UILib;
using UnityEngine;
using XMainClient.UI;
using XMainClient.UI.UICommon;
using XUtliPoolLib;

namespace XMainClient
{
	internal class XTeamPartnerBonusHandler : DlgHandlerBase
	{
		private GameObject m_CurrentBuff;

		private GameObject m_DisableBuff;

		private IXUILabel[] m_Levels;

		private List<int> m_QualityLevels;

		private IXUILabel m_DisableLevel;

		private GameObject m_Active;

		private GameObject m_Disactive;

		private GameObject m_PopActive;

		private GameObject m_PopDisactive;

		private IXUISprite m_BtnOpenPop;

		private GameObject m_PopPanel;

		private IXUISprite m_PopClose;

		private GameObject m_PopEmpty;

		private GameObject m_PopCurrentBuff;

		private GameObject m_PopNextBuff;

		private GameObject m_PopFinalBuff;

		private XTeamDocument _TeamDoc;

		private XDragonGuildDocument _Doc;

		private DragonGuildTable.RowData m_CurrentBuffData;

		private DragonGuildTable.RowData m_NextBuffData;

		private bool m_bFullLevel;

		private bool m_bActive;

		public bool bConsiderTeam = false;

		protected override void Init()
		{
			base.Init();
			this.m_Active = base.PanelObject.transform.Find("Active").gameObject;
			this.m_Disactive = base.PanelObject.transform.Find("Disactive").gameObject;
			this.m_CurrentBuff = this.m_Active.transform.Find("Buff").gameObject;
			this.m_DisableBuff = this.m_Disactive.transform.Find("Buff").gameObject;
			this.m_BtnOpenPop = (base.PanelObject.transform.Find("BtnOpenPop").GetComponent("XUISprite") as IXUISprite);
			this.m_PopPanel = base.PanelObject.transform.Find("FriendBonusPop").gameObject;
			this.m_PopClose = (this.m_PopPanel.transform.Find("Close").GetComponent("XUISprite") as IXUISprite);
			this.m_PopActive = this.m_PopPanel.transform.Find("Active").gameObject;
			this.m_PopDisactive = this.m_PopPanel.transform.Find("Disactive").gameObject;
			this.m_PopEmpty = this.m_PopDisactive.transform.Find("Empty").gameObject;
			IXUILabel ixuilabel = this.m_PopEmpty.transform.Find("Slogan").GetComponent("XUILabel") as IXUILabel;
			ixuilabel.SetText(XSingleton<UiUtility>.singleton.ReplaceReturn(XStringDefineProxy.GetString("TeamBonusNoPartner")));
			IXUIButton ixuibutton = this.m_PopEmpty.transform.Find("BtnPartner").GetComponent("XUIButton") as IXUIButton;
			ixuibutton.RegisterClickEventHandler(new ButtonClickEventHandler(this._OnGotoPartnerClicked));
			this.m_PopCurrentBuff = this.m_PopActive.transform.Find("CurrentBuff").gameObject;
			this.m_PopNextBuff = this.m_PopActive.transform.Find("NextBuff").gameObject;
			this.m_PopFinalBuff = this.m_PopActive.transform.Find("FinalBuff").gameObject;
			this.m_QualityLevels = XSingleton<XGlobalConfig>.singleton.GetIntList("TeamFriendDegreeBuffQuality");
			this.m_Levels = new IXUILabel[this.m_QualityLevels.Count];
			for (int i = 0; i < this.m_Levels.Length; i++)
			{
				this.m_Levels[i] = (this.m_Active.transform.Find(XSingleton<XCommon>.singleton.StringCombine("Level", i.ToString())).GetComponent("XUILabel") as IXUILabel);
			}
			this.m_DisableLevel = (this.m_Disactive.transform.Find("Level0").GetComponent("XUILabel") as IXUILabel);
			this._TeamDoc = XDocuments.GetSpecificDocument<XTeamDocument>(XTeamDocument.uuID);
			this._Doc = XDragonGuildDocument.Doc;
			this.m_PopPanel.SetActive(false);
		}

		public override void RegisterEvent()
		{
			base.RegisterEvent();
			this.m_PopClose.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this._OnPopCloseClicked));
			this.m_BtnOpenPop.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this._OnPopOpenClicked));
		}

		private void _OnPopCloseClicked(IXUISprite iSp)
		{
			this.m_PopPanel.SetActive(false);
		}

		private void _OnPopOpenClicked(IXUISprite iSp)
		{
			bool flag = this.IsHadDragonGuildMemberInTeam();
			if (!flag)
			{
				bool flag2 = !XSingleton<XGameSysMgr>.singleton.IsSystemOpened(XSysDefine.XSys_GuildCollectSummon);
				if (flag2)
				{
					OpenSystemTable.RowData sysData = XSingleton<XGameSysMgr>.singleton.GetSysData(XFastEnumIntEqualityComparer<XSysDefine>.ToInt(XSysDefine.XSys_GuildCollectSummon));
					bool flag3 = sysData != null;
					if (flag3)
					{
						XSingleton<UiUtility>.singleton.ShowSystemTip(string.Format(XStringDefineProxy.GetString("LEVEL_REQUIRE_LEVEL"), sysData.PlayerLevel), "fece00");
					}
				}
				else
				{
					this.m_PopPanel.SetActive(true);
					this.RefreshPop();
				}
			}
		}

		public void RefreshCurrent()
		{
			this.m_CurrentBuffData = null;
			bool bActive = this.IsHadDragonGuildMemberInTeam();
			uint level = this._Doc.BaseData.level;
			DragonGuildTable.RowData bylevel = XDragonGuildDocument.DragonGuildBuffTable.GetBylevel(level);
			bool flag = bylevel != null;
			if (flag)
			{
				this.m_CurrentBuffData = bylevel;
				this.m_bFullLevel = ((ulong)level == (ulong)((long)XDragonGuildDocument.DragonGuildBuffTable.Table.Length));
			}
			this.m_bActive = bActive;
			this.m_NextBuffData = bylevel;
			bool flag2 = this.m_CurrentBuffData == null;
			if (flag2)
			{
				this.m_CurrentBuffData = this.m_NextBuffData;
			}
			this.m_Active.SetActive(this.m_bActive);
			this.m_Disactive.SetActive(!this.m_bActive);
			bool flag3 = this.m_CurrentBuffData != null;
			if (flag3)
			{
				bool bActive2 = this.m_bActive;
				if (bActive2)
				{
					int num = 0;
					for (int i = this.m_QualityLevels.Count - 1; i >= 0; i--)
					{
						bool flag4 = (ulong)this.m_CurrentBuffData.level >= (ulong)((long)this.m_QualityLevels[i]);
						if (flag4)
						{
							num = i;
							break;
						}
					}
					for (int j = 0; j < this.m_Levels.Length; j++)
					{
						this.m_Levels[j].SetVisible(j == num);
					}
					this.m_Levels[num].SetText(this.m_CurrentBuffData.level.ToString());
					this._RefreshBuff(this.m_CurrentBuff, this.m_CurrentBuffData);
				}
				else
				{
					this.m_DisableLevel.SetText(this.m_CurrentBuffData.level.ToString());
					this._RefreshBuff(this.m_DisableBuff, this.m_CurrentBuffData);
				}
			}
			else
			{
				bool flag5 = this.m_NextBuffData != null;
				if (flag5)
				{
					this.m_DisableLevel.SetText(this.m_NextBuffData.level.ToString());
					this._RefreshBuff(this.m_DisableBuff, this.m_NextBuffData);
				}
			}
		}

		private bool IsHadDragonGuildMemberInTeam()
		{
			bool result = false;
			bool flag = this.bConsiderTeam;
			if (flag)
			{
				bool flag2 = this._TeamDoc.bInTeam && this._Doc.IsInDragonGuild();
				if (flag2)
				{
					for (int i = 0; i < this._TeamDoc.MyTeam.members.Count; i++)
					{
						XTeamMember xteamMember = this._TeamDoc.MyTeam.members[i];
						bool flag3 = xteamMember == this._TeamDoc.MyTeam.myData;
						if (!flag3)
						{
							bool flag4 = this._Doc.IsMyDragonGuildMember(xteamMember.dragonGuildID);
							if (flag4)
							{
								result = true;
								break;
							}
						}
					}
				}
			}
			else
			{
				result = true;
			}
			return result;
		}

		public void RefreshPop()
		{
			bool flag = !this.m_PopPanel.activeSelf;
			if (!flag)
			{
				this.m_PopActive.SetActive(this.m_bActive);
				this.m_PopDisactive.SetActive(!this.m_bActive);
				bool flag2 = !this.m_bActive;
				if (!flag2)
				{
					bool bFullLevel = this.m_bFullLevel;
					if (bFullLevel)
					{
						this.m_PopFinalBuff.SetActive(true);
						this.m_PopCurrentBuff.SetActive(false);
						this.m_PopNextBuff.SetActive(false);
						this._RefreshDetailInfo(this.m_PopFinalBuff, this.m_CurrentBuffData);
					}
					else
					{
						this.m_PopFinalBuff.SetActive(false);
						this.m_PopCurrentBuff.SetActive(true);
						this.m_PopNextBuff.SetActive(true);
						this._RefreshDetailInfo(this.m_PopCurrentBuff, this.m_CurrentBuffData);
						this._RefreshDetailInfo(this.m_PopNextBuff, this.m_NextBuffData);
					}
				}
			}
		}

		public override void RefreshData()
		{
			base.RefreshData();
			this.RefreshCurrent();
			this.RefreshPop();
		}

		private void _RefreshDetailInfo(GameObject go, DragonGuildTable.RowData rowData)
		{
			IXUILabel ixuilabel = go.transform.Find("Level").GetComponent("XUILabel") as IXUILabel;
			IXUILabel ixuilabel2 = go.transform.Find("Value").GetComponent("XUILabel") as IXUILabel;
			GameObject gameObject = go.transform.Find("Buff").gameObject;
			ixuilabel.SetText(rowData.level.ToString());
			this._RefreshBuff(gameObject, rowData);
		}

		private void _RefreshBuff(GameObject go, DragonGuildTable.RowData rowData)
		{
			IXUILabel ixuilabel = go.GetComponent("XUILabel") as IXUILabel;
			IXUILabel ixuilabel2 = go.transform.Find("Value").GetComponent("XUILabel") as IXUILabel;
			BuffTable.RowData buffData = XSingleton<XBuffTemplateManager>.singleton.GetBuffData(rowData.buf[0], rowData.buf[1]);
			bool flag = buffData == null;
			if (flag)
			{
				ixuilabel.SetText(string.Empty);
				ixuilabel2.SetText(string.Empty);
			}
			else
			{
				ixuilabel.SetText(buffData.BuffName);
				ixuilabel2.SetText(string.Empty);
			}
		}

		private bool _OnGotoPartnerClicked(IXUIButton btn)
		{
			DlgBase<XFriendsView, XFriendsBehaviour>.singleton.ShowTab(XSysDefine.XSys_GuildCollectSummon);
			return true;
		}
	}
}