2022-11-13 15:42:04 -08:00
|
|
|
using Godot;
|
|
|
|
|
2023-05-25 15:28:33 -07:00
|
|
|
namespace SupaLidlGame.State.Character
|
2022-11-13 15:42:04 -08:00
|
|
|
{
|
|
|
|
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
|
|
|
|
2023-05-25 15:28:33 -07:00
|
|
|
public override IState<CharacterState> Enter(IState<CharacterState> previousState)
|
2022-11-13 15:42:04 -08:00
|
|
|
{
|
|
|
|
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"))
|
|
|
|
{
|
2023-05-26 17:42:50 -07:00
|
|
|
if (Character.Inventory.SelectedItem is Items.Weapon weapon)
|
2022-11-19 21:21:12 -08:00
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|