Add a dirty booster pack opening sequence

This commit is contained in:
Michal Adam Pikulski
2025-10-21 15:40:47 +02:00
parent c71836c029
commit 00f6d2c6c6
11 changed files with 1874 additions and 436 deletions

View File

@@ -685,6 +685,12 @@ namespace Minigames.DivingForPictures
// Call this when the game ends
public void EndGame()
{
// Start the end game sequence that grants a booster, waits for the UI animation, then shows Game Over.
StartCoroutine(EndGameSequence());
}
private IEnumerator EndGameSequence()
{
// Clean up active monsters
foreach (var monster in activeMonsters.ToArray())
@@ -694,10 +700,38 @@ namespace Minigames.DivingForPictures
monster.DespawnMonster();
}
}
CinematicsManager.Instance.ShowGameOverScreen();
activeMonsters.Clear();
// 1) Call the booster pack giver if available
bool completed = false;
var giver = UI.CardSystem.BoosterPackGiver.Instance;
if (giver != null)
{
// Temporarily subscribe to completion
UnityAction onDone = null;
onDone = () => { completed = true; giver.OnCompleted.RemoveListener(onDone); };
giver.OnCompleted.AddListener(onDone);
giver.GiveBoosterPack();
// 2) Wait for it to finish (with a safety timeout in case it's not wired)
float timeout = 5f; // fallback to avoid blocking forever
float elapsed = 0f;
while (!completed && elapsed < timeout)
{
elapsed += Time.unscaledDeltaTime;
yield return null;
}
}
else
{
// If no giver is present, proceed immediately
Logging.Debug("[DivingGameManager] BoosterPackGiver not found; skipping booster animation.");
}
// 3) Only then show the game over screen
CinematicsManager.Instance.ShowGameOverScreen();
// Final score could be saved to player prefs or other persistence
Logging.Debug($"Final Score: {playerScore}");
}