TO SQUASH: Simplified Ball Spawner.
This commit is contained in:
@@ -27,37 +27,25 @@ public class BallSpawner : MonoBehaviour
|
|||||||
{
|
{
|
||||||
int currentLevel = PlayerPrefs.GetInt("CurrentLevel");
|
int currentLevel = PlayerPrefs.GetInt("CurrentLevel");
|
||||||
|
|
||||||
ballQueue.Enqueue(() => SpawnBasicBall());
|
ballQueue.Enqueue(() => SpawnBall(basicBallPrefab));
|
||||||
ballQueue.Enqueue(() => SpawnBasicBall());
|
ballQueue.Enqueue(() => SpawnBall(basicBallPrefab));
|
||||||
ballQueue.Enqueue(() => SpawnBasicBall());
|
ballQueue.Enqueue(() => SpawnBall(basicBallPrefab));
|
||||||
ballQueue.Enqueue(() => SpawnFruitBall());
|
ballQueue.Enqueue(() => SpawnBall(fruitBallPrefab));
|
||||||
ballQueue.Enqueue(() => SpawnFruitBall());
|
ballQueue.Enqueue(() => SpawnBall(fruitBallPrefab));
|
||||||
|
|
||||||
StartCoroutine(SpawnBalls());
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 spawnPosition = GetRandomPositionInsideGameBoard();
|
Vector3 spawnPosition = GetRandomPositionInsideGameBoard();
|
||||||
Instantiate(basicBallPrefab, spawnPosition, Quaternion.identity);
|
Instantiate(ballPrefab, 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vector3 GetRandomPositionInsideGameBoard()
|
private Vector3 GetRandomPositionInsideGameBoard()
|
||||||
|
|||||||
Reference in New Issue
Block a user