add game completion handling and menu navigation

This commit is contained in:
2026-01-24 02:51:56 +01:00
parent bba82f64fd
commit 1769361bf2

View File

@@ -13,7 +13,9 @@ public partial class GameManager : Node
[Export] private Control _winScreen; [Export] private Control _winScreen;
[Export] private Control _loseScreen; [Export] private Control _loseScreen;
[Export] private Control _gameCompleteScreen;
[Export] private Label _dayLabel; [Export] private Label _dayLabel;
[Export] private PackedScene _mainMenuScene;
private int _currentDayIndex = 0; private int _currentDayIndex = 0;
private Node _currentMiniGame; private Node _currentMiniGame;
@@ -21,7 +23,7 @@ public partial class GameManager : Node
public override void _Ready() public override void _Ready()
{ {
EventBus.OnLiftCompleted += HandleLiftResult; EventBus.OnLiftCompleted += HandleLiftResult;
StartDay(_currentDayIndex); CallDeferred(nameof(StartDay), _currentDayIndex);
} }
public override void _ExitTree() public override void _ExitTree()
@@ -34,7 +36,16 @@ public partial class GameManager : Node
if (index >= _days.Count) if (index >= _days.Count)
{ {
GD.Print("YOU BEAT THE GYM! ALL DAYS COMPLETE."); GD.Print("YOU BEAT THE GYM! ALL DAYS COMPLETE.");
// TODO: Show "Game Complete" screen _currentMiniGame?.QueueFree();
_hazardSystem.ClearHazards();
if (_winScreen != null) _winScreen.Visible = false;
if (_loseScreen != null) _loseScreen.Visible = false;
if (_gameCompleteScreen != null)
{
_gameCompleteScreen.Visible = true;
}
return; return;
} }
@@ -68,18 +79,33 @@ public partial class GameManager : Node
{ {
GD.Print("Day Complete! Next day loading..."); GD.Print("Day Complete! Next day loading...");
if (_winScreen != null) _winScreen.Visible = true; if (_winScreen != null) _winScreen.Visible = true;
// Wait for player input to proceed, or auto-load after delay
// For now, let's auto-advance after 3 seconds for the prototype
GetTree().CreateTimer(3.0f).Timeout += () => NextDay();
} }
else else
{ {
GD.Print("FAIL! Go home."); GD.Print("FAIL! Go home.");
if (_loseScreen != null) _loseScreen.Visible = true; if (_loseScreen != null) _loseScreen.Visible = true;
}
}
// Restart day after delay public void OnNextDayPressed()
GetTree().CreateTimer(3.0f).Timeout += () => RestartDay(); {
NextDay();
}
public void OnRetryPressed()
{
RestartDay();
}
public void OnMenuPressed()
{
if (_mainMenuScene != null)
{
GetTree().ChangeSceneToPacked(_mainMenuScene);
}
else
{
GetTree().Quit();
} }
} }