TO SQUASH: Ball reset.
This commit is contained in:
@@ -1183,6 +1183,7 @@ MonoBehaviour:
|
||||
oozeBallPrefab: {fileID: 2828226485849316135, guid: ff4467517111a6d0ab4e5608c8adeee0, type: 3}
|
||||
fruitBallPrefab: {fileID: 3086586548818580311, guid: b67974a0c09fbe75aac299e30a0c665b, type: 3}
|
||||
gameBoard: {fileID: 297740150}
|
||||
player: {fileID: 1002905792}
|
||||
--- !u!4 &240489637
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -272,8 +272,6 @@ public class LevelEnder : MonoBehaviour
|
||||
musicManager.PauseMusic();
|
||||
|
||||
yield return new WaitForSeconds(1.0f);
|
||||
|
||||
player.OnLevelEnd();
|
||||
|
||||
// Reenable spawners.
|
||||
multiplierSpawner.StartSpawning();
|
||||
@@ -304,7 +302,10 @@ public class LevelEnder : MonoBehaviour
|
||||
levelEndTally.enabled = false;
|
||||
levelEndTallyBackground.enabled = false;
|
||||
|
||||
// TODO: Reset balls.
|
||||
// Reset.
|
||||
player.OnLevelEnd();
|
||||
ballSpawner.ResetBalls();
|
||||
worldFiller.ClearWalls();
|
||||
|
||||
// Restart music.
|
||||
musicManager.ResumeMusic();
|
||||
|
||||
@@ -18,12 +18,16 @@ public class BallSpawner : Spawner
|
||||
|
||||
public GameObject gameBoard;
|
||||
|
||||
public Player player;
|
||||
|
||||
private static WaitForSeconds _waitForSeconds0_5 = new WaitForSeconds(0.5f);
|
||||
|
||||
private Queue<System.Action> ballQueue = new Queue<System.Action>();
|
||||
|
||||
private Queue<GameObject> balls = new Queue<GameObject>();
|
||||
|
||||
private int basicBallCount = 0;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
@@ -31,17 +35,7 @@ public class BallSpawner : Spawner
|
||||
|
||||
ballQueue.Enqueue(() => SpawnBall(basicBallPrefab));
|
||||
ballQueue.Enqueue(() => SpawnBall(basicBallPrefab));
|
||||
// ballQueue.Enqueue(() => SpawnBall(basicBallPrefab));
|
||||
// ballQueue.Enqueue(() => SpawnBall(fruitBallPrefab));
|
||||
// ballQueue.Enqueue(() => SpawnBall(fruitBallPrefab));
|
||||
// ballQueue.Enqueue(() => SpawnBall(oozeBallPrefab));
|
||||
// ballQueue.Enqueue(() => SpawnBall(nuclearBallPrefab));
|
||||
// ballQueue.Enqueue(() => SpawnBall(glassBallPrefab));
|
||||
// ballQueue.Enqueue(() => SpawnBall(glassBallPrefab));
|
||||
// ballQueue.Enqueue(() => SpawnBall(glassBallPrefab));
|
||||
// ballQueue.Enqueue(() => SpawnBall(glassBallPrefab));
|
||||
// ballQueue.Enqueue(() => SpawnBall(glassBallPrefab));
|
||||
// ballQueue.Enqueue(() => SpawnBall(eyeBallPrefab));
|
||||
basicBallCount = 2;
|
||||
|
||||
StartCoroutine(SpawnBalls());
|
||||
}
|
||||
@@ -74,6 +68,112 @@ public class BallSpawner : Spawner
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetBalls()
|
||||
{
|
||||
// Clear all balls.
|
||||
int nukeBallCount = 0;
|
||||
int glassBallCount = 0;
|
||||
int eyeBallCount = 0;
|
||||
int oozeBallCount = 0;
|
||||
int fruitBallCount = 0;
|
||||
|
||||
foreach (var ball in balls)
|
||||
{
|
||||
if (ball != null)
|
||||
{
|
||||
if (ball.CompareTag("NuclearBall"))
|
||||
{
|
||||
nukeBallCount++;
|
||||
}
|
||||
else if (ball.CompareTag("GlassBall"))
|
||||
{
|
||||
glassBallCount++;
|
||||
}
|
||||
else if (ball.CompareTag("EyeBall"))
|
||||
{
|
||||
eyeBallCount++;
|
||||
}
|
||||
else if (ball.CompareTag("OozeBall"))
|
||||
{
|
||||
oozeBallCount++;
|
||||
}
|
||||
else if (ball.CompareTag("FruitBall"))
|
||||
{
|
||||
fruitBallCount++;
|
||||
}
|
||||
Destroy(ball);
|
||||
}
|
||||
}
|
||||
balls.Clear();
|
||||
|
||||
// Always spawn one basic ball more than in the previous level.
|
||||
basicBallCount++;
|
||||
|
||||
// At special levels force spawn certain types of balls.
|
||||
if (player.level % 5 == 0)
|
||||
{
|
||||
// One nuclear ball each five levels.
|
||||
nukeBallCount++;
|
||||
|
||||
if (player.level >= 10)
|
||||
{
|
||||
// Glass balls after level 10.
|
||||
glassBallCount += Random.Range(1, 3);
|
||||
}
|
||||
|
||||
if (player.level >= 15)
|
||||
{
|
||||
// An extra nuke ball after level 15.
|
||||
nukeBallCount++;
|
||||
|
||||
// Eye balls after level 15.
|
||||
eyeBallCount++;
|
||||
}
|
||||
|
||||
if (player.level >= 20)
|
||||
{
|
||||
// Ooze balls after level 20.
|
||||
oozeBallCount++;
|
||||
}
|
||||
|
||||
// No extra basic ball when a special ball spawns for the first time.
|
||||
basicBallCount--;
|
||||
}
|
||||
|
||||
// Spawn balls.
|
||||
for (int i = 0; i < basicBallCount; i++)
|
||||
{
|
||||
ballQueue.Enqueue(() => SpawnBall(basicBallPrefab));
|
||||
}
|
||||
|
||||
for (int i = 0; i < nukeBallCount; i++)
|
||||
{
|
||||
ballQueue.Enqueue(() => SpawnBall(nuclearBallPrefab));
|
||||
}
|
||||
|
||||
for (int i = 0; i < glassBallCount; i++)
|
||||
{
|
||||
ballQueue.Enqueue(() => SpawnBall(glassBallPrefab));
|
||||
}
|
||||
|
||||
for (int i = 0; i < eyeBallCount; i++)
|
||||
{
|
||||
ballQueue.Enqueue(() => SpawnBall(eyeBallPrefab));
|
||||
}
|
||||
|
||||
for (int i = 0; i < oozeBallCount; i++)
|
||||
{
|
||||
ballQueue.Enqueue(() => SpawnBall(oozeBallPrefab));
|
||||
}
|
||||
|
||||
for (int i = 0; i < fruitBallCount; i++)
|
||||
{
|
||||
ballQueue.Enqueue(() => SpawnBall(fruitBallPrefab));
|
||||
}
|
||||
|
||||
StartCoroutine(SpawnBalls());
|
||||
}
|
||||
|
||||
private void SpawnBall(GameObject ballPrefab, Vector2? position = null)
|
||||
{
|
||||
if (ballPrefab == null || gameBoard == null)
|
||||
|
||||
Reference in New Issue
Block a user