summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/UI/XTeamView.cs
blob: eb0d640e359418edd37c9178f955003f7a626326 (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
using System;
using KKSG;
using UILib;
using UnityEngine;
using XMainClient.UI.UICommon;
using XUtliPoolLib;

namespace XMainClient.UI
{
	internal class XTeamView : TabDlgBase<XTeamView>
	{
		public override string fileName
		{
			get
			{
				return "Team/TeamDlg";
			}
		}

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

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

		public XMyTeamHandler _MyTeamHandler;

		public XTeamListHandler _TeamListHandler;

		public XTeamDungeonSelectorHandler _DungeonSelectorHandler;

		public XYuyinView _yuyinHandler;

		public GameObject m_MyTeamPanel;

		public GameObject m_TeamListPanel;

		public GameObject m_DungeonSelectorPanel;

		private XTeamDocument _doc;

		private XTeamView.ShowTeamViewEventHandler mShowTeamViewEvent;

		private TeamLevelType mCurTeamLeveltype = TeamLevelType.TeamLevelNest;

		public delegate void ShowTeamViewEventHandler();

		protected override void OnLoad()
		{
			base.OnLoad();
			this.m_MyTeamPanel = base.uiBehaviour.transform.Find("Bg/MyTeamFrame").gameObject;
			this.m_MyTeamPanel.SetActive(false);
			this.m_TeamListPanel = base.uiBehaviour.transform.Find("Bg/TeamListFrame").gameObject;
			this.m_TeamListPanel.SetActive(false);
			this.m_DungeonSelectorPanel = base.uiBehaviour.transform.Find("Bg/SelectFrame").gameObject;
			this.m_DungeonSelectorPanel.SetActive(false);
			this._doc = XDocuments.GetSpecificDocument<XTeamDocument>(XTeamDocument.uuID);
		}

		protected override void OnUnload()
		{
			DlgHandlerBase.EnsureUnload<XMyTeamHandler>(ref this._MyTeamHandler);
			DlgHandlerBase.EnsureUnload<XTeamListHandler>(ref this._TeamListHandler);
			DlgHandlerBase.EnsureUnload<XTeamDungeonSelectorHandler>(ref this._DungeonSelectorHandler);
			DlgHandlerBase.EnsureUnload<XYuyinView>(ref this._yuyinHandler);
			base.OnUnload();
		}

		protected override void OnShow()
		{
			base.OnShow();
			this._doc.ReqTeamOp(TeamOperate.TEAM_QUERYCOUNT, 0UL, null, TeamMemberType.TMT_NORMAL, null);
			this._doc.ReqSceneDayCount();
			RpcC2G_GetTowerActivityTop rpc = new RpcC2G_GetTowerActivityTop();
			XSingleton<XClientNetwork>.singleton.Send(rpc);
			XDragonNestDocument specificDocument = XDocuments.GetSpecificDocument<XDragonNestDocument>(XDragonNestDocument.uuID);
			specificDocument.SendReqDragonNestInfo();
			XGuildSmallMonsterDocument specificDocument2 = XDocuments.GetSpecificDocument<XGuildSmallMonsterDocument>(XGuildSmallMonsterDocument.uuID);
			specificDocument2.SendQuerySmallMonterInfo();
			bool flag = DlgBase<ScreenShotShareView, ScreenShotShareBehaviour>.singleton.IsLoaded() && DlgBase<ScreenShotShareView, ScreenShotShareBehaviour>.singleton.IsVisible();
			if (flag)
			{
				DlgBase<ScreenShotShareView, ScreenShotShareBehaviour>.singleton.SetVisible(false, true);
			}
			DlgBase<RandomGiftView, RandomGiftBehaviour>.singleton.TryOpenUI();
		}

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

		public void RefreshYuyin(ulong uid)
		{
			bool flag = this._yuyinHandler != null;
			if (flag)
			{
				this._yuyinHandler.Refresh(YuyinIconType.Team);
			}
		}

		public void ShowTeamView()
		{
			bool flag = XSingleton<XScene>.singleton.SceneType == SceneType.SCENE_FAMILYGARDEN;
			if (flag)
			{
				XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("CurSceneCanNotCtrl"), "fece00");
			}
			else
			{
				base.Load();
				bool flag2 = !base.IsVisible();
				if (flag2)
				{
					bool bInTeam = this._doc.bInTeam;
					if (bInTeam)
					{
						base.ShowWorkGameSystem(XSysDefine.XSys_Team_MyTeam);
					}
					else
					{
						base.ShowWorkGameSystem(XSysDefine.XSys_Team_TeamList);
					}
				}
				else
				{
					bool bInTeam2 = this._doc.bInTeam;
					if (bInTeam2)
					{
						base.ShowSubGamsSystem(XSysDefine.XSys_Team_MyTeam);
					}
					else
					{
						base.ShowSubGamsSystem(XSysDefine.XSys_Team_TeamList);
					}
				}
				bool bInTeam3 = this._doc.bInTeam;
				if (bInTeam3)
				{
					this._yuyinHandler.Show(YuyinIconType.Team, 5);
					this._yuyinHandler.Show(this._doc.bInTeam);
				}
			}
		}

		public void ShowTeamViewWithMsgBox(TeamLevelType _type, XTeamView.ShowTeamViewEventHandler _cbRealShow)
		{
			int dayLeftCount = ActivityNestHandler.GetDayLeftCount();
			this.mCurTeamLeveltype = _type;
			this.mShowTeamViewEvent = _cbRealShow;
			bool flag = dayLeftCount > 0;
			if (flag)
			{
				bool flag2 = _cbRealShow != null;
				if (flag2)
				{
					_cbRealShow();
				}
			}
			else
			{
				XExpeditionDocument specificDocument = XDocuments.GetSpecificDocument<XExpeditionDocument>(XExpeditionDocument.uuID);
				int num;
				int num2;
				bool flag3 = specificDocument.CanBuy(_type, out num, out num2);
				ButtonClickEventHandler handle;
				ButtonClickEventHandler handle2;
				string @string;
				if (flag3)
				{
					handle = new ButtonClickEventHandler(this._ShowTeamViewBuyTimes);
					handle2 = new ButtonClickEventHandler(this._ShowTeamViewNotBuyTimes);
					CostInfo buyCost = specificDocument.GetBuyCost(_type);
					@string = XStringDefineProxy.GetString("NEST_NO_TIMES_NEED_BUY_MSGBOX", new object[]
					{
						XLabelSymbolHelper.FormatCostWithIcon((int)buyCost.count, buyCost.type)
					});
				}
				else
				{
					handle = new ButtonClickEventHandler(this._ShowTeamViewNotBuyTimes);
					handle2 = new ButtonClickEventHandler(this._CancelShowTeamView);
					@string = XStringDefineProxy.GetString("NEST_NO_TIMES_CANNOT_BUY_MSGBOX");
				}
				DlgBase<ModalDlg, ModalDlgBehaviour>.singleton.Load();
				DlgBase<ModalDlg, ModalDlgBehaviour>.singleton.SetSingleButtonMode(false);
				DlgBase<ModalDlg, ModalDlgBehaviour>.singleton.SetVisible(false, true);
				DlgBase<ModalDlg, ModalDlgBehaviour>.singleton.SetLabelsWithSymbols(@string, XStringDefineProxy.GetString(XStringDefine.COMMON_OK), XStringDefineProxy.GetString(XStringDefine.COMMON_CANCEL));
				DlgBase<ModalDlg, ModalDlgBehaviour>.singleton.SetModalCallback(handle, handle2);
				DlgBase<ModalDlg, ModalDlgBehaviour>.singleton.SetTweenTargetAndPlay(DlgBase<ModalDlg, ModalDlgBehaviour>.singleton.uiBehaviour.gameObject);
			}
		}

		private bool _ShowTeamViewBuyTimes(IXUIButton btn)
		{
			XExpeditionDocument specificDocument = XDocuments.GetSpecificDocument<XExpeditionDocument>(XExpeditionDocument.uuID);
			specificDocument.ReqBuyCount(this.mCurTeamLeveltype);
			this._ShowTeamViewNotBuyTimes(btn);
			return true;
		}

		private bool _ShowTeamViewNotBuyTimes(IXUIButton btn)
		{
			XSingleton<UiUtility>.singleton.CloseModalDlg();
			bool flag = this.mShowTeamViewEvent != null;
			if (flag)
			{
				this.mShowTeamViewEvent();
			}
			this.mShowTeamViewEvent = null;
			return true;
		}

		protected bool _CancelShowTeamView(IXUIButton btn)
		{
			XSingleton<UiUtility>.singleton.CloseModalDlg();
			this.mShowTeamViewEvent = null;
			return true;
		}

		public override void SetupHandlers(XSysDefine sys)
		{
			XSysDefine xsysDefine = sys;
			if (xsysDefine != XSysDefine.XSys_Team_TeamList)
			{
				if (xsysDefine != XSysDefine.XSys_Team_MyTeam)
				{
					XSingleton<XDebug>.singleton.AddErrorLog("System has not finished:", sys.ToString(), null, null, null, null);
				}
				else
				{
					base._AddActiveHandler(DlgHandlerBase.EnsureCreate<XMyTeamHandler>(ref this._MyTeamHandler, this.m_MyTeamPanel, this, true));
					base._AddActiveHandler(DlgHandlerBase.EnsureCreate<XTeamDungeonSelectorHandler>(ref this._DungeonSelectorHandler, this.m_DungeonSelectorPanel, this, true));
					base._AddActiveHandler(DlgHandlerBase.EnsureCreate<XYuyinView>(ref this._yuyinHandler, base.uiBehaviour.transform, true, this));
				}
			}
			else
			{
				base._AddActiveHandler(DlgHandlerBase.EnsureCreate<XTeamListHandler>(ref this._TeamListHandler, this.m_TeamListPanel, this, true));
				base._AddActiveHandler(DlgHandlerBase.EnsureCreate<XTeamDungeonSelectorHandler>(ref this._DungeonSelectorHandler, this.m_DungeonSelectorPanel, this, true));
			}
		}

		public override void StackRefresh()
		{
			bool flag = (this._doc.bInTeam && this.mCurrentSys != XSysDefine.XSys_Team_MyTeam) || (!this._doc.bInTeam && this.mCurrentSys != XSysDefine.XSys_Team_TeamList);
			if (flag)
			{
				this.ShowTeamView();
			}
			base.StackRefresh();
		}

		public static void TryJoinTeam(int teamID, bool bHasPwd)
		{
			XTeamDocument specificDocument = XDocuments.GetSpecificDocument<XTeamDocument>(XTeamDocument.uuID);
			if (bHasPwd)
			{
				DlgBase<XTeamInputPasswordView, XTeamInputPasswordBehaviour>.singleton.TeamID = teamID;
				DlgBase<XTeamInputPasswordView, XTeamInputPasswordBehaviour>.singleton.SetVisibleWithAnimation(true, null);
			}
			else
			{
				specificDocument.ReqTeamOp(TeamOperate.TEAM_JOIN, (ulong)((long)teamID), null, TeamMemberType.TMT_NORMAL, null);
			}
		}

		public static void SetTeamRelationUI(Transform t, XTeamRelation relation, bool bOnlyOne, XTeamRelation.Relation targetRelation = XTeamRelation.Relation.TR_NONE)
		{
			bool flag = t == null;
			if (!flag)
			{
				IXUIList ixuilist = t.GetComponent("XUIList") as IXUIList;
				Transform transform = t.Find("Guild");
				Transform transform2 = t.Find("Friend");
				Transform transform3 = t.Find("Partner");
				bool flag2 = true;
				bool flag3 = relation == null;
				if (!flag3)
				{
					bool flag4 = targetRelation > XTeamRelation.Relation.TR_NONE;
					if (flag4)
					{
						bool flag5 = !relation.HasRelation(targetRelation);
						if (flag5)
						{
							goto IL_181;
						}
						XTeamRelation.Relation relation2 = relation.ActualRelation & targetRelation;
						transform.gameObject.SetActive(XTeamRelation.HasRelation(relation2, XTeamRelation.Relation.TR_GUILD));
						transform2.gameObject.SetActive(XTeamRelation.HasRelation(relation2, XTeamRelation.Relation.TR_FRIEND) && !XTeamRelation.HasRelation(relation2, XTeamRelation.Relation.TR_PARTNER));
						transform3.gameObject.SetActive(XTeamRelation.HasRelation(relation2, XTeamRelation.Relation.TR_PARTNER));
					}
					else
					{
						bool flag6 = !bOnlyOne;
						if (flag6)
						{
							transform.gameObject.SetActive(XTeamRelation.HasRelation(relation.FinalRelation2, XTeamRelation.Relation.TR_GUILD));
							transform2.gameObject.SetActive(XTeamRelation.HasRelation(relation.FinalRelation2, XTeamRelation.Relation.TR_FRIEND));
							transform3.gameObject.SetActive(XTeamRelation.HasRelation(relation.FinalRelation, XTeamRelation.Relation.TR_PARTNER));
						}
						else
						{
							transform.gameObject.SetActive(relation.FinalRelation == XTeamRelation.Relation.TR_GUILD);
							transform2.gameObject.SetActive(relation.FinalRelation == XTeamRelation.Relation.TR_FRIEND);
							transform3.gameObject.SetActive(relation.FinalRelation == XTeamRelation.Relation.TR_PARTNER);
						}
					}
					flag2 = false;
				}
				IL_181:
				bool flag7 = flag2;
				if (flag7)
				{
					transform.gameObject.SetActive(false);
					transform2.gameObject.SetActive(false);
					transform3.gameObject.SetActive(false);
				}
				bool flag8 = ixuilist != null;
				if (flag8)
				{
					ixuilist.Refresh();
				}
			}
		}
	}
}