Added GameOver screen and win/death logic. Game can now officially be finished (Positive and Negative)

This commit is contained in:
2026-05-09 15:23:10 +02:00
parent 5eab205a9c
commit 78d1014067
3 changed files with 76 additions and 4 deletions
+22 -1
View File
@@ -23,6 +23,7 @@ public partial class UIHandler : Control
[Export] RichTextLabel currentLayer;
[Export] RichTextLabel deepestLayer;
[Export] Button unlockLayer;
[Export] PanelContainer gameOver;
private bool receivedRobotJumpSignal = false;
@@ -163,12 +164,20 @@ public partial class UIHandler : Control
waterLabel.Text = $"Water: {GameData.survival.thirst:0}/{GameData.survival.maxThirst:0}";
hungerLabel.Text = $"Food: {GameData.survival.hunger:0}/{GameData.survival.maxHunger:0}";
survivalStatus.Text = GameData.survival.currentStatus;
if (GameData.survival.isDead)
{
ShowGameOver();
}
}
private void DisplayWorldStats()
{
currentLayer.Text = $"Current layer: {GameData.currentLayer}/{GameData.ruinSize}";
deepestLayer.Text = $"Deepest layer: {GameData.lowestLayer}";
if(GameData.lowestLayer == GameData.ruinSize){
unlockLayer.Visible = false;
return;
}
unlockLayer.TooltipText = "Needed items: \r" + GameData.map[GameData.lowestLayer].DisplayGateIngredients();
unlockLayer.Disabled = !GameData.inventory.CanCraft(GameData.map[GameData.lowestLayer].gateIngredients, 1);
}
@@ -184,8 +193,20 @@ public partial class UIHandler : Control
GameData.lowestLayer++;
if (GameData.lowestLayer == GameData.ruinSize)
{
GD.Print("GAME WON!");
gameOver.Show();
}
}
}
public void ShowGameOver()
{
if(gameOver.Visible) return;
gameOver.GetNode<RichTextLabel>("./VBoxContainer/Content").Text = $"[font_size=32]You died! \r Reason: {GameData.survival.deathReason} \r Better luck next time \r";
gameOver.Show();
}
public void HideGameOver()
{
gameOver.Hide();
}
}
+2 -2
View File
@@ -82,7 +82,7 @@ public partial class World : Node3D
public override void _Process(double delta)
{
GameData.survival.Update(delta);
survival.Update(delta);
if (!canMove) return;
if (Input.IsActionJustPressed("layer_up") && currentLayer > 0) currentLayer--;
@@ -308,4 +308,4 @@ public partial class World : Node3D
}
}
}
}
}