cirnogodot/Scripts/Components/FSM/Player/Dead.cs

64 lines
1.4 KiB
C#
Raw Normal View History

2025-03-01 20:50:47 +01:00
using Cirno.Scripts.Components.Actors;
using Godot;
2025-03-01 14:08:31 +01:00
namespace Cirno.Scripts.Components.FSM.Player;
public partial class Dead : PlayerFSMState
{
[Export]
private PlayerAnimationProvider _animationProvider;
2025-03-01 20:50:47 +01:00
[Export]
private InputProvider _inputProvider;
[Export]
private ActorResourceProvider _healthProvider;
private GameManager _gameManager;
private Hud _hud;
2025-03-01 18:02:11 +01:00
public override void Init(ActorStateMachine stateMachine)
{
base.Init(stateMachine);
2025-03-01 20:50:47 +01:00
_gameManager = GameManager.Instance;
_hud = Hud.Instance;
2025-03-01 18:02:11 +01:00
}
2025-03-01 14:08:31 +01:00
public override void EnterState()
{
_animationProvider.PlayDeathAnimation();
2025-03-01 18:02:11 +01:00
// show game over
2025-03-01 20:50:47 +01:00
_hud.ShowGameOver();
2025-03-01 14:08:31 +01:00
}
public override void ExitState()
{
2025-03-01 18:02:11 +01:00
// Hide game over
2025-03-01 20:50:47 +01:00
_hud.HideGameOver();
2025-03-01 14:08:31 +01:00
}
public override void ProcessState(double delta)
{
2025-03-01 18:02:11 +01:00
// wait for button
2025-03-01 20:50:47 +01:00
if (_inputProvider.GetShootJustPressed())
{
Respawn();
}
2025-03-01 14:08:31 +01:00
}
public override void PhysicsProcessState(double delta)
{
}
2025-03-01 20:50:47 +01:00
public void Respawn()
{
_stateMachine.GlobalPosition = _gameManager.LastCheckpointPosition;
_healthProvider.FillResource();
_gameManager.ClearBullets();
_stateMachine.SetState((int)PlayerState.Active);
}
2025-03-01 14:08:31 +01:00
}