var spawnPoints : Transform;
var enemyPrefabs : GameObject;
var yieldTimeMin = 0;
var yieldTimeMax = 0;
static var enemyCounter = 0;
var spawnXOffsetMin = 0;
var spawnXOffsetMax = 0;
var spawnZOffsetMin = 0;
var spawnZOffsetMax = 0;
var defaultSpawnNumber = 5;
var waveNumber = 0;
var isSpawning = false;
function SpawnEnemies(wave : int)
{
var spawnNum = (defaultSpawnNumber + 5 * (wave - 1));
isSpawning = true;
for(var i = 0; i < spawnNum;i++)
{
yield WaitForSeconds(Random.Range(yieldTimeMin, yieldTimeMax));
var object : GameObject = enemyPrefabs[Random.Range(0, enemyPrefabs.Length)];
var position : Transform = spawnPoints[Random.Range(0, spawnPoints.Length)];
Instantiate(object, position.position + Vector3(Random.Range(spawnXOffsetMin, spawnXOffsetMax), 0, Random.Range(spawnZOffsetMin, spawnZOffsetMax)), position.rotation);
enemyCounter++;
}
isSpawning = false;
}
function UpdateWave()
{
waveNumber++;
SpawnEnemies(waveNumber);
}
function Start()
{
SpawnEnemies(waveNumber);
}
function Update ()
{
if (enemyCounter == 0 && !isSpawning)
{
UpdateWave();
}
}