SupaLidlGame/State/Weapon/SwordAnticipateState.cs

47 lines
1.2 KiB
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 SwordAnticipateState : WeaponState
2023-05-23 00:23:53 -07:00
{
[Export]
public SupaLidlGame.Items.Weapons.Sword Sword { get; set; }
[Export]
public SwordAttackState AttackState { get; set; }
private double _anticipateTime;
2023-05-26 17:42:50 -07:00
public override WeaponState Enter(IState<WeaponState> prevState)
2023-05-23 00:23:53 -07:00
{
Sword.EnableParry();
if (Sword.Character is SupaLidlGame.Characters.Player)
{
return AttackState;
}
if (Sword.Anchor.Rotation > Mathf.DegToRad(50))
{
Sword.AnimationPlayer.Play("anticipate_alternate");
}
else
{
Sword.AnimationPlayer.Play("anticipate");
}
_anticipateTime = Sword.NPCAnticipateTime;
return null;
}
2023-05-26 17:42:50 -07:00
public override WeaponState Process(double delta)
2023-05-23 00:23:53 -07:00
{
// go into attack state if anticipation time is delta
if ((_anticipateTime -= delta) <= 0)
{
return AttackState;
}
return null;
}
}
}