34 lines
960 B
C#
34 lines
960 B
C#
using Godot;
|
|
using System;
|
|
using DungeonRPG.Scripts.General;
|
|
|
|
public partial class PlayerMoveState : PlayerState
|
|
{
|
|
|
|
[Export(PropertyHint.Range, "0, 20,0.1")] private float speed = 5;
|
|
public override void _PhysicsProcess(double delta)
|
|
{
|
|
if (characterNode.Direction == Vector2.Zero)
|
|
{
|
|
characterNode.StateMachine.SwitchState<PlayerIdleState>();
|
|
return;
|
|
}
|
|
|
|
characterNode.Velocity = new Vector3(characterNode.Direction.X, 0, characterNode.Direction.Y);
|
|
characterNode.Velocity *= speed;
|
|
characterNode.MoveAndSlide();
|
|
}
|
|
|
|
public override void _Input(InputEvent @event)
|
|
{
|
|
if (Input.IsActionJustPressed(GameConstants.INPUT_DASH))
|
|
{
|
|
characterNode.StateMachine.SwitchState<PlayerDashState>();
|
|
}
|
|
}
|
|
protected override void EnterState()
|
|
{
|
|
characterNode.AnimatedSprite.Play(GameConstants.ANIM_MOVE);
|
|
}
|
|
}
|