Fix pausing etc. issues in the minigame
This commit is contained in:
@@ -342,13 +342,13 @@ LineRenderer:
|
|||||||
m_SortingLayer: 0
|
m_SortingLayer: 0
|
||||||
m_SortingOrder: 0
|
m_SortingOrder: 0
|
||||||
m_Positions:
|
m_Positions:
|
||||||
- {x: -0.15602553, y: 4.074945, z: 0}
|
- {x: -0.15602553, y: 4.0749445, z: 0}
|
||||||
- {x: -0.1566351, y: 3.9736383, z: 0}
|
- {x: -0.1566351, y: 3.9736378, z: 0}
|
||||||
- {x: -0.1572447, y: 3.8729858, z: 0}
|
- {x: -0.1572447, y: 3.8729858, z: 0}
|
||||||
- {x: -0.15785426, y: 3.7729874, z: 0}
|
- {x: -0.15785426, y: 3.7729874, z: 0}
|
||||||
- {x: -0.15846384, y: 3.6736436, z: 0}
|
- {x: -0.15846384, y: 3.6736438, z: 0}
|
||||||
- {x: -0.15907341, y: 3.5749543, z: 0}
|
- {x: -0.15907341, y: 3.5749543, z: 0}
|
||||||
- {x: -0.15968299, y: 3.4769192, z: 0}
|
- {x: -0.15968299, y: 3.4769194, z: 0}
|
||||||
- {x: -0.16029257, y: 3.3795385, z: 0}
|
- {x: -0.16029257, y: 3.3795385, z: 0}
|
||||||
- {x: -0.16090216, y: 3.2828126, z: 0}
|
- {x: -0.16090216, y: 3.2828126, z: 0}
|
||||||
- {x: -0.16151173, y: 3.1867406, z: 0}
|
- {x: -0.16151173, y: 3.1867406, z: 0}
|
||||||
@@ -915,7 +915,7 @@ Transform:
|
|||||||
m_GameObject: {fileID: 747976396}
|
m_GameObject: {fileID: 747976396}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: 3.197517, z: 0}
|
m_LocalPosition: {x: 0, y: 3.1975174, z: 0}
|
||||||
m_LocalScale: {x: 0.57574, y: 0.57574, z: 0.57574}
|
m_LocalScale: {x: 0.57574, y: 0.57574, z: 0.57574}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children:
|
m_Children:
|
||||||
@@ -1369,13 +1369,13 @@ LineRenderer:
|
|||||||
m_Positions:
|
m_Positions:
|
||||||
- {x: -0.15602553, y: 4.074945, z: 0}
|
- {x: -0.15602553, y: 4.074945, z: 0}
|
||||||
- {x: -0.11662118, y: 3.8796225, z: 0}
|
- {x: -0.11662118, y: 3.8796225, z: 0}
|
||||||
- {x: -0.07721684, y: 3.7057447, z: 0}
|
- {x: -0.07721684, y: 3.7057445, z: 0}
|
||||||
- {x: -0.03781248, y: 3.5533109, z: 0}
|
- {x: -0.03781248, y: 3.5533106, z: 0}
|
||||||
- {x: 0.0015918687, y: 3.4223216, z: 0}
|
- {x: 0.0015918687, y: 3.4223216, z: 0}
|
||||||
- {x: 0.040996216, y: 3.3127766, z: 0}
|
- {x: 0.040996216, y: 3.3127766, z: 0}
|
||||||
- {x: 0.08040057, y: 3.224676, z: 0}
|
- {x: 0.08040057, y: 3.2246757, z: 0}
|
||||||
- {x: 0.11980491, y: 3.1580195, z: 0}
|
- {x: 0.11980491, y: 3.1580195, z: 0}
|
||||||
- {x: 0.15920927, y: 3.112808, z: 0}
|
- {x: 0.15920927, y: 3.1128078, z: 0}
|
||||||
- {x: 0.1986136, y: 3.0890403, z: 0}
|
- {x: 0.1986136, y: 3.0890403, z: 0}
|
||||||
- {x: 0.23801796, y: 3.0867171, z: 0}
|
- {x: 0.23801796, y: 3.0867171, z: 0}
|
||||||
m_Parameters:
|
m_Parameters:
|
||||||
@@ -1912,13 +1912,13 @@ LineRenderer:
|
|||||||
m_Positions:
|
m_Positions:
|
||||||
- {x: -0.15602553, y: 4.074945, z: 0}
|
- {x: -0.15602553, y: 4.074945, z: 0}
|
||||||
- {x: -0.18956745, y: 3.8764977, z: 0}
|
- {x: -0.18956745, y: 3.8764977, z: 0}
|
||||||
- {x: -0.22310936, y: 3.7000234, z: 0}
|
- {x: -0.22310936, y: 3.7000232, z: 0}
|
||||||
- {x: -0.25665125, y: 3.5455205, z: 0}
|
- {x: -0.25665125, y: 3.5455205, z: 0}
|
||||||
- {x: -0.29019317, y: 3.412991, z: 0}
|
- {x: -0.29019317, y: 3.4129908, z: 0}
|
||||||
- {x: -0.32373506, y: 3.3024333, z: 0}
|
- {x: -0.32373506, y: 3.3024333, z: 0}
|
||||||
- {x: -0.35727698, y: 3.2138486, z: 0}
|
- {x: -0.35727698, y: 3.213848, z: 0}
|
||||||
- {x: -0.39081886, y: 3.1472359, z: 0}
|
- {x: -0.39081886, y: 3.1472356, z: 0}
|
||||||
- {x: -0.4243608, y: 3.1025958, z: 0}
|
- {x: -0.4243608, y: 3.1025953, z: 0}
|
||||||
- {x: -0.45790267, y: 3.0799277, z: 0}
|
- {x: -0.45790267, y: 3.0799277, z: 0}
|
||||||
- {x: -0.4914446, y: 3.0792325, z: 0}
|
- {x: -0.4914446, y: 3.0792325, z: 0}
|
||||||
m_Parameters:
|
m_Parameters:
|
||||||
|
|||||||
@@ -67,20 +67,16 @@ namespace Minigames.DivingForPictures
|
|||||||
SetNextSpawnInterval();
|
SetNextSpawnInterval();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnEnable()
|
|
||||||
{
|
|
||||||
DivingGameManager.Instance.RegisterPausableComponent(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
// Start spawning if not paused
|
// Start spawning if not paused
|
||||||
|
DivingGameManager.Instance.RegisterPausableComponent(this);
|
||||||
StartSpawningCoroutine();
|
StartSpawningCoroutine();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnDestroy()
|
void OnDestroy()
|
||||||
{
|
{
|
||||||
DivingGameManager.Instance.UnregisterPausableComponent(this);
|
DivingGameManager.Instance?.UnregisterPausableComponent(this);
|
||||||
|
|
||||||
// Clean up any active coroutines
|
// Clean up any active coroutines
|
||||||
StopAllCoroutines();
|
StopAllCoroutines();
|
||||||
|
|||||||
@@ -98,24 +98,10 @@ namespace Minigames.DivingForPictures
|
|||||||
public event Action<Monster, float> OnPhotoSequenceCompleted; // Now includes proximity score
|
public event Action<Monster, float> OnPhotoSequenceCompleted; // Now includes proximity score
|
||||||
public event Action<float> OnPhotoSequenceProgressUpdated;
|
public event Action<float> OnPhotoSequenceProgressUpdated;
|
||||||
|
|
||||||
private static DivingGameManager _instance;
|
private static DivingGameManager _instance = null;
|
||||||
private static bool _isQuitting = false;
|
private static bool _isQuitting = false;
|
||||||
public static DivingGameManager Instance
|
|
||||||
{
|
public static DivingGameManager Instance => _instance;
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_instance == null && Application.isPlaying && !_isQuitting)
|
|
||||||
{
|
|
||||||
_instance = FindAnyObjectByType<DivingGameManager>();
|
|
||||||
if (_instance == null)
|
|
||||||
{
|
|
||||||
var go = new GameObject("DivingGameManager");
|
|
||||||
_instance = go.AddComponent<DivingGameManager>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return _instance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,8 +29,11 @@ namespace Minigames.DivingForPictures
|
|||||||
private void OnDestroy()
|
private void OnDestroy()
|
||||||
{
|
{
|
||||||
// Unsubscribe from events
|
// Unsubscribe from events
|
||||||
DivingGameManager.Instance.OnScoreChanged -= UpdateScoreDisplay;
|
if (DivingGameManager.Instance)
|
||||||
DivingGameManager.Instance.OnPictureTaken -= ShowScorePopup;
|
{
|
||||||
|
DivingGameManager.Instance.OnScoreChanged -= UpdateScoreDisplay;
|
||||||
|
DivingGameManager.Instance.OnPictureTaken -= ShowScorePopup;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateScoreDisplay(int score)
|
private void UpdateScoreDisplay(int score)
|
||||||
|
|||||||
@@ -83,14 +83,10 @@ namespace Minigames.DivingForPictures
|
|||||||
onObstacleDestroyed = new UnityEvent<GameObject>();
|
onObstacleDestroyed = new UnityEvent<GameObject>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnEnable()
|
private void Start()
|
||||||
{
|
{
|
||||||
// Register with the DivingGameManager for pause/resume events
|
// Register with the DivingGameManager for pause/resume events
|
||||||
DivingGameManager.Instance.RegisterPausableComponent(this);
|
DivingGameManager.Instance.RegisterPausableComponent(this);
|
||||||
}
|
|
||||||
|
|
||||||
private void Start()
|
|
||||||
{
|
|
||||||
DivingGameManager.Instance.OnGameInitialized += Initialize;
|
DivingGameManager.Instance.OnGameInitialized += Initialize;
|
||||||
|
|
||||||
// If game is already initialized, initialize immediately
|
// If game is already initialized, initialize immediately
|
||||||
@@ -104,7 +100,7 @@ namespace Minigames.DivingForPictures
|
|||||||
|
|
||||||
private void OnDestroy()
|
private void OnDestroy()
|
||||||
{
|
{
|
||||||
DivingGameManager.Instance.UnregisterPausableComponent(this);
|
DivingGameManager.Instance?.UnregisterPausableComponent(this);
|
||||||
|
|
||||||
// Clean up any active coroutines
|
// Clean up any active coroutines
|
||||||
StopAllCoroutines();
|
StopAllCoroutines();
|
||||||
|
|||||||
@@ -43,14 +43,11 @@ namespace Minigames.DivingForPictures.Player
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnEnable()
|
void Start()
|
||||||
{
|
{
|
||||||
// Register as a pausable component with DivingGameManager
|
// Register as a pausable component with DivingGameManager
|
||||||
DivingGameManager.Instance.RegisterPausableComponent(this);
|
DivingGameManager.Instance.RegisterPausableComponent(this);
|
||||||
}
|
|
||||||
|
|
||||||
void Start()
|
|
||||||
{
|
|
||||||
// Initialize target to current position
|
// Initialize target to current position
|
||||||
targetFingerX = transform.position.x;
|
targetFingerX = transform.position.x;
|
||||||
isTouchActive = false;
|
isTouchActive = false;
|
||||||
@@ -114,10 +111,11 @@ namespace Minigames.DivingForPictures.Player
|
|||||||
|
|
||||||
private void OnDestroy()
|
private void OnDestroy()
|
||||||
{
|
{
|
||||||
DivingGameManager.Instance.OnGameInitialized -= Initialize;
|
if (DivingGameManager.Instance)
|
||||||
|
{
|
||||||
// Unregister as a pausable component
|
DivingGameManager.Instance.OnGameInitialized -= Initialize;
|
||||||
DivingGameManager.Instance.UnregisterPausableComponent(this);
|
DivingGameManager.Instance.UnregisterPausableComponent(this);
|
||||||
|
}
|
||||||
|
|
||||||
// Unsubscribe from edge anchor events
|
// Unsubscribe from edge anchor events
|
||||||
if (edgeAnchor != null)
|
if (edgeAnchor != null)
|
||||||
|
|||||||
@@ -168,14 +168,10 @@ namespace Minigames.DivingForPictures
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnEnable()
|
private void Start()
|
||||||
{
|
{
|
||||||
// Register with the DivingGameManager for pause/resume events
|
// Register with the DivingGameManager for pause/resume events
|
||||||
DivingGameManager.Instance.RegisterPausableComponent(this);
|
DivingGameManager.Instance.RegisterPausableComponent(this);
|
||||||
}
|
|
||||||
|
|
||||||
private void Start()
|
|
||||||
{
|
|
||||||
DivingGameManager.Instance.OnGameInitialized += Initialize;
|
DivingGameManager.Instance.OnGameInitialized += Initialize;
|
||||||
|
|
||||||
// If game is already initialized, initialize immediately
|
// If game is already initialized, initialize immediately
|
||||||
@@ -189,7 +185,7 @@ namespace Minigames.DivingForPictures
|
|||||||
|
|
||||||
private void OnDestroy()
|
private void OnDestroy()
|
||||||
{
|
{
|
||||||
DivingGameManager.Instance.UnregisterPausableComponent(this);
|
DivingGameManager.Instance?.UnregisterPausableComponent(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace Minigames.DivingForPictures.Utilities
|
|||||||
|
|
||||||
private bool isPaused = false;
|
private bool isPaused = false;
|
||||||
|
|
||||||
private void OnEnable()
|
private void Start()
|
||||||
{
|
{
|
||||||
DivingGameManager.Instance.RegisterPausableComponent(this);
|
DivingGameManager.Instance.RegisterPausableComponent(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace Minigames.DivingForPictures.Utilities
|
|||||||
|
|
||||||
private bool isPaused = false;
|
private bool isPaused = false;
|
||||||
|
|
||||||
private void OnEnable()
|
private void Start()
|
||||||
{
|
{
|
||||||
DivingGameManager.Instance.RegisterPausableComponent(this);
|
DivingGameManager.Instance.RegisterPausableComponent(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,12 +9,6 @@ public class DivingGameOverScreen : MonoBehaviour
|
|||||||
[SerializeField]
|
[SerializeField]
|
||||||
private TextMeshProUGUI finalScoreText;
|
private TextMeshProUGUI finalScoreText;
|
||||||
|
|
||||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
|
||||||
void Start()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnEnable()
|
void OnEnable()
|
||||||
{
|
{
|
||||||
if (DivingGameManager.Instance != null)
|
if (DivingGameManager.Instance != null)
|
||||||
|
|||||||
@@ -26,9 +26,9 @@ MonoBehaviour:
|
|||||||
spawnCooldown: 5
|
spawnCooldown: 5
|
||||||
basePoints: 100
|
basePoints: 100
|
||||||
depthMultiplier: 10
|
depthMultiplier: 10
|
||||||
speedTransitionDuration: 2
|
speedTransitionDuration: 3
|
||||||
surfacingSpeedFactor: 6
|
surfacingSpeedFactor: 6
|
||||||
surfacingSpawnDelay: 5
|
surfacingSpawnDelay: 2
|
||||||
referenceScreenHeight: 1920
|
referenceScreenHeight: 1920
|
||||||
initialTileCount: 3
|
initialTileCount: 3
|
||||||
tileSpawnBuffer: 2
|
tileSpawnBuffer: 2
|
||||||
|
|||||||
Reference in New Issue
Block a user