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

55 lines
1.2 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;
2025-03-05 10:55:14 +01:00
public partial class Dead : PlayerStateBase
2025-03-01 14:08:31 +01:00
{
2025-03-05 10:55:14 +01:00
public override PlayerState StateId => PlayerState.Dead;
2025-03-01 14:08:31 +01:00
[Export]
private PlayerAnimationProvider _animationProvider;
2025-03-01 20:50:47 +01:00
[Export]
private InputProvider _inputProvider;
[Export]
private ActorResourceProvider _healthProvider;
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
2025-03-05 10:55:14 +01:00
Hud.Instance.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-05 10:55:14 +01:00
Hud.Instance.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()
{
2025-03-05 10:55:14 +01:00
MainObject.GlobalPosition = GameManager.Instance.LastCheckpointPosition;
2025-03-01 20:50:47 +01:00
_healthProvider.FillResource();
2025-03-05 10:55:14 +01:00
GameManager.Instance.ClearBullets();
2025-03-01 20:50:47 +01:00
2025-03-05 10:55:14 +01:00
ChangeState(PlayerState.Active);
2025-03-01 20:50:47 +01:00
}
2025-03-01 14:08:31 +01:00
}