summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/ActivityExpeditionHandler.cs
blob: 6fc49249c8f3172af5c33cf7dd0b4f45bbe02681 (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
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 ActivityExpeditionHandler : DlgHandlerBase
	{
		public XUIPool m_ExpediPool = new XUIPool(XSingleton<XGameUI>.singleton.m_uiTool);

		private XExpeditionDocument _doc;

		private XTeamDocument _TeamDoc;

		protected override void Init()
		{
			base.Init();
			Transform transform = base.PanelObject.transform.Find("Panel/ExpediTpl");
			this.m_ExpediPool.SetupPool(transform.parent.gameObject, transform.gameObject, 3u, false);
			this._doc = XDocuments.GetSpecificDocument<XExpeditionDocument>(XExpeditionDocument.uuID);
			this._doc.ExpeditionView = this;
			this._TeamDoc = XDocuments.GetSpecificDocument<XTeamDocument>(XTeamDocument.uuID);
		}

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

		protected override void OnHide()
		{
			this.m_ExpediPool.ReturnAll(false);
			base.OnHide();
		}

		public override void OnUnload()
		{
			this._doc.ExpeditionView = null;
			base.OnUnload();
		}

		public void ShowExpediFrame()
		{
			this.m_ExpediPool.ReturnAll(false);
			Vector3 localPosition = this.m_ExpediPool._tpl.transform.localPosition;
			float num = (float)this.m_ExpediPool.TplWidth;
			List<ExpeditionTable.RowData> expeditionList = this._doc.GetExpeditionList(TeamLevelType.TeamLevelExpdition);
			XPlayer player = XSingleton<XEntityMgr>.singleton.Player;
			uint level = player.Attributes.Level;
			int num2 = 0;
			foreach (ExpeditionTable.RowData rowData in expeditionList)
			{
				GameObject gameObject = this.m_ExpediPool.FetchGameObject(false);
				gameObject.transform.localPosition = localPosition + new Vector3(num * (float)num2++, 0f, 0f);
				IXUILabel ixuilabel = gameObject.transform.Find("Name").GetComponent("XUILabel") as IXUILabel;
				IXUITexture ixuitexture = gameObject.transform.Find("ExpediBg").GetComponent("XUITexture") as IXUITexture;
				IXUIButton ixuibutton = gameObject.transform.Find("Do").GetComponent("XUIButton") as IXUIButton;
				IXUILabel ixuilabel2 = ixuibutton.gameObject.transform.Find("Text").GetComponent("XUILabel") as IXUILabel;
				ixuibutton.ID = (ulong)((long)rowData.DNExpeditionID);
				IXUISprite ixuisprite = gameObject.transform.GetComponent("XUISprite") as IXUISprite;
				ixuisprite.ID = ixuibutton.ID;
				ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnExpediBgClicked));
				ixuilabel.SetText(rowData.DNExpeditionName);
				bool flag = rowData.ViewableDropList != null;
				if (flag)
				{
					for (int i = 0; i < 2; i++)
					{
						GameObject gameObject2 = gameObject.transform.Find("Item" + (i + 1)).gameObject;
						bool flag2 = i >= rowData.ViewableDropList.Length;
						if (flag2)
						{
							XSingleton<XItemDrawerMgr>.singleton.normalItemDrawer.DrawItem(gameObject2, 0, 0, false);
						}
						else
						{
							IXUISprite ixuisprite2 = gameObject2.transform.Find("Icon").GetComponent("XUISprite") as IXUISprite;
							ixuisprite2.ID = (ulong)rowData.ViewableDropList[i];
							XSingleton<XItemDrawerMgr>.singleton.normalItemDrawer.DrawItem(gameObject2, (int)ixuisprite2.ID, 0, false);
							ixuisprite2.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(XSingleton<UiUtility>.singleton.OnItemClick));
						}
					}
				}
				ixuibutton.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnDoClicked));
				bool flag3 = this._TeamDoc.MyTeam != null && (ulong)this._TeamDoc.MyTeam.teamBrief.dungeonID == (ulong)((long)rowData.DNExpeditionID);
				if (flag3)
				{
					ixuilabel2.SetText(XStringDefineProxy.GetString("TEAM_LEAVE"));
				}
				else
				{
					ixuilabel2.SetText(XStringDefineProxy.GetString("TEAM_ENTER"));
				}
				bool flag4 = (ulong)level >= (ulong)((long)rowData.RequiredLevel);
				if (flag4)
				{
					ixuibutton.SetEnable(true, false);
				}
				else
				{
					ixuibutton.SetEnable(false, false);
					ixuilabel2.SetText(XStringDefineProxy.GetString("EXPEDITION_REQUIRED_LEVEL", new object[]
					{
						rowData.RequiredLevel
					}));
				}
			}
		}

		protected void OnExpediBgClicked(IXUISprite sp)
		{
			this.ShowTeamView((uint)sp.ID);
		}

		protected bool OnDoClicked(IXUIButton btn)
		{
			bool flag = this._TeamDoc.MyTeam != null && (ulong)this._TeamDoc.MyTeam.teamBrief.dungeonID == btn.ID;
			bool result;
			if (flag)
			{
				this._TeamDoc.ReqTeamOp(TeamOperate.TEAM_LEAVE, 0UL, null, TeamMemberType.TMT_NORMAL, null);
				result = true;
			}
			else
			{
				this.ShowTeamView((uint)btn.ID);
				result = true;
			}
			return result;
		}

		protected void ShowTeamView(uint id)
		{
			this._TeamDoc.TryChangeToExpID((int)id);
			DlgBase<XTeamView, TabDlgBehaviour>.singleton.ShowTeamView();
		}

		public static int GetDayLeftCount()
		{
			XExpeditionDocument specificDocument = XDocuments.GetSpecificDocument<XExpeditionDocument>(XExpeditionDocument.uuID);
			return specificDocument.GetDayCount(TeamLevelType.TeamLevelExpdition, null);
		}
	}
}