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

namespace XMainClient.UI
{
	internal class ArtifactComposingHandler : DlgHandlerBase
	{
		protected override string FileName
		{
			get
			{
				return "ItemNew/ArtifactComposeFrame";
			}
		}

		public string CreatePath
		{
			get
			{
				bool flag = string.IsNullOrEmpty(this.m_createPath);
				if (flag)
				{
					this.m_createPath = XSingleton<XGlobalConfig>.singleton.GetValue("EquipCreatEffectPath");
				}
				return this.m_createPath;
			}
		}

		private ArtifactComposeDocument m_doc;

		private ArtifactBagDocument m_artifactBagdoc;

		private IXUILabel m_textLab;

		private IXUIButton m_doBtn;

		private IXUILabel m_doLab;

		private IXUISprite m_sprBar;

		private GameObject m_barView;

		private XFx m_creatFx = null;

		private XFx m_successFx = null;

		private Transform m_successEffectTra;

		private EquipSetItemBaseView m_itemView;

		private ArtifactQuanlityFx m_quanlityFx = new ArtifactQuanlityFx();

		private float m_fCoolTime = 0.5f;

		private float m_fLastClickBtnTime = 0f;

		private int m_barFullWidth;

		private string m_createPath = string.Empty;

		protected override void Init()
		{
			base.Init();
			this.m_doc = ArtifactComposeDocument.Doc;
			this.m_artifactBagdoc = ArtifactBagDocument.Doc;
			this.m_textLab = (base.PanelObject.transform.Find("Text").GetComponent("XUILabel") as IXUILabel);
			this.m_barView = base.PanelObject.transform.Find("Making").gameObject;
			this.m_sprBar = (this.m_barView.transform.Find("Bar").GetComponent("XUISprite") as IXUISprite);
			this.m_doBtn = (base.PanelObject.transform.Find("Do").GetComponent("XUIButton") as IXUIButton);
			this.m_doLab = (base.PanelObject.transform.Find("Do/T").GetComponent("XUILabel") as IXUILabel);
			this.m_successEffectTra = base.PanelObject.transform.Find("Suc");
			string @string = XSingleton<XStringTable>.singleton.GetString("ArtifactComposeSuccessEffectName");
			this.m_successFx = XSingleton<XFxMgr>.singleton.CreateUIFx(@string, this.m_successEffectTra, false);
			this.m_itemView = new EquipSetItemBaseView();
			this.m_itemView.FindFrom(base.PanelObject.transform);
			this.m_barFullWidth = this.m_sprBar.spriteWidth;
		}

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

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

		protected override void OnHide()
		{
			base.OnHide();
			this.HideEffect();
			bool flag = this.m_successEffectTra != null;
			if (flag)
			{
				this.m_successEffectTra.gameObject.SetActive(false);
			}
			base.PanelObject.SetActive(false);
			this.m_quanlityFx.Reset();
		}

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

		public override void OnUnload()
		{
			base.OnUnload();
			this.m_doc = null;
			bool flag = this.m_creatFx != null;
			if (flag)
			{
				XSingleton<XFxMgr>.singleton.DestroyFx(this.m_creatFx, true);
				this.m_creatFx = null;
			}
			bool flag2 = this.m_successFx != null;
			if (flag2)
			{
				XSingleton<XFxMgr>.singleton.DestroyFx(this.m_successFx, true);
				this.m_successFx = null;
			}
			this.m_quanlityFx.Reset();
		}

		private void FillContent()
		{
			bool flag = this.m_itemView.goItem != null;
			if (flag)
			{
				this.m_itemView.goItem.SetActive(false);
			}
		}

		public void SetFinishState(bool bFinish)
		{
			this.m_barView.SetActive(!bFinish);
			this.m_successEffectTra.gameObject.SetActive(bFinish);
			this.m_doBtn.SetVisible(true);
			if (bFinish)
			{
				this.HideEffect();
				XSingleton<XAudioMgr>.singleton.PlayUISound("Audio/UI/UI_Upgrade_Gear", true, AudioChannel.Action);
				this.m_textLab.SetText(XStringDefineProxy.GetString("EQUIPCREATE_EQUIPSET_SUCCESS").Replace("{n}", "\n"));
				this.m_doLab.SetText(XStringDefineProxy.GetString(XStringDefine.COMMON_OK));
				this.m_doBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnClickButtonOK));
			}
			else
			{
				this.ShowEffect();
				this.m_textLab.SetText(XStringDefineProxy.GetString("Artifact_compose_tips"));
				this.m_doLab.SetText(XStringDefineProxy.GetString(XStringDefine.COMMON_CANCEL));
				this.m_doBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnClickButtonCancel));
			}
		}

		public void SetFinishArtifactInfo(XItem item)
		{
			bool flag = this.m_itemView.goItem != null;
			if (flag)
			{
				this.m_itemView.goItem.SetActive(true);
			}
			bool flag2 = item != null && item.uid > 0UL && item.itemID > 0;
			if (flag2)
			{
				bool flag3 = base.IsVisible() && this.m_itemView != null;
				if (flag3)
				{
					EquipSetItemBaseView.stEquipInfoParam param;
					param.isShowTooltip = false;
					param.playerProf = 0;
					this.m_itemView.SetItemInfo(item, param, item.bBinding);
					bool flag4 = item.itemConf != null;
					if (flag4)
					{
						this.SetEffect(this.m_itemView.goItem, item.itemID);
					}
				}
				this.m_itemView.SetFinishItem(item);
			}
		}

		private void ShowEffect()
		{
			bool flag = this.m_creatFx == null;
			if (flag)
			{
				this.m_creatFx = XSingleton<XFxMgr>.singleton.CreateFx(this.CreatePath, null, true);
			}
			else
			{
				this.m_creatFx.SetActive(true);
			}
			this.m_creatFx.Play(base.PanelObject.transform.Find("Bg"), Vector3.zero, Vector3.one, 1f, true, false);
			XSingleton<XAudioMgr>.singleton.PlayUISound("Audio/UI/UI_datie", true, AudioChannel.Action);
		}

		private void SetEffect(GameObject go, int itemId)
		{
			bool flag = go == null;
			if (!flag)
			{
				ItemList.RowData itemConf = XBagDocument.GetItemConf(itemId);
				bool flag2 = itemConf == null;
				if (!flag2)
				{
					ArtifactListTable.RowData artifactListRowData = ArtifactDocument.GetArtifactListRowData((uint)itemId);
					bool flag3 = artifactListRowData == null;
					if (!flag3)
					{
						ulong key = this.m_artifactBagdoc.MakeKey((uint)itemConf.ItemQuality, artifactListRowData.AttrType);
						string path;
						bool flag4 = !this.m_artifactBagdoc.GetArtifactEffectPath(key, out path);
						if (flag4)
						{
							this.m_quanlityFx.Reset();
						}
						else
						{
							bool flag5 = !this.m_quanlityFx.IsCanReuse(key);
							if (flag5)
							{
								this.m_quanlityFx.SetData(key, go.transform.Find("Icon/Icon/Effects"), path);
							}
						}
					}
				}
			}
		}

		private void HideEffect()
		{
			bool flag = this.m_creatFx != null;
			if (flag)
			{
				this.m_creatFx.SetActive(false);
				this.m_creatFx.Stop();
			}
		}

		public void SetBar(int f)
		{
			f = Mathf.Clamp(f, 1, 100);
			this.m_sprBar.spriteWidth = this.m_barFullWidth * f / 100;
		}

		private bool OnClickButtonOK(IXUIButton btn)
		{
			bool flag = this.SetButtonCool(this.m_fCoolTime);
			bool result;
			if (flag)
			{
				result = false;
			}
			else
			{
				bool isComposing = this.m_doc.IsComposing;
				if (isComposing)
				{
					result = true;
				}
				else
				{
					base.SetVisible(false);
					result = true;
				}
			}
			return result;
		}

		private bool OnClickButtonCancel(IXUIButton btn)
		{
			bool flag = this.SetButtonCool(this.m_fCoolTime);
			bool result;
			if (flag)
			{
				result = false;
			}
			else
			{
				bool isComposing = this.m_doc.IsComposing;
				if (isComposing)
				{
					result = true;
				}
				else
				{
					base.SetVisible(false);
					result = true;
				}
			}
			return result;
		}

		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;
		}
	}
}