SupaLidlGame/State/Weapon/SwordIdleState.cs

45 lines
1010 B
C#
Raw Normal View History

2023-05-23 00:23:53 -07:00
using Godot;
2023-05-26 17:42:50 -07:00
namespace SupaLidlGame.State.Weapon
2023-05-23 00:23:53 -07:00
{
2023-05-26 17:42:50 -07:00
public partial class SwordIdleState : WeaponState
2023-05-23 00:23:53 -07:00
{
[Export]
public SwordAnticipateState AnticipateState { get; set; }
[Export]
public SupaLidlGame.Items.Weapons.Sword Sword { get; set; }
private double _attackCooldown;
2023-05-26 17:42:50 -07:00
public override WeaponState Enter(IState<WeaponState> prevState)
2023-05-23 00:23:53 -07:00
{
if (prevState is SwordAttackState)
{
_attackCooldown = Sword.UseTime - Sword.AttackTime;
}
return null;
}
2023-05-26 17:42:50 -07:00
public override WeaponState Use()
2023-05-23 00:23:53 -07:00
{
if (_attackCooldown <= 0)
{
return AnticipateState;
}
return AnticipateState;
}
2023-05-26 17:42:50 -07:00
public override WeaponState Process(double delta)
2023-05-23 00:23:53 -07:00
{
if (_attackCooldown > 0)
{
_attackCooldown -= delta;
}
return null;
}
}
}