Revamp game pausing and input handling. Fix minigame tutorial and end sequence. (#39)

- Revamp pausing and centralize management in GameManager
- Switch Pause implementation to be counter-based to solve corner case of multiple pause requests
- Remove duplicated Pause logic from other components
- Add pausing when browsing the card album
- Fully deliver the exclusive UI implementation
- Spruce up the MiniGame tutorial with correct pausing, hiding other UI
- Correctly unpause after showing tutorial
- Fix minigame ending sequence. The cinematic correctly plays only once now
- Replaying the minigame works

Co-authored-by: Michal Adam Pikulski <michal@foolhardyhorizons.com>
Co-authored-by: Michal Pikulski <michal@foolhardyhorizons.com>
Reviewed-on: #39
This commit is contained in:
2025-10-24 11:09:32 +00:00
parent 35acaddca5
commit 5a85a602bd
26 changed files with 1342 additions and 1023 deletions

View File

@@ -25,15 +25,9 @@ namespace Minigames.DivingForPictures
private UnityEngine.Camera _mainCamera; // Cache camera reference
private bool _isSurfacing = false;
// Pause state
private bool _isPaused = false;
// Coroutines for pause/resume
private Coroutine _spawnCoroutine;
// IPausable implementation
public bool IsPaused => _isPaused;
void Awake()
{
_mainCamera = UnityEngine.Camera.main;
@@ -87,10 +81,6 @@ namespace Minigames.DivingForPictures
/// </summary>
public void Pause()
{
if (_isPaused) return; // Already paused
_isPaused = true;
// Stop spawning coroutine
if (_spawnCoroutine != null)
{
@@ -116,10 +106,6 @@ namespace Minigames.DivingForPictures
/// </summary>
public void DoResume()
{
if (!_isPaused) return; // Already running
_isPaused = false;
// Restart spawning coroutine
StartSpawningCoroutine();
@@ -141,7 +127,7 @@ namespace Minigames.DivingForPictures
/// </summary>
private void StartSpawningCoroutine()
{
if (_spawnCoroutine == null && !_isPaused)
if (_spawnCoroutine == null && !GameManager.Instance.IsPaused)
{
_spawnCoroutine = StartCoroutine(SpawnBubblesRoutine());
}
@@ -219,7 +205,7 @@ namespace Minigames.DivingForPictures
bubble.SetWobbleScaleLimits(_devSettings.BubbleWobbleMinScale, _devSettings.BubbleWobbleMaxScale);
// If the game is already paused, pause this bubble immediately
if (_isPaused)
if (GameManager.Instance.IsPaused)
{
bubble.Pause();
}
@@ -262,7 +248,7 @@ namespace Minigames.DivingForPictures
{
Logging.Debug("[BubbleSpawner] Started bubble spawning coroutine");
while (enabled && gameObject.activeInHierarchy && !_isPaused)
while (enabled && gameObject.activeInHierarchy && !GameManager.Instance.IsPaused)
{
SpawnBubble();
SetNextSpawnInterval(); // Set interval for next spawn