SupaLidlGame/State/Weapon/SwordAnticipateState.cs

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