blob: 778c30f4dfc660eee13d294449bbb93fb8d51820 (
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
|
using System;
using UnityEngine;
using XUpdater;
using XUtliPoolLib;
namespace XMainClient
{
internal class XGesture : XSingleton<XGesture>
{
public bool Freezed
{
get
{
return this._bFreeze;
}
set
{
this._bFreeze = value;
this.Cancel();
}
}
public bool Working
{
get
{
return this._finger_id != -1;
}
}
public bool Gestured
{
get
{
return this._bswype || this._one || this._one_up;
}
}
public bool OneTouch
{
get
{
return this._one;
}
}
public bool OneUpTouch
{
get
{
return this._one_up;
}
}
public bool Swype
{
get
{
return this._bswype;
}
}
public bool LastSwypeUsed
{
get
{
return this._last_swype_used;
}
}
public float LastSwypeAt
{
get
{
return this._last_swype_at;
}
}
public float LastSwypeDis
{
get
{
return this._swype_dis;
}
}
public Vector3 SwypeDirection
{
get
{
return -this._swypedir;
}
}
public XGesture.SwypeDirectionType SwypeType
{
get
{
return this._swype_type;
}
}
public Vector3 GesturePosition
{
get
{
return this._gesturepos;
}
}
public Vector3 TouchPosition
{
get
{
return this._touchpos;
}
}
public int FingerId
{
get
{
return this._finger_id;
}
}
private readonly float _dead_zone = 10f;
private bool _bTouch = false;
private int _finger_id = -1;
private bool _one = false;
private bool _one_up = false;
private bool _bswype = false;
private bool _last_swype_used = false;
private bool _bFreeze = false;
private float _last_swype_at = 0f;
private float _start_at = 0f;
private float _swype_start_at = 0f;
private float _swype_dis = 0f;
private Vector2 _start = Vector2.zero;
private Vector2 _swype_start = Vector2.zero;
private Vector2 _double_touch_start = Vector2.zero;
private Vector2 _end = Vector2.zero;
private Vector3 _swypedir = Vector3.zero;
private Vector3 _gesturepos = Vector3.zero;
private Vector3 _touchpos = Vector3.zero;
private float _last_touch_down_at = 0f;
private XGesture.SwypeDirectionType _swype_type;
public enum SwypeDirectionType
{
Left,
Right
}
private enum DoubleTouchPhase
{
Preparing,
Prepared
}
public void SwypeCounted()
{
this._last_swype_used = true;
}
public void ClearOneHit()
{
this._one = false;
this._one_up = false;
}
public void OnEnterScene()
{
this._bFreeze = false;
this.Cancel();
}
public void Feed(XTouchItem touch)
{
this._one |= this.OneUpdate(touch);
this._one_up |= this.OneUpUpdate(touch);
bool flag = (!this._bFreeze || XSingleton<XScene>.singleton.bSpectator) && ((this._finger_id == -1 && touch.FingerId != XSingleton<XVirtualTab>.singleton.FingerId) || this._finger_id == touch.FingerId);
if (flag)
{
bool flag2 = touch.Phase == 0;
if (flag2)
{
this._start = touch.Position;
this._swype_start = this._start;
this._start_at = Time.time;
this._swype_start_at = this._start_at;
this._bTouch = true;
}
bool bTouch = this._bTouch;
if (bTouch)
{
bool flag3 = XTouch.IsActiveTouch(touch);
if (flag3)
{
this._gesturepos = touch.Position;
this._bswype = this.SwypeUpdate(touch);
bool bswype = this._bswype;
if (bswype)
{
this._finger_id = touch.FingerId;
}
}
else
{
this.Cancel();
}
}
}
}
public void Cancel()
{
this._bTouch = false;
this._one = false;
this._bswype = false;
this._finger_id = -1;
}
private bool OneUpdate(XTouchItem touch)
{
bool flag = touch.Phase == null && (touch.FingerId == XFastEnumIntEqualityComparer<XFingerId>.ToInt(XFingerId.XCommon_0) || touch.FingerId == XFastEnumIntEqualityComparer<XFingerId>.ToInt(XFingerId.XCommon_1));
bool result;
if (flag)
{
this._touchpos = touch.Position;
result = true;
}
else
{
result = false;
}
return result;
}
private bool OneUpUpdate(XTouchItem touch)
{
bool flag = touch.FingerId != XFastEnumIntEqualityComparer<XFingerId>.ToInt(XFingerId.XCommon_0) && touch.FingerId != XFastEnumIntEqualityComparer<XFingerId>.ToInt(XFingerId.XCommon_1);
bool result;
if (flag)
{
result = false;
}
else
{
bool flag2 = touch.Phase == 0;
if (flag2)
{
bool flag3 = XSingleton<XUpdater.XUpdater>.singleton.EditorMode && touch.FingerId == 1;
if (flag3)
{
return false;
}
this._touchpos = touch.Position;
this._last_touch_down_at = Time.time;
}
else
{
bool flag4 = (int)touch.Phase == 4 || (int)touch.Phase == 3;
if (flag4)
{
float a = Time.time - this._last_touch_down_at;
bool flag5 = XSingleton<XCommon>.singleton.IsLess(a, 0.5f / Time.timeScale);
if (flag5)
{
Vector2 vector;
vector.x = this._touchpos.x - touch.Position.x;
vector.y = this._touchpos.y - touch.Position.y;
float num = Mathf.Sqrt(Mathf.Pow(vector.x, 2f) + Mathf.Pow(vector.y, 2f));
bool flag6 = num < this._dead_zone;
if (flag6)
{
this._touchpos = touch.Position;
return true;
}
}
}
}
result = false;
}
return result;
}
private bool SwypeUpdate(XTouchItem touch)
{
TouchPhase phase = touch.Phase;
bool flag = (int)phase == 1;
if (flag)
{
this._end = touch.Position;
Vector2 vector = this._end - this._swype_start;
float time = Time.time;
this._swype_dis = Mathf.Sqrt(Mathf.Pow(vector.x, 2f) + Mathf.Pow(vector.y, 2f));
bool flag2 = this._swype_dis > this._dead_zone;
if (flag2)
{
this._swype_type = (XSingleton<XCommon>.singleton.IsGreater(this._swype_start.x, (float)Screen.width * 0.5f) ? XGesture.SwypeDirectionType.Right : XGesture.SwypeDirectionType.Left);
this._swype_start = this._end;
this._swype_start_at = time;
this._swypedir.x = vector.x;
this._swypedir.y = 0f;
this._swypedir.z = vector.y;
this._swypedir.Normalize();
this._gesturepos = this._end;
this._last_swype_at = time;
this._last_swype_used = false;
return true;
}
}
return false;
}
}
}
|