SupaLidlGame/Characters/States/PlayerMoveState.cs

48 lines
1.2 KiB
C#
Raw Normal View History

2022-11-13 15:42:04 -08:00
using Godot;
2022-11-19 21:21:12 -08:00
using SupaLidlGame.Items;
2022-11-13 15:42:04 -08:00
namespace SupaLidlGame.Characters.State
{
public partial class PlayerMoveState : PlayerState
{
[Export]
2022-11-19 21:21:12 -08:00
public PlayerRollState RollState { get; set; }
2022-11-13 15:42:04 -08:00
public override CharacterState Enter(CharacterState previousState)
{
Godot.GD.Print("Started moving");
2022-11-19 21:21:12 -08:00
_player.Animation = "move";
2022-11-13 15:42:04 -08:00
return base.Enter(previousState);
}
public override CharacterState Process(double delta)
{
base.Process(delta);
if (Character.Direction.LengthSquared() == 0)
{
return IdleState;
}
return null;
}
2022-11-18 13:53:51 -08:00
public override CharacterState Input(InputEvent @event)
2022-11-13 15:42:04 -08:00
{
if (@event.IsActionPressed("roll"))
{
2022-11-19 21:21:12 -08:00
if (Character.Inventory.SelectedItem is Weapon weapon)
{
if (!weapon.IsUsing)
{
return RollState;
}
}
else
{
return RollState;
}
2022-11-13 15:42:04 -08:00
}
2022-11-19 21:21:12 -08:00
return base.Input(@event);
2022-11-13 15:42:04 -08:00
}
}
}