You should play with **Arrays**! Arrays are "Tables" that contents severals and different gameobjects or any other var. So, let's say this:
**public GameObject[] hazard;**
By adding "[]" you simply declare an array. Drag and drop any enemies you want in your Hazard array and **create an Int named a**.
**In void Update()**
if (score >= 15 && a < 1)
{
a += 1;
}
//if (score >= 50 && a < 2)
//{
// a += 1;
//}
//ETC...
**Now in your IEnumerator SpawnWaves** ():
IEnumerator SpawnWaves ()
{
yield return new WaitForSeconds (startWait);
while (true)
{
for (int i = 0; i < hazardCount; i++)
{
Vector3 spawnPosition = new Vector3 (Random.Range (-spawnValues.x, spawnValues.x), Random.Range (-spawnValues.y, spawnValues.y), Random.Range(-spawnValues.z, spawnValues.z));
Quaternion spawnRotation = Quaternion.identity;
if (hazard[a] != null)
{
Instantiate (hazard[a], spawnPosition, spawnRotation);
}
yield return new WaitForSeconds (spawnWait);
}
yield return new WaitForSeconds (waveWait);
if (gameOver)
{
restartText.text = "Press 'R' for Restart";
restart = true;
break;
}
}
}
Oh yeah, by the way, I don't care about code "indentation"! When people wan't to help, they simply do ;)
Math
↧