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

namespace XMainClient.UI
{
	internal class BattleQTEDlg : DlgBase<BattleQTEDlg, BattleQTEDlgBehaviour>
	{
		public override string fileName
		{
			get
			{
				return "Battle/BattleQTEDlg";
			}
		}

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

		public override bool autoload
		{
			get
			{
				return true;
			}
		}

		private XBattleDocument _doc = null;

		private QteUIType _type = QteUIType.Bind;

		private float _abnormal_delta = 0.01f;

		private bool _abnormal_flag = false;

		private int _abnormal_wait = 0;

		private int _abnormal_send_wait = 0;

		private float _charge_value = 0f;

		protected override void Init()
		{
			base.Init();
			this._doc = XDocuments.GetSpecificDocument<XBattleDocument>(XBattleDocument.uuID);
		}

		public void SetStatus(QteUIType type, bool status)
		{
			this._type = type;
			this.SetVisible(status, true);
		}

		public void SetChargeValue(float value)
		{
			this._charge_value = value;
			base.uiBehaviour.m_ChargeBar.Value = this._charge_value;
		}

		public void SetAbnormalValue(float value)
		{
			this._abnormal_delta = value;
		}

		protected override void OnShow()
		{
			base.OnShow();
			base.uiBehaviour.m_Bind.gameObject.SetActive(this._type == QteUIType.Bind);
			base.uiBehaviour.m_Abnormal.gameObject.SetActive(this._type == QteUIType.Abnormal);
			base.uiBehaviour.m_Charge.gameObject.SetActive(this._type == QteUIType.Charge);
			base.uiBehaviour.m_Block.gameObject.SetActive(this._type != QteUIType.Charge);
			switch (this._type)
			{
			case QteUIType.Bind:
			{
				base.uiBehaviour.m_BindLeftButton.SetVisible(true);
				base.uiBehaviour.m_BindRightButton.SetVisible(false);
				base.uiBehaviour.m_BindArrow.localPosition = new Vector3(base.uiBehaviour.m_BindLeftButton.parent.gameObject.transform.localPosition.x, 0f);
				bool flag = DlgBase<BattleMain, BattleMainBehaviour>.singleton.IsLoaded() && DlgBase<BattleMain, BattleMainBehaviour>.singleton.SkillHandler != null;
				if (flag)
				{
					DlgBase<BattleMain, BattleMainBehaviour>.singleton.SkillHandler.SetVisible(false);
					DlgBase<BattleMain, BattleMainBehaviour>.singleton.SkillHandler.ResetPressState();
				}
				break;
			}
			case QteUIType.Abnormal:
			{
				this._abnormal_flag = true;
				this._abnormal_wait = 0;
				this._abnormal_send_wait = 0;
				base.uiBehaviour.m_AbnormalBar.Value = 0f;
				base.uiBehaviour.m_AbnormalSuccessTween.gameObject.SetActive(false);
				base.uiBehaviour.m_AbnormalFailTween.gameObject.SetActive(false);
				base.uiBehaviour.m_AbnormalHitTween.gameObject.SetActive(false);
				base.uiBehaviour.m_AbnormalBeginTween.PlayTween(true, -1f);
				bool flag2 = DlgBase<BattleMain, BattleMainBehaviour>.singleton.IsLoaded() && DlgBase<BattleMain, BattleMainBehaviour>.singleton.SkillHandler != null;
				if (flag2)
				{
					DlgBase<BattleMain, BattleMainBehaviour>.singleton.SkillHandler.SetVisible(false);
					DlgBase<BattleMain, BattleMainBehaviour>.singleton.SkillHandler.ResetPressState();
				}
				break;
			}
			case QteUIType.Charge:
				base.uiBehaviour.m_ChargeBar.Value = this._charge_value;
				break;
			}
		}

		protected override void OnHide()
		{
			base.OnHide();
			QteUIType type = this._type;
			if (type > QteUIType.Abnormal)
			{
				if (type != QteUIType.Charge)
				{
				}
			}
			else
			{
				bool flag = DlgBase<BattleMain, BattleMainBehaviour>.singleton.IsLoaded() && DlgBase<BattleMain, BattleMainBehaviour>.singleton.SkillHandler != null;
				if (flag)
				{
					DlgBase<BattleMain, BattleMainBehaviour>.singleton.SkillHandler.SetVisible(true);
				}
			}
		}

		public override void RegisterEvent()
		{
			base.RegisterEvent();
			base.uiBehaviour.m_BindLeftButton.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnBindLeftButtonClick));
			base.uiBehaviour.m_BindRightButton.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnBindRightButtonClick));
			base.uiBehaviour.m_AbnormalClickSpace.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnAbnormalClicked));
		}

		private void OnBindLeftButtonClick(IXUISprite sp)
		{
			base.uiBehaviour.m_BindLeftButton.SetVisible(false);
			base.uiBehaviour.m_BindRightButton.SetVisible(true);
			base.uiBehaviour.m_BindArrow.localPosition = new Vector3(base.uiBehaviour.m_BindRightButton.parent.gameObject.transform.localPosition.x, 0f);
			this.SendBindOperation();
		}

		private void OnBindRightButtonClick(IXUISprite sp)
		{
			base.uiBehaviour.m_BindLeftButton.SetVisible(true);
			base.uiBehaviour.m_BindRightButton.SetVisible(false);
			base.uiBehaviour.m_BindArrow.localPosition = new Vector3(base.uiBehaviour.m_BindLeftButton.parent.gameObject.transform.localPosition.x, 0f);
			this.SendBindOperation();
		}

		private void OnAbnormalClicked(IXUISprite sp)
		{
			bool flag = !this._abnormal_flag;
			if (!flag)
			{
				this._abnormal_flag = false;
				bool flag2 = base.uiBehaviour.m_AbnormalLeftTarget.localPosition.x <= base.uiBehaviour.m_AbnormalThumb.localPosition.x && base.uiBehaviour.m_AbnormalRightTarget.localPosition.x >= base.uiBehaviour.m_AbnormalThumb.localPosition.x;
				if (flag2)
				{
					base.uiBehaviour.m_AbnormalSuccessTween.PlayTween(true, -1f);
					base.uiBehaviour.m_AbnormalHitTween.PlayTween(true, -1f);
					this._abnormal_send_wait = 30;
				}
				else
				{
					base.uiBehaviour.m_AbnormalFailTween.PlayTween(true, -1f);
					this._abnormal_wait = 30;
				}
			}
		}

		private void SendCheckAbnormalOperation()
		{
			PtcC2G_QTEOperation ptcC2G_QTEOperation = new PtcC2G_QTEOperation();
			ptcC2G_QTEOperation.Data.type = 2u;
			ptcC2G_QTEOperation.Data.monsterid = (ulong)((long)this._doc.AbnormalBuffID);
			XSingleton<XClientNetwork>.singleton.Send(ptcC2G_QTEOperation);
		}

		private void SendBindOperation()
		{
			bool syncMode = XSingleton<XGame>.singleton.SyncMode;
			if (syncMode)
			{
				PtcC2G_QTEOperation ptcC2G_QTEOperation = new PtcC2G_QTEOperation();
				ptcC2G_QTEOperation.Data.type = 2u;
				ptcC2G_QTEOperation.Data.monsterid = (ulong)((long)this._doc.BindBuffID);
				XSingleton<XClientNetwork>.singleton.Send(ptcC2G_QTEOperation);
			}
			else
			{
				XBuff xbuff = null;
				bool flag = XSingleton<XEntityMgr>.singleton.Player != null;
				if (flag)
				{
					xbuff = XSingleton<XEntityMgr>.singleton.Player.Buffs.GetBuffByID(this._doc.BindBuffID);
				}
				bool flag2 = xbuff != null;
				if (flag2)
				{
					bool flag3 = XSingleton<XEntityMgr>.singleton.Player.Attributes.GetAttr(XAttributeDefine.XAttr_PhysicalAtkMod_Total) > XSingleton<XEntityMgr>.singleton.Player.Attributes.GetAttr(XAttributeDefine.XAttr_MagicAtkMod_Total);
					double attr;
					if (flag3)
					{
						attr = XSingleton<XEntityMgr>.singleton.Player.Attributes.GetAttr(XAttributeDefine.XAttr_PhysicalAtkMod_Total);
					}
					else
					{
						attr = XSingleton<XEntityMgr>.singleton.Player.Attributes.GetAttr(XAttributeDefine.XAttr_MagicAtkMod_Total);
					}
					xbuff.ChangeBuffHP((double)((float)(-(float)attr)));
				}
			}
		}

		public override void OnUpdate()
		{
			base.OnUpdate();
			QteUIType type = this._type;
			if (type == QteUIType.Abnormal)
			{
				bool flag = this._abnormal_wait != 0;
				if (flag)
				{
					this._abnormal_wait--;
					bool flag2 = this._abnormal_wait == 0;
					if (flag2)
					{
						this._abnormal_flag = true;
					}
				}
				bool flag3 = this._abnormal_send_wait != 0;
				if (flag3)
				{
					this._abnormal_send_wait--;
					bool flag4 = this._abnormal_send_wait == 0;
					if (flag4)
					{
						this.SendCheckAbnormalOperation();
					}
				}
				bool abnormal_flag = this._abnormal_flag;
				if (abnormal_flag)
				{
					base.uiBehaviour.m_AbnormalBar.Value += this._abnormal_delta;
					bool flag5 = base.uiBehaviour.m_AbnormalBar.Value == 1f || base.uiBehaviour.m_AbnormalBar.Value == 0f;
					if (flag5)
					{
						this._abnormal_delta = -this._abnormal_delta;
					}
				}
			}
		}
	}
}