Skip to content

Commit dd8201a

Browse files
committed
修改控制逻辑
1 parent 85e639b commit dd8201a

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

CrazyCar/Assets/Scripts/Game/GameCtrBtn.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,27 @@
66
using Utils;
77

88
public class GameCtrBtn : MonoBehaviour, IPointerDownHandler, IPointerUpHandler {
9-
private Action<float> clickDown;
9+
private Action clickDown;
1010
private Action clickUp;
1111
private bool isClickDown = false;
12-
private float curTime;
1312

1413
private void Update() {
1514
if (isClickDown) {
16-
clickDown?.Invoke(curTime);
15+
clickDown?.Invoke();
1716
}
1817
}
1918

20-
public void SetClick(Action<float> clickDown = null, Action clickUp = null) {
19+
public void SetClick(Action clickDown = null, Action clickUp = null) {
2120
this.clickDown = clickDown;
2221
this.clickUp = clickUp;
2322
}
2423

2524
public void OnPointerDown(PointerEventData eventData) {
2625
isClickDown = true;
27-
curTime = Time.fixedTime;
2826
}
2927

3028
public void OnPointerUp(PointerEventData eventData) {
3129
isClickDown = false;
32-
curTime = 0;
3330
clickUp?.Invoke();
3431
}
3532
}

CrazyCar/Assets/Scripts/Game/InputSystemPanel.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,24 @@ private bool IsStartGame {
3232
}
3333

3434
private void Start() {
35-
frontBtn.SetClick((float time) => {
35+
frontBtn.SetClick(() => {
3636
this.SendCommand(new PlayerControllerCommand(ControllerType.Vertical, 1));
3737
});
38-
backBtn.SetClick((float time) => {
38+
backBtn.SetClick(() => {
3939
this.SendCommand(new PlayerControllerCommand(ControllerType.Vertical, -1));
4040
});
41-
leftBtn.SetClick((float time) => {
41+
leftBtn.SetClick(() => {
4242
this.SendCommand(new PlayerControllerCommand(ControllerType.Horizontal, -1));
4343
}, () => {
4444
this.SendCommand(new PlayerControllerCommand(ControllerType.Horizontal, 0));
4545
});
46-
rightBtn.SetClick((float time) => {
46+
rightBtn.SetClick(() => {
4747
this.SendCommand(new PlayerControllerCommand(ControllerType.Horizontal, 1));
4848
}, () => {
4949
this.SendCommand(new PlayerControllerCommand(ControllerType.Horizontal, 0));
5050
});
51-
spaceBtn.SetClick((float time) => {
52-
this.SendCommand(new PlayerControllerCommand(ControllerType.Speed, Mathf.Clamp01(Time.fixedTime - time)));
51+
spaceBtn.SetClick(() => {
52+
this.SendCommand(new PlayerControllerCommand(ControllerType.Speed, 1));
5353
}, () => {
5454
this.SendCommand(new PlayerControllerCommand(ControllerType.Speed, -1));
5555
});

0 commit comments

Comments
 (0)