SupaLidlGame/State/Weapon/SwordIdleState.cs

52 lines
1.0 KiB
C#
Raw Normal View History

2023-05-23 00:23:53 -07:00
using Godot;
2023-06-03 18:21:46 -07:00
namespace SupaLidlGame.State.Weapon;
public partial class SwordIdleState : WeaponState
2023-05-23 00:23:53 -07:00
{
2023-06-03 18:21:46 -07:00
[Export]
public SwordAnticipateState AnticipateState { get; set; }
2023-05-23 00:23:53 -07:00
2023-06-03 18:21:46 -07:00
[Export]
public SupaLidlGame.Items.Weapons.Sword Sword { get; set; }
2023-05-23 00:23:53 -07:00
2023-06-03 18:21:46 -07:00
private double _attackCooldown;
2023-05-23 00:23:53 -07:00
2023-06-03 18:21:46 -07:00
public override WeaponState Enter(IState<WeaponState> prevState)
{
if (prevState is SwordAttackState)
2023-05-23 00:23:53 -07:00
{
2023-06-03 18:21:46 -07:00
_attackCooldown = Sword.UseTime - Sword.AttackTime;
}
2023-05-28 10:57:23 -07:00
2023-06-03 18:21:46 -07:00
Sword.Visible = !Sword.ShouldHideIdle;
2023-05-28 10:57:23 -07:00
2023-06-03 18:21:46 -07:00
return null;
}
2023-05-23 00:23:53 -07:00
2023-06-03 18:21:46 -07:00
public override void Exit(IState<WeaponState> nextState)
{
Sword.Visible = true;
}
2023-05-28 10:57:23 -07:00
2023-06-03 18:21:46 -07:00
public override WeaponState Use()
{
if (_attackCooldown <= 0)
2023-05-23 00:23:53 -07:00
{
return AnticipateState;
}
2023-06-03 18:21:46 -07:00
return AnticipateState;
}
2023-05-23 00:23:53 -07:00
2023-06-03 18:21:46 -07:00
public override WeaponState Process(double delta)
{
if (_attackCooldown > 0)
{
_attackCooldown -= delta;
2023-05-23 00:23:53 -07:00
}
2023-06-03 18:21:46 -07:00
return null;
2023-05-23 00:23:53 -07:00
}
}