mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 10:55:35 +00:00
64 lines
No EOL
1.4 KiB
C#
64 lines
No EOL
1.4 KiB
C#
using Cirno.Scripts.Components.Actors;
|
|
using Godot;
|
|
|
|
namespace Cirno.Scripts.Components.FSM.Player;
|
|
|
|
public partial class Dead : PlayerFSMState
|
|
{
|
|
[Export]
|
|
private PlayerAnimationProvider _animationProvider;
|
|
|
|
[Export]
|
|
private InputProvider _inputProvider;
|
|
|
|
[Export]
|
|
private ActorResourceProvider _healthProvider;
|
|
|
|
private GameManager _gameManager;
|
|
private Hud _hud;
|
|
|
|
public override void Init(ActorStateMachine stateMachine)
|
|
{
|
|
base.Init(stateMachine);
|
|
|
|
_gameManager = GameManager.Instance;
|
|
_hud = Hud.Instance;
|
|
}
|
|
|
|
public override void EnterState()
|
|
{
|
|
_animationProvider.PlayDeathAnimation();
|
|
// show game over
|
|
|
|
_hud.ShowGameOver();
|
|
}
|
|
|
|
public override void ExitState()
|
|
{
|
|
// Hide game over
|
|
_hud.HideGameOver();
|
|
}
|
|
|
|
public override void ProcessState(double delta)
|
|
{
|
|
// wait for button
|
|
if (_inputProvider.GetShootJustPressed())
|
|
{
|
|
Respawn();
|
|
}
|
|
}
|
|
|
|
public override void PhysicsProcessState(double delta)
|
|
{
|
|
|
|
}
|
|
|
|
public void Respawn()
|
|
{
|
|
_stateMachine.GlobalPosition = _gameManager.LastCheckpointPosition;
|
|
_healthProvider.FillResource();
|
|
_gameManager.ClearBullets();
|
|
|
|
_stateMachine.SetState((int)PlayerState.Active);
|
|
}
|
|
} |