IMplement basic Developer Settings

This commit is contained in:
2025-09-24 12:21:21 +02:00
parent f07ce88331
commit 8b96a5d0c3
18 changed files with 739 additions and 248 deletions

View File

@@ -1,5 +1,6 @@
using UnityEngine;
using Pooling;
using AppleHills.Core.Settings;
namespace Minigames.DivingForPictures
{
@@ -10,25 +11,9 @@ namespace Minigames.DivingForPictures
{
public Bubble bubblePrefab;
public Sprite[] bubbleSprites; // Assign in inspector
public float spawnInterval = 0.3f;
public Vector2 speedRange = new Vector2(0.5f, 2f);
public Vector2 scaleRange = new Vector2(0.3f, 0.7f);
public Vector2 wobbleSpeedRange = new Vector2(1f, 3f);
public Vector2 wobbleAmountRange = new Vector2(0.05f, 0.15f);
public float spawnXMin = -3.5f;
public float spawnXMax = 3.5f;
public float spawnY = -5f;
public float wobbleMinScale = 0.2f;
public float wobbleMaxScale = 1.2f;
[Header("Object Pooling")]
public bool useObjectPooling = true;
public int initialPoolSize = 10;
public int maxPoolSize = 30;
[Header("Surfacing Settings")]
[Tooltip("Factor to multiply bubble speed by when surfacing (0.5 = half speed)")]
[SerializeField] private float surfacingSpeedFactor = 0.5f;
private DivingDeveloperSettings _devSettings;
private IDivingMinigameSettings _gameSettings;
private float _timer;
private float _nextSpawnInterval;
@@ -40,14 +25,24 @@ namespace Minigames.DivingForPictures
{
_mainCamera = Camera.main;
if (useObjectPooling)
// Get developer settings and game settings
_devSettings = GameManager.GetDeveloperSettings<DivingDeveloperSettings>();
_gameSettings = GameManager.GetSettingsObject<IDivingMinigameSettings>();
if (_devSettings == null)
{
Debug.LogError("[BubbleSpawner] Failed to load developer settings!");
return;
}
if (_devSettings.BubbleUseObjectPooling)
{
// Create the bubble pool
GameObject poolGO = new GameObject("BubblePool");
poolGO.transform.SetParent(transform);
_bubblePool = poolGO.AddComponent<BubblePool>();
_bubblePool.initialPoolSize = initialPoolSize;
_bubblePool.maxPoolSize = maxPoolSize;
_bubblePool.initialPoolSize = _devSettings.BubbleInitialPoolSize;
_bubblePool.maxPoolSize = _devSettings.BubbleMaxPoolSize;
_bubblePool.Initialize(bubblePrefab);
// Periodically check for pool statistics in debug builds
@@ -80,7 +75,7 @@ namespace Minigames.DivingForPictures
/// <returns>Randomized interval in seconds.</returns>
float GetRandomizedInterval()
{
return spawnInterval * Random.Range(0.8f, 1.2f);
return _devSettings.BubbleSpawnInterval * Random.Range(0.8f, 1.2f);
}
/// <summary>
@@ -88,11 +83,11 @@ namespace Minigames.DivingForPictures
/// </summary>
void SpawnBubble()
{
float x = Random.Range(spawnXMin, spawnXMax);
Vector3 spawnPos = new Vector3(x, spawnY, 0f);
float x = Random.Range(_devSettings.BubbleSpawnXMin, _devSettings.BubbleSpawnXMax);
Vector3 spawnPos = new Vector3(x, _devSettings.BubbleSpawnY, 0f);
Bubble bubble;
if (useObjectPooling && _bubblePool != null)
if (_devSettings.BubbleUseObjectPooling && _bubblePool != null)
{
bubble = _bubblePool.GetBubble();
bubble.transform.position = spawnPos;
@@ -103,25 +98,25 @@ namespace Minigames.DivingForPictures
}
// Randomize bubble properties
float baseSpeed = Random.Range(speedRange.x, speedRange.y);
float baseSpeed = Random.Range(_devSettings.BubbleSpeedRange.x, _devSettings.BubbleSpeedRange.y);
// Apply surfacing speed reduction if needed
if (_isSurfacing)
{
bubble.speed = baseSpeed * surfacingSpeedFactor;
bubble.speed = baseSpeed * _devSettings.BubbleSurfacingSpeedFactor;
}
else
{
bubble.speed = baseSpeed;
}
bubble.wobbleSpeed = Random.Range(wobbleSpeedRange.x, wobbleSpeedRange.y);
bubble.wobbleSpeed = Random.Range(_devSettings.BubbleWobbleSpeedRange.x, _devSettings.BubbleWobbleSpeedRange.y);
// Set base scale (initial size) for the bubble
float baseScale = Random.Range(scaleRange.x, scaleRange.y);
float baseScale = Random.Range(_devSettings.BubbleScaleRange.x, _devSettings.BubbleScaleRange.y);
bubble.SetBaseScale(baseScale);
// Assign random sprite to BubbleSprite (fixed naming from BottleSprite)
// Assign random sprite to BubbleSprite
if (bubbleSprites != null && bubbleSprites.Length > 0)
{
Sprite randomSprite = bubbleSprites[Random.Range(0, bubbleSprites.Length)];
@@ -132,7 +127,7 @@ namespace Minigames.DivingForPictures
bubble.transform.rotation = Quaternion.Euler(0f, 0f, Random.Range(0f, 360f));
// Pass min/max scale for wobble clamping
bubble.SetWobbleScaleLimits(wobbleMinScale, wobbleMaxScale);
bubble.SetWobbleScaleLimits(_devSettings.BubbleWobbleMinScale, _devSettings.BubbleWobbleMaxScale);
}
/// <summary>
@@ -148,10 +143,10 @@ namespace Minigames.DivingForPictures
Bubble[] activeBubbles = FindObjectsByType<Bubble>(FindObjectsSortMode.None);
foreach (Bubble bubble in activeBubbles)
{
bubble.speed *= surfacingSpeedFactor;
bubble.speed *= _devSettings.BubbleSurfacingSpeedFactor;
}
Debug.Log($"[BubbleSpawner] Started surfacing mode. Bubbles slowed to {surfacingSpeedFactor * 100}% speed.");
Debug.Log($"[BubbleSpawner] Started surfacing mode. Bubbles slowed to {_devSettings.BubbleSurfacingSpeedFactor * 100}% speed.");
}
/// <summary>