From bc4fe8fc8088594fb7e20d4735e306a0e83e6638 Mon Sep 17 00:00:00 2001 From: Miguel Astor Date: Mon, 3 Aug 2026 00:16:32 -0400 Subject: [PATCH] TO SQUASH: Simplified Ball Spawner. --- Assets/Scripts/Game/BallSpawner.cs | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/Assets/Scripts/Game/BallSpawner.cs b/Assets/Scripts/Game/BallSpawner.cs index 6ebd179..cc17b29 100644 --- a/Assets/Scripts/Game/BallSpawner.cs +++ b/Assets/Scripts/Game/BallSpawner.cs @@ -27,37 +27,25 @@ public class BallSpawner : MonoBehaviour { int currentLevel = PlayerPrefs.GetInt("CurrentLevel"); - ballQueue.Enqueue(() => SpawnBasicBall()); - ballQueue.Enqueue(() => SpawnBasicBall()); - ballQueue.Enqueue(() => SpawnBasicBall()); - ballQueue.Enqueue(() => SpawnFruitBall()); - ballQueue.Enqueue(() => SpawnFruitBall()); + ballQueue.Enqueue(() => SpawnBall(basicBallPrefab)); + ballQueue.Enqueue(() => SpawnBall(basicBallPrefab)); + ballQueue.Enqueue(() => SpawnBall(basicBallPrefab)); + ballQueue.Enqueue(() => SpawnBall(fruitBallPrefab)); + ballQueue.Enqueue(() => SpawnBall(fruitBallPrefab)); StartCoroutine(SpawnBalls()); } - private void SpawnBasicBall() + private void SpawnBall(GameObject ballPrefab) { - if (basicBallPrefab == null || gameBoard == null) + if (ballPrefab == null || gameBoard == null) { - Debug.LogWarning("BallSpawner: Missing basicBallPrefab or gameBoard reference."); + Debug.LogWarning("BallSpawner: Missing ballPrefab or gameBoard reference."); return; } Vector3 spawnPosition = GetRandomPositionInsideGameBoard(); - Instantiate(basicBallPrefab, spawnPosition, Quaternion.identity); - } - - private void SpawnFruitBall() - { - if (fruitBallPrefab == null || gameBoard == null) - { - Debug.LogWarning("BallSpawner: Missing fruitBallPrefab or gameBoard reference."); - return; - } - - Vector3 spawnPosition = GetRandomPositionInsideGameBoard(); - Instantiate(fruitBallPrefab, spawnPosition, Quaternion.identity); + Instantiate(ballPrefab, spawnPosition, Quaternion.identity); } private Vector3 GetRandomPositionInsideGameBoard()