mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:05:34 +00:00
FSM Player health and animations
This commit is contained in:
parent
af0261ce8e
commit
f91df43caa
13 changed files with 317 additions and 32 deletions
|
|
@ -7,7 +7,7 @@ namespace Cirno.Scripts.Components.FSM.Player;
|
|||
public partial class Active : PlayerFSMState
|
||||
{
|
||||
private Vector2 _movementDirection { get; set; }
|
||||
public Vector2 FacingDirection { get; private set; }
|
||||
public Vector2 FacingDirection { get; private set; } = Vector2.Down;
|
||||
|
||||
[Export]
|
||||
public int Speed { get; set; } = 45;
|
||||
|
|
@ -27,16 +27,37 @@ public partial class Active : PlayerFSMState
|
|||
[Export]
|
||||
private InputProvider _inputProvider;
|
||||
|
||||
[Export] private PlayerDamageReceiver _damageReceiver;
|
||||
|
||||
private bool _isStrafing;
|
||||
|
||||
|
||||
|
||||
public int MovementSpeed => _isStrafing ? StrafeSpeed : Speed;
|
||||
|
||||
private PlayerStateMachine _player;
|
||||
|
||||
public override void Init(ActorStateMachine stateMachine)
|
||||
{
|
||||
base.Init(stateMachine);
|
||||
|
||||
_player = (PlayerStateMachine)stateMachine;
|
||||
|
||||
_damageReceiver.Death += () =>
|
||||
{
|
||||
ChangeState(PlayerState.Dead);
|
||||
};
|
||||
|
||||
_damageReceiver.HealthChanged += (value, maxValue) =>
|
||||
{
|
||||
_animationProvider.Blink();
|
||||
};
|
||||
|
||||
_damageReceiver.ShieldChanged += (value, maxValue) =>
|
||||
{
|
||||
_animationProvider.PlayShieldAnimation();
|
||||
};
|
||||
|
||||
_damageReceiver.Init();
|
||||
|
||||
//_weaponProvider = stateMachine.GetNode<PlayerWeaponProvider>("WeaponProvider");
|
||||
//_animationProvider = stateMachine.GetNode<PlayerAnimationProvider>("AnimationProvider");
|
||||
|
||||
|
|
@ -48,6 +69,8 @@ public partial class Active : PlayerFSMState
|
|||
// enable sprite
|
||||
// enable crosshair
|
||||
_crosshairProvider.Show();
|
||||
|
||||
_damageReceiver.Enabled = true;
|
||||
}
|
||||
|
||||
public override void ExitState()
|
||||
|
|
@ -55,6 +78,8 @@ public partial class Active : PlayerFSMState
|
|||
_animationProvider.SetAnimation(Vector2.Zero);
|
||||
_crosshairProvider.Hide();
|
||||
_hitboxSpriteProvider.Hide();
|
||||
|
||||
_damageReceiver.Enabled = false;
|
||||
}
|
||||
|
||||
public override void PhysicsProcessState(double delta)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue