Added game over

This commit is contained in:
Marco 2025-04-01 11:23:37 +02:00
commit 8151298b44
14 changed files with 160 additions and 35 deletions

View file

@ -18,6 +18,8 @@ public partial class Dead : PlayerStateBase
[Export]
private ActorResourceProvider _motivationProvider;
private bool _isGameOver = false;
public override void EnterState()
{
@ -26,19 +28,21 @@ public partial class Dead : PlayerStateBase
if (_motivationProvider.CurrentResource < 100f)
{
// If motivation is not enough show game over scene
GD.Print("Game over");
Hud.Instance.ShowGameOver();
_isGameOver = true;
}
else
{
// Else show respawn notification
Hud.Instance.ShowGameOver();
Hud.Instance.ShowTerminated();
_isGameOver = false;
}
}
public override void ExitState()
{
// Hide game over
Hud.Instance.HideGameOver();
Hud.Instance.HideTerminated();
}
public override void ProcessState(double delta)
@ -46,7 +50,16 @@ public partial class Dead : PlayerStateBase
// wait for button
if (_inputProvider.GetShootJustPressed())
{
Respawn();
if (_isGameOver)
{
// Restart Level
GlobalState.Instance.RestartLevel();
}
else
{
Respawn();
}
}
}