Delay start for animation

This commit is contained in:
Marco 2025-03-03 10:58:20 +01:00
commit a9a7b234fb
9 changed files with 108 additions and 23 deletions

View file

@ -30,6 +30,8 @@ public partial class Active : PlayerFSMState
[Export] private PlayerDamageReceiver _damageReceiver;
[Export] private ActivationProvider _activationProvider;
[Export] private InteractionController _interactionController;
private bool _isStrafing;
public int MovementSpeed => _isStrafing ? StrafeSpeed : Speed;
@ -51,16 +53,16 @@ public partial class Active : PlayerFSMState
ChangeState(PlayerState.Dead);
};
_damageReceiver.HealthChanged += (value, maxValue) =>
_damageReceiver.HealthDecreased += (value, newValue, maxValue) =>
{
_animationProvider.Blink();
_hud.UpdateHealth(value, maxValue);
//_hud.UpdateHealth(value, maxValue);
};
_damageReceiver.ShieldChanged += (value, maxValue) =>
_damageReceiver.ShieldDecreased += (value, newValue, maxValue) =>
{
_animationProvider.PlayShieldAnimation();
_hud.UpdateShield(value, maxValue);
//_hud.UpdateShield(value, maxValue);
};
_damageReceiver.Init();
@ -84,6 +86,7 @@ public partial class Active : PlayerFSMState
_animationProvider.ShowSprite();
_damageReceiver.Enabled = true;
_activationProvider.Enabled = true;
_interactionController.Enabled = true;
}
public override void ExitState()
@ -94,6 +97,7 @@ public partial class Active : PlayerFSMState
_damageReceiver.Enabled = false;
_activationProvider.Enabled = false;
_interactionController.Enabled = false;
}
public override void PhysicsProcessState(double delta)

View file

@ -1,13 +1,17 @@
using System;
using System.Threading.Tasks;
using Godot;
namespace Cirno.Scripts.Components.FSM.Player;
public partial class Init : PlayerFSMState
{
[Export]
private PlayerAnimationProvider _animationProvider;
public override void EnterState()
{
GD.Print(this.State.ToString());
_animationProvider.PlayUnteleportAnimation();
_ = AutoSwitchToStart();
}
public override void ExitState()
@ -24,4 +28,10 @@ public partial class Init : PlayerFSMState
{
}
private async Task AutoSwitchToStart()
{
await Task.Delay(500);
_stateMachine.SetState((int)PlayerState.Active);
}
}