void Update() { if (asteroidsShouldBeGoing) { if (asteroidWaitTimeCounter < AsteroidWaitTime) { asteroidWaitTimeCounter += (1 * Time.deltaTime); } else { SpawnAsteroid(); asteroidWaitTimeCounter = 0; fuelCounter += 1; powerUpCounter += 1; shieldCounter += 1; } if (asteroidWaitTimeCounter > AsteroidWaitTime / 2 && powerUpSpots[powerUpCounter] == 1) { if (fuel[fuelCounter] == 1) { powerUpCounter = 0; } else { float oneOfThree = Random.Range(0, 2); float zeroOne = Random.Range(0, 2); if (zeroOne >= 1) { oneOfThree = -oneOfThree; } PowerUps.Enqueue(AsteroidSpawner.SpawnPowerUp(AsteroidSpawner.transform.position.y * oneOfThree)); PowerUpsCounter += 1; powerUpCounter = 0; } } if (asteroidWaitTimeCounter > AsteroidWaitTime / 2 && shieldSpots[shieldCounter] == 1) { if (fuel[fuelCounter] == 1) { shieldCounter = 0; } else { float oneOfThree = Random.Range(0, 2); float zeroOne = Random.Range(0, 2); if (zeroOne >= 1) { oneOfThree = -oneOfThree; } Shields.Enqueue(AsteroidSpawner.SpawnShield(AsteroidSpawner.transform.position.y * oneOfThree)); ShieldsCounter += 1; shieldCounter = 0; } } if (asteroidWaitTimeCounter > AsteroidWaitTime / 2 && fuel[fuelCounter] == 1) { float oneOfThree = Random.Range(0, 2); float zeroOne = Random.Range(0, 2); if (zeroOne >= 1) { oneOfThree = -oneOfThree; } Fuels.Enqueue(AsteroidSpawner.SpawnFuel(AsteroidSpawner.transform.position.y * oneOfThree)); FuelsCounter += 1; fuelCounter = 0; } } if (MainMenu) { if (asteroidWaitTimeCounter < AsteroidWaitTime) { asteroidWaitTimeCounter += (1 * Time.deltaTime); } else { float randomUpDown = Random.Range(-AsteroidSpawner.transform.localScale.y, AsteroidSpawner.transform.localScale.y); AsteroidSpawner.SpawnAsteroid(randomUpDown, AsteroidPrefabs[5]); asteroidWaitTimeCounter = 0; } } }