Add backbone for card creation and implement Camera minigame mechanics
This commit is contained in:
@@ -37,7 +37,7 @@ namespace Minigames.DivingForPictures
|
||||
|
||||
private int _spawnCounter;
|
||||
private float _speedUpTimer;
|
||||
private Camera _mainCamera;
|
||||
private UnityEngine.Camera _mainCamera;
|
||||
private float _screenBottom;
|
||||
private float _screenTop;
|
||||
private TrenchTilePool _tilePool;
|
||||
@@ -76,7 +76,7 @@ namespace Minigames.DivingForPictures
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_mainCamera = Camera.main;
|
||||
_mainCamera = UnityEngine.Camera.main;
|
||||
|
||||
// Get settings from GameManager
|
||||
_settings = GameManager.GetSettingsObject<IDivingMinigameSettings>();
|
||||
@@ -125,38 +125,23 @@ namespace Minigames.DivingForPictures
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// Find DivingGameManager and subscribe to its initialization event
|
||||
DivingGameManager gameManager = FindFirstObjectByType<DivingGameManager>();
|
||||
if (gameManager != null)
|
||||
DivingGameManager.Instance.OnGameInitialized += Initialize;
|
||||
|
||||
// Register with the DivingGameManager for pause/resume events
|
||||
DivingGameManager.Instance.RegisterPausableComponent(this);
|
||||
|
||||
// If game is already initialized, initialize immediately
|
||||
if (DivingGameManager.Instance.GetType().GetField("_isGameInitialized",
|
||||
System.Reflection.BindingFlags.NonPublic |
|
||||
System.Reflection.BindingFlags.Instance)?.GetValue(DivingGameManager.Instance) is bool isInitialized && isInitialized)
|
||||
{
|
||||
gameManager.OnGameInitialized += Initialize;
|
||||
|
||||
// Register with the DivingGameManager for pause/resume events
|
||||
gameManager.RegisterPausableComponent(this);
|
||||
|
||||
// If game is already initialized, initialize immediately
|
||||
if (gameManager.GetType().GetField("_isGameInitialized",
|
||||
System.Reflection.BindingFlags.NonPublic |
|
||||
System.Reflection.BindingFlags.Instance)?.GetValue(gameManager) is bool isInitialized && isInitialized)
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("[TrenchTileSpawner] DivingGameManager not found. Initializing immediately.");
|
||||
Initialize();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
// Unregister from DivingGameManager
|
||||
DivingGameManager gameManager = FindFirstObjectByType<DivingGameManager>();
|
||||
if (gameManager != null)
|
||||
{
|
||||
gameManager.UnregisterPausableComponent(this);
|
||||
}
|
||||
DivingGameManager.Instance.UnregisterPausableComponent(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -199,7 +184,7 @@ namespace Minigames.DivingForPictures
|
||||
/// <summary>
|
||||
/// Resumes the spawner and all associated processes
|
||||
/// </summary>
|
||||
public void Resume()
|
||||
public void DoResume()
|
||||
{
|
||||
if (!_isPaused) return; // Already running
|
||||
|
||||
@@ -386,7 +371,7 @@ namespace Minigames.DivingForPictures
|
||||
{
|
||||
if (_mainCamera == null)
|
||||
{
|
||||
_mainCamera = Camera.main;
|
||||
_mainCamera = UnityEngine.Camera.main;
|
||||
if (_mainCamera == null)
|
||||
{
|
||||
Debug.LogError("No main camera found!");
|
||||
@@ -904,7 +889,7 @@ namespace Minigames.DivingForPictures
|
||||
if (!Application.isPlaying)
|
||||
{
|
||||
// Only try to calculate this if _screenBottom hasn't been set by the game
|
||||
Camera editorCam = Camera.main;
|
||||
UnityEngine.Camera editorCam = UnityEngine.Camera.main;
|
||||
if (editorCam != null)
|
||||
{
|
||||
Vector3 bottom = editorCam.ViewportToWorldPoint(new Vector3(0.5f, 0f, editorCam.nearClipPlane));
|
||||
|
||||
Reference in New Issue
Block a user