Fix up the UI + game flow in minigame, should function correctly now

This commit is contained in:
Michal Pikulski
2025-10-24 13:01:19 +02:00
parent 1003c3f6ac
commit 04737ab01b
11 changed files with 919 additions and 1203 deletions

View File

@@ -9,6 +9,7 @@ using System.Collections;
using System.Collections.Generic;
using Bootstrap;
using UI;
using UI.Core;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Playables;
@@ -117,6 +118,9 @@ namespace Minigames.DivingForPictures
{
Destroy(gameObject);
}
// Ensure any previous run state is reset when this manager awakes
_isGameOver = false;
}
private void OnApplicationQuit()
@@ -457,6 +461,9 @@ namespace Minigames.DivingForPictures
_isSurfacing = true;
// TODO: Call it here?
UIPageController.Instance.HideAllUI();
// 1. Initiate smooth velocity transition to surfacing speed
float targetVelocityFactor = -1.0f * _settings.SurfacingSpeedFactor;
SetVelocityFactor(targetVelocityFactor);
@@ -693,6 +700,7 @@ namespace Minigames.DivingForPictures
UnityAction onDone = null;
onDone = () => { completed = true; giver.OnCompleted.RemoveListener(onDone); };
giver.OnCompleted.AddListener(onDone);
UIPageController.Instance.ShowAllUI();
giver.GiveBoosterPack();
// 2) Wait for it to finish (with a safety timeout in case it's not wired)
@@ -712,7 +720,7 @@ namespace Minigames.DivingForPictures
// 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}");
}
@@ -799,40 +807,46 @@ namespace Minigames.DivingForPictures
/// </summary>
public void Pause()
{
// Ignore pause requests once the game has reached Game Over
if (_isGameOver) return;
DoPause();
}
public void DoPause(bool turnOffGameInput = true)
{
// Pause all registered components
foreach (var component in _pausableComponents)
{
component.Pause();
}
// Change input mode to UI when menu is open
if(turnOffGameInput)
InputManager.Instance.SetInputMode(InputMode.GameAndUI);
Logging.Debug($"[DivingGameManager] Game paused. Paused {_pausableComponents.Count} components.");
}
/// <summary>
/// Resume the game and all registered components
/// </summary>
public void DoResume()
{
// Resume all registered components
foreach (var component in _pausableComponents)
{
component.DoResume();
}
// Change input mode to UI when menu is open
InputManager.Instance.SetInputMode(InputMode.GameAndUI);
Logging.Debug($"[DivingGameManager] Game resumed. Resumed {_pausableComponents.Count} components.");
}
}
public void DoPause(bool turnOffGameInput = true)
{
// Ignore pause requests once the game has ended
if (_isGameOver) return;
// Pause all registered components
foreach (var component in _pausableComponents)
{
component.Pause();
}
// Change input mode to UI when menu is open
if(turnOffGameInput)
InputManager.Instance.SetInputMode(InputMode.GameAndUI);
Logging.Debug($"[DivingGameManager] Game paused. Paused {_pausableComponents.Count} components.");
}
/// <summary>
/// Resume the game and all registered components
/// </summary>
public void DoResume()
{
// Ignore resume requests once the game has ended
if (_isGameOver) return;
// Resume all registered components
foreach (var component in _pausableComponents)
{
component.DoResume();
}
// Change input mode to UI when menu is open
InputManager.Instance.SetInputMode(InputMode.GameAndUI);
Logging.Debug($"[DivingGameManager] Game resumed. Resumed {_pausableComponents.Count} components.");
}
#region Photo Sequence Methods