Survivalcraft API 1.8.2.3
v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
TouchInputWidget.cs
浏览该文件的文档.
1
using
Engine
;
2
using
Engine.Input
;
3
4
namespace
Game
{
5
public
class
TouchInputWidget
:
Widget
{
6
public
int
?
m_touchId
;
7
8
public
Vector2
m_touchLastPosition
;
9
10
public
Vector2
m_touchOrigin
;
11
12
public
Vector2
m_touchOriginLimited
;
13
14
public
bool
m_touchMoved
;
15
16
public
double
m_touchTime
;
17
18
public
int
m_touchFrameIndex
;
19
20
public
TouchInput
?
m_touchInput
;
21
22
public
float
m_radius
= 30f;
23
24
public
float
Radius
{
25
get
=>
m_radius
;
26
set
=>
m_radius
=
MathUtils
.
Max
(value, 1f);
27
}
28
29
public
TouchInput
?
TouchInput
{
30
get
{
31
if
(
IsEnabledGlobal
&&
IsVisibleGlobal
) {
32
return
m_touchInput
;
33
}
34
return
null
;
35
}
36
}
37
38
public
override
void
Update
() {
39
m_touchInput
=
null
;
40
double
frameStartTime =
Time
.
FrameStartTime
;
41
int
frameIndex =
Time
.
FrameIndex
;
42
foreach
(
TouchLocation
touchLocation
in
Input
.TouchLocations) {
43
if
(touchLocation.
State
==
TouchLocationState
.Pressed) {
44
if
(
HitTestGlobal
(touchLocation.
Position
) ==
this
) {
45
m_touchId
= touchLocation.
Id
;
46
m_touchLastPosition
= touchLocation.
Position
;
47
m_touchOrigin
= touchLocation.
Position
;
48
m_touchOriginLimited
= touchLocation.
Position
;
49
m_touchTime
= frameStartTime;
50
m_touchFrameIndex
= frameIndex;
51
m_touchMoved
=
false
;
52
}
53
}
54
else
if
(touchLocation.
State
==
TouchLocationState
.Moved) {
55
if
(
m_touchId
.HasValue
56
&& touchLocation.
Id
==
m_touchId
.Value) {
57
m_touchMoved
|=
Vector2
.
Distance
(touchLocation.
Position
,
m_touchOrigin
) >
SettingsManager.MinimumDragDistance
*
GlobalScale
;
58
TouchInput
value =
default
;
59
value.InputType = !
m_touchMoved
?
TouchInputType.Hold
:
TouchInputType
.Move;
60
value.Duration = (float)(frameStartTime -
m_touchTime
);
61
value.DurationFrames = frameIndex -
m_touchFrameIndex
;
62
value.Position = touchLocation.
Position
;
63
value.Move = touchLocation.Position -
m_touchLastPosition
;
64
value.TotalMove = touchLocation.Position -
m_touchOrigin
;
65
value.TotalMoveLimited = touchLocation.Position -
m_touchOriginLimited
;
66
if
(MathF.Abs(value.
TotalMoveLimited
.
X
) >
m_radius
) {
67
m_touchOriginLimited.X = touchLocation.Position.X - MathF.Sign(value.
TotalMoveLimited
.
X
) *
m_radius
;
68
}
69
if
(MathF.Abs(value.
TotalMoveLimited
.
Y
) >
m_radius
) {
70
m_touchOriginLimited.Y = touchLocation.Position.Y - MathF.Sign(value.
TotalMoveLimited
.
Y
) *
m_radius
;
71
}
72
m_touchInput
= value;
73
m_touchLastPosition
= touchLocation.
Position
;
74
}
75
}
76
else
if
(touchLocation.
State
==
TouchLocationState
.Released
77
&&
m_touchId
.HasValue
78
&& touchLocation.
Id
==
m_touchId
.Value) {
79
if
(frameStartTime -
m_touchTime
<=
SettingsManager
.
MinimumHoldDuration
80
&&
Vector2
.
Distance
(touchLocation.
Position
,
m_touchOrigin
) <
SettingsManager
.
MinimumDragDistance
*
GlobalScale
) {
81
TouchInput
value2 =
default
;
82
value2.InputType =
TouchInputType
.Tap;
83
value2.Duration = (float)(frameStartTime -
m_touchTime
);
84
value2.DurationFrames = frameIndex -
m_touchFrameIndex
;
85
value2.Position = touchLocation.
Position
;
86
m_touchInput
= value2;
87
}
88
m_touchId
=
null
;
89
}
90
}
91
}
92
}
93
}
Engine.MathUtils
定义
MathUtils.cs:2
Engine.MathUtils.Max
static int Max(int x1, int x2)
定义
MathUtils.cs:18
Engine.Time
定义
Time.cs:4
Engine.Time.FrameIndex
static int FrameIndex
定义
Time.cs:26
Engine.Time.FrameStartTime
static double FrameStartTime
定义
Time.cs:42
Game.SettingsManager
定义
SettingsManager.cs:11
Game.SettingsManager.MinimumDragDistance
static float MinimumDragDistance
定义
SettingsManager.cs:254
Game.SettingsManager.MinimumHoldDuration
static float MinimumHoldDuration
定义
SettingsManager.cs:252
Game.TouchInputWidget
定义
TouchInputWidget.cs:5
Game.TouchInputWidget.m_touchId
int? m_touchId
定义
TouchInputWidget.cs:6
Game.TouchInputWidget.m_touchTime
double m_touchTime
定义
TouchInputWidget.cs:16
Game.TouchInputWidget.Update
override void Update()
定义
TouchInputWidget.cs:38
Game.TouchInputWidget.m_touchMoved
bool m_touchMoved
定义
TouchInputWidget.cs:14
Game.TouchInputWidget.m_touchOrigin
Vector2 m_touchOrigin
定义
TouchInputWidget.cs:10
Game.TouchInputWidget.TouchInput
TouchInput? TouchInput
定义
TouchInputWidget.cs:29
Game.TouchInputWidget.m_touchLastPosition
Vector2 m_touchLastPosition
定义
TouchInputWidget.cs:8
Game.TouchInputWidget.m_radius
float m_radius
定义
TouchInputWidget.cs:22
Game.TouchInputWidget.Radius
float Radius
定义
TouchInputWidget.cs:24
Game.TouchInputWidget.m_touchOriginLimited
Vector2 m_touchOriginLimited
定义
TouchInputWidget.cs:12
Game.TouchInputWidget.m_touchFrameIndex
int m_touchFrameIndex
定义
TouchInputWidget.cs:18
Game.TouchInputWidget.m_touchInput
TouchInput? m_touchInput
定义
TouchInputWidget.cs:20
Game.Widget.GlobalScale
float GlobalScale
定义
Widget.cs:328
Game.Widget.IsVisibleGlobal
bool IsVisibleGlobal
定义
Widget.cs:382
Game.Widget.HitTestGlobal
virtual Widget HitTestGlobal(Vector2 point, Func< Widget, bool > predicate=null)
定义
Widget.cs:696
Game.Widget.Widget
Widget()
定义
Widget.cs:479
Game.Widget.Input
WidgetInput Input
定义
Widget.cs:296
Game.Widget.IsEnabledGlobal
bool IsEnabledGlobal
定义
Widget.cs:394
Engine.Input
定义
CursorType.cs:1
Engine.Input.TouchLocationState
TouchLocationState
定义
TouchLocationState.cs:2
Engine
定义
BaseSound.cs:10
Game
定义
ContentFileBridge.cs:4
Game.TouchInputType
TouchInputType
定义
TouchInputType.cs:2
Game.TouchInputType.Hold
@ Hold
定义
TouchInputType.cs:4
Engine.Input.TouchLocation
定义
TouchLocation.cs:2
Engine.Input.TouchLocation.Position
Vector2 Position
定义
TouchLocation.cs:5
Engine.Input.TouchLocation.Id
int Id
定义
TouchLocation.cs:3
Engine.Input.TouchLocation.State
TouchLocationState State
定义
TouchLocation.cs:7
Engine.Vector2
定义
Vector2.cs:2
Engine.Vector2.Y
float Y
定义
Vector2.cs:5
Engine.Vector2.X
float X
定义
Vector2.cs:3
Engine.Vector2.Distance
static float Distance(Vector2 v1, Vector2 v2)
定义
Vector2.cs:53
Game.TouchInput.TotalMoveLimited
Vector2 TotalMoveLimited
定义
TouchInput.cs:15
SurvivalcraftApi 1.8.2.3
Survivalcraft.Windows
Widget
TouchInputWidget.cs
制作者
1.16.1