TO SQUASH: Fixed oozeball split animation.
This commit is contained in:
@@ -39,7 +39,35 @@ public class BallSpawner : MonoBehaviour
|
||||
StartCoroutine(SpawnBalls());
|
||||
}
|
||||
|
||||
private void SpawnBall(GameObject ballPrefab)
|
||||
public void SpawnBallOfType(string ballType, Vector2? position = null)
|
||||
{
|
||||
switch (ballType)
|
||||
{
|
||||
case "BasicBall":
|
||||
SpawnBall(basicBallPrefab, position);
|
||||
break;
|
||||
case "NuclearBall":
|
||||
SpawnBall(nuclearBallPrefab, position);
|
||||
break;
|
||||
case "GlassBall":
|
||||
SpawnBall(glassBallPrefab, position);
|
||||
break;
|
||||
case "EyeBall":
|
||||
SpawnBall(eyeBallPrefab, position);
|
||||
break;
|
||||
case "OozeBall":
|
||||
SpawnBall(oozeBallPrefab, position);
|
||||
break;
|
||||
case "FruitBall":
|
||||
SpawnBall(fruitBallPrefab, position);
|
||||
break;
|
||||
default:
|
||||
Debug.LogWarning($"Unknown ball type: {ballType}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void SpawnBall(GameObject ballPrefab, Vector2? position = null)
|
||||
{
|
||||
if (ballPrefab == null || gameBoard == null)
|
||||
{
|
||||
@@ -47,9 +75,20 @@ public class BallSpawner : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3 spawnPosition = GetRandomPositionInsideGameBoard();
|
||||
Vector3 spawnPosition = position.HasValue ?
|
||||
new Vector3(position.Value.x, position.Value.y, gameBoard.transform.position.z) :
|
||||
GetRandomPositionInsideGameBoard();
|
||||
var newBall = Instantiate(ballPrefab, spawnPosition, Quaternion.identity);
|
||||
|
||||
if (ballPrefab == oozeBallPrefab)
|
||||
{
|
||||
var oozeBallScript = newBall.GetComponent<OozeBall>();
|
||||
if (oozeBallScript != null)
|
||||
{
|
||||
oozeBallScript.spawner = this;
|
||||
}
|
||||
}
|
||||
|
||||
balls.Enqueue(newBall);
|
||||
}
|
||||
|
||||
@@ -81,15 +120,7 @@ public class BallSpawner : MonoBehaviour
|
||||
return new Vector3(randomX, randomY, gameBoard.transform.position.z);
|
||||
}
|
||||
|
||||
private IEnumerator SpawnBalls()
|
||||
{
|
||||
while (ballQueue.Count > 0)
|
||||
{
|
||||
System.Action spawnAction = ballQueue.Dequeue();
|
||||
spawnAction.Invoke();
|
||||
yield return _waitForSeconds0_5;
|
||||
}
|
||||
|
||||
public void FixCollisions() {
|
||||
// Disable collision between existing balls of certain types.
|
||||
// Only basic balls and fruit balls will collide with each other, while ooze,
|
||||
// nuclear, glass, and eye balls will not collide with any other balls.
|
||||
@@ -117,4 +148,16 @@ public class BallSpawner : MonoBehaviour
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator SpawnBalls()
|
||||
{
|
||||
while (ballQueue.Count > 0)
|
||||
{
|
||||
System.Action spawnAction = ballQueue.Dequeue();
|
||||
spawnAction.Invoke();
|
||||
yield return _waitForSeconds0_5;
|
||||
}
|
||||
|
||||
FixCollisions();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user