mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 09:55:35 +00:00
Added game over
This commit is contained in:
parent
1e116090e5
commit
8151298b44
14 changed files with 160 additions and 35 deletions
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue