mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-13 04:55:54 +00:00
Migrated player state machine
This commit is contained in:
parent
bb3cdefaa2
commit
9c3f22760b
19 changed files with 108 additions and 69 deletions
|
|
@ -3,8 +3,10 @@ using Godot;
|
|||
|
||||
namespace Cirno.Scripts.Components.FSM.Player;
|
||||
|
||||
public partial class Dead : PlayerFSMState
|
||||
public partial class Dead : PlayerStateBase
|
||||
{
|
||||
public override PlayerState StateId => PlayerState.Dead;
|
||||
|
||||
[Export]
|
||||
private PlayerAnimationProvider _animationProvider;
|
||||
|
||||
|
|
@ -13,30 +15,19 @@ public partial class Dead : PlayerFSMState
|
|||
|
||||
[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();
|
||||
Hud.Instance.ShowGameOver();
|
||||
}
|
||||
|
||||
public override void ExitState()
|
||||
{
|
||||
// Hide game over
|
||||
_hud.HideGameOver();
|
||||
Hud.Instance.HideGameOver();
|
||||
}
|
||||
|
||||
public override void ProcessState(double delta)
|
||||
|
|
@ -55,10 +46,10 @@ public partial class Dead : PlayerFSMState
|
|||
|
||||
public void Respawn()
|
||||
{
|
||||
_stateMachine.GlobalPosition = _gameManager.LastCheckpointPosition;
|
||||
MainObject.GlobalPosition = GameManager.Instance.LastCheckpointPosition;
|
||||
_healthProvider.FillResource();
|
||||
_gameManager.ClearBullets();
|
||||
GameManager.Instance.ClearBullets();
|
||||
|
||||
_stateMachine.SetState((int)PlayerState.Active);
|
||||
ChangeState(PlayerState.Active);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue