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

namespace XMainClient.UI
{
	internal class SuperRiskSelectMapHandler : DlgHandlerBase
	{
		protected override string FileName
		{
			get
			{
				return "GameSystem/SuperRisk/SelectMapHandler";
			}
		}

		private XSuperRiskDocument _doc;

		private IXUIButton m_Close;

		private IXUIButton m_Help;

		private List<Transform> m_btnTras = new List<Transform>();

		private float m_fCoolTime = 1f;

		private float m_fLastClickBtnTime = 0f;

		protected override void Init()
		{
			base.Init();
			this._doc = (XSingleton<XGame>.singleton.Doc.GetXComponent(XSuperRiskDocument.uuID) as XSuperRiskDocument);
			this.m_btnTras.Clear();
			Transform transform = base.PanelObject.transform.Find("Bg/RiskMap/SelectMap");
			for (int i = 0; i < transform.childCount; i++)
			{
				Transform item = transform.Find(XSingleton<XCommon>.singleton.StringCombine("Map", i.ToString()));
				this.m_btnTras.Add(item);
			}
			this.m_Close = (base.PanelObject.transform.Find("Bg/panel/Close").GetComponent("XUIButton") as IXUIButton);
			this.m_Help = (base.transform.Find("Bg/panel/Help").GetComponent("XUIButton") as IXUIButton);
		}

		public override void RegisterEvent()
		{
			this.m_Close.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnCloseClick));
			this.m_Help.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnHelpClicked));
		}

		public bool OnHelpClicked(IXUIButton button)
		{
			DlgBase<XCommonHelpTipView, XCommonHelpTipBehaviour>.singleton.ShowHelp(XSysDefine.XSys_SuperRisk);
			return true;
		}

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

		private void FillContent()
		{
			bool flag = false;
			for (int i = 0; i < this.m_btnTras.Count; i++)
			{
				RiskMapFile.RowData mapIdByIndex = this._doc.GetMapIdByIndex(i);
				bool flag2 = mapIdByIndex == null;
				if (flag2)
				{
					this.m_btnTras[i].Find("Map").gameObject.SetActive(false);
					this.m_btnTras[i].Find("Cloud/T").gameObject.SetActive(false);
					this.m_btnTras[i].Find("Cloud").gameObject.SetActive(true);
				}
				else
				{
					uint num = 0u;
					bool flag3 = XSingleton<XAttributeMgr>.singleton.XPlayerData != null;
					if (flag3)
					{
						num = XSingleton<XAttributeMgr>.singleton.XPlayerData.Level;
					}
					this.m_btnTras[i].Find("Map").gameObject.SetActive(false);
					bool flag4 = (ulong)num > (ulong)((long)mapIdByIndex.NeedLevel);
					if (flag4)
					{
						this.m_btnTras[i].Find("Cloud").gameObject.SetActive(false);
						IXUISprite ixuisprite = this.m_btnTras[i].GetComponent("XUISprite") as IXUISprite;
						bool flag5 = mapIdByIndex == null;
						if (flag5)
						{
							ixuisprite.ID = 0UL;
						}
						else
						{
							ixuisprite.ID = (ulong)((long)mapIdByIndex.MapID);
						}
						ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnMapClick));
						ixuisprite.RegisterSpritePressEventHandler(new SpritePressEventHandler(this.OnMapPress));
					}
					else
					{
						bool flag6 = (ulong)num < (ulong)((long)mapIdByIndex.NeedLevel);
						if (flag6)
						{
							bool flag7 = flag;
							if (flag7)
							{
								this.m_btnTras[i].Find("Cloud").gameObject.SetActive(true);
								this.m_btnTras[i].Find("Cloud/T").gameObject.SetActive(false);
							}
							else
							{
								this.m_btnTras[i].Find("Cloud").gameObject.SetActive(true);
								IXUILabel ixuilabel = this.m_btnTras[i].Find("Cloud/T").GetComponent("XUILabel") as IXUILabel;
								ixuilabel.gameObject.SetActive(true);
								ixuilabel.SetText(string.Format(XStringDefineProxy.GetString("OPEN_AT_LEVEL"), mapIdByIndex.NeedLevel));
								flag = true;
							}
						}
						else
						{
							bool flag8 = num > this._doc.HisMaxLevel.PreLevel;
							if (flag8)
							{
								this._doc.HisMaxLevel.PreLevel = num;
								this.m_btnTras[i].Find("Cloud/T").gameObject.SetActive(false);
								IXUITweenTool ixuitweenTool = this.m_btnTras[i].Find("Cloud").GetComponent("XUIPlayTween") as IXUITweenTool;
								ixuitweenTool.gameObject.SetActive(true);
								ixuitweenTool.SetTweenGroup(0);
								ixuitweenTool.ResetTweenByGroup(true, 0);
								ixuitweenTool.PlayTween(true, -1f);
							}
							else
							{
								this.m_btnTras[i].Find("Cloud").gameObject.SetActive(false);
							}
							IXUISprite ixuisprite = this.m_btnTras[i].GetComponent("XUISprite") as IXUISprite;
							bool flag9 = mapIdByIndex == null;
							if (flag9)
							{
								ixuisprite.ID = 0UL;
							}
							else
							{
								ixuisprite.ID = (ulong)((long)mapIdByIndex.MapID);
							}
							ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnMapClick));
							ixuisprite.RegisterSpritePressEventHandler(new SpritePressEventHandler(this.OnMapPress));
						}
					}
				}
			}
		}

		private bool OnCloseClick(IXUIButton go)
		{
			XSuperRiskDocument specificDocument = XDocuments.GetSpecificDocument<XSuperRiskDocument>(XSuperRiskDocument.uuID);
			specificDocument.NeedUpdate = false;
			base.SetVisible(false);
			DlgBase<SuperRiskDlg, SuperRiskDlgBehaviour>.singleton.SetVisible(false, true);
			return true;
		}

		private void OnMapClick(IXUISprite button)
		{
			bool flag = this.SetButtonCool(this.m_fCoolTime);
			if (!flag)
			{
				bool flag2 = button.ID == 0UL;
				if (!flag2)
				{
					this._doc.CurrentMapID = (int)button.ID;
					DlgBase<SuperRiskDlg, SuperRiskDlgBehaviour>.singleton.ShowGameMap();
				}
			}
		}

		private bool OnMapPress(IXUISprite uiSprite, bool isPressed)
		{
			GameObject gameObject = uiSprite.gameObject.transform.Find("Map").gameObject;
			gameObject.SetActive(isPressed);
			return true;
		}

		private bool SetButtonCool(float time)
		{
			float num = Time.realtimeSinceStartup - this.m_fLastClickBtnTime;
			bool flag = num < time;
			bool result;
			if (flag)
			{
				result = true;
			}
			else
			{
				this.m_fLastClickBtnTime = Time.realtimeSinceStartup;
				result = false;
			}
			return result;
		}
	}
}