Clean up IPausable interafaces a little bit and start refactoring the pause-game flow in the minigame
This commit is contained in:
@@ -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,9 +81,7 @@ namespace Minigames.DivingForPictures
|
||||
/// </summary>
|
||||
public void Pause()
|
||||
{
|
||||
if (_isPaused) return; // Already paused
|
||||
|
||||
_isPaused = true;
|
||||
if (GameManager.Instance.IsPaused) return; // Already paused
|
||||
|
||||
// Stop spawning coroutine
|
||||
if (_spawnCoroutine != null)
|
||||
@@ -116,9 +108,7 @@ namespace Minigames.DivingForPictures
|
||||
/// </summary>
|
||||
public void DoResume()
|
||||
{
|
||||
if (!_isPaused) return; // Already running
|
||||
|
||||
_isPaused = false;
|
||||
if (!GameManager.Instance.IsPaused) return; // Already running
|
||||
|
||||
// Restart spawning coroutine
|
||||
StartSpawningCoroutine();
|
||||
@@ -141,7 +131,7 @@ namespace Minigames.DivingForPictures
|
||||
/// </summary>
|
||||
private void StartSpawningCoroutine()
|
||||
{
|
||||
if (_spawnCoroutine == null && !_isPaused)
|
||||
if (_spawnCoroutine == null && !GameManager.Instance.IsPaused)
|
||||
{
|
||||
_spawnCoroutine = StartCoroutine(SpawnBubblesRoutine());
|
||||
}
|
||||
@@ -219,7 +209,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 +252,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
|
||||
|
||||
Reference in New Issue
Block a user