-
Notifications
You must be signed in to change notification settings - Fork 0
/
Walk.cs
28 lines (23 loc) · 837 Bytes
/
Walk.cs
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
using Godot;
using HexapusNew.helpers;
namespace PlayerStateMachine;
public partial class Walk: PlayerState {
public override void Enter() {
player.PlayAnimation(AnimationName.walk);
}
public override void PhysicsUpdate(double delta) {
var inputVector = GameManager.GetInputVector();
if (inputVector != Vector2.Zero) {
player.Move(inputVector, delta);
player.ApplyVelocity(delta);
}
// Not too happy with this state knowing which next state to transition to
// TODO: Maybe have an intermediary that knows which states come next?
if (inputVector == Vector2.Zero) {
EmitSignal(PlayerState.SignalName.transition, StateName.idle);
}
}
public override void Exit() {
player.StopAllAnimations();
}
}