mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
91 lines
No EOL
2.2 KiB
C#
91 lines
No EOL
2.2 KiB
C#
using Cirno.Scripts.Components.Actors;
|
|
using Cirno.Scripts.Components.Actors._3D;
|
|
using Cirno.Scripts.Controllers;
|
|
using Godot;
|
|
|
|
namespace Cirno.Scripts.Components.FSM._3DPlayer;
|
|
|
|
public partial class Dead : BaseState<PlayerState, CharacterBody3D>
|
|
{
|
|
public override PlayerState StateId => PlayerState.Dead;
|
|
|
|
[Export]
|
|
private ActorResourceProvider _motivationProvider;
|
|
[Export]
|
|
private InputProvider _inputProvider;
|
|
|
|
[Export]
|
|
private ActorResourceProvider _healthProvider;
|
|
|
|
[Export]
|
|
private PlayerAnimationProvider3D _animationProvider;
|
|
|
|
private bool _isGameOver = false;
|
|
|
|
public override void EnterState()
|
|
{
|
|
base.EnterState();
|
|
//MainObject.Hide();
|
|
|
|
_animationProvider.PlayDeathAnimation();
|
|
|
|
|
|
if (_motivationProvider.CurrentResource < 100f)
|
|
{
|
|
// If motivation is not enough show game over scene
|
|
Hud.Instance.ShowGameOver();
|
|
_isGameOver = true;
|
|
}
|
|
else
|
|
{
|
|
// Else show respawn notification
|
|
Hud.Instance.ShowTerminated();
|
|
_isGameOver = false;
|
|
}
|
|
}
|
|
|
|
public override void ExitState()
|
|
{
|
|
base.ExitState();
|
|
Hud.Instance.HideTerminated();
|
|
}
|
|
|
|
public override void PhysicsProcessState(double delta)
|
|
{
|
|
base.PhysicsProcessState(delta);
|
|
}
|
|
|
|
public override void ProcessState(double delta)
|
|
{
|
|
base.ProcessState(delta);
|
|
|
|
if (_inputProvider.GetShootJustPressed())
|
|
{
|
|
if (_isGameOver)
|
|
{
|
|
// Restart Level
|
|
GlobalState.Instance.RestartLevel();
|
|
}
|
|
else
|
|
{
|
|
Respawn();
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
public void Respawn()
|
|
{
|
|
MainObject.GlobalPosition = GameController.Instance.LastCheckPointPosition;
|
|
_healthProvider.FillResource();
|
|
PoolingManager.Instance.ClearBullets();
|
|
|
|
_motivationProvider.CurrentResource -= 100f;
|
|
if (_motivationProvider.CurrentResource <= 1f)
|
|
{
|
|
_motivationProvider.CurrentResource = 1f;
|
|
}
|
|
|
|
ChangeState(PlayerState.Active);
|
|
}
|
|
} |