Graphics Reference
In-Depth Information
private int totalSpawnObjects;
private int currentObjectNum;
public int currentWave;
void Start ()
{
// count how many objects we have lined up in the spawn
// object list
foreach( GameObject go in spawnObjectPrefabs )
{
totalSpawnObjects++;
}
Debug.Log("Wave_Spawner.cs found "+totalSpawnObjects+" spawn
objects to choose from.");
// schedule first attack wave
Invoke("LaunchWave",timeBeforeFirstSpawn);
}
public void LaunchWave()
{
CancelInvoke("LaunchWave");
if( randomSpawning )
{
currentObjectNum= Random.Range ( 0,
totalSpawnObjects-1 );
} else {
currentObjectNum++;
// loop back to 0 when we reach the end of the
current 'run' of things to spawn
if( currentObjectNum > totalSpawnObjects-1 )
{
currentObjectNum=0;
// you could also implement something to tell
// game control that all waves have finished if
// you were making a game that only lasted until
// that happens
}
}
// create an object
GameObject tempObj=
SpawnController.Instance.SpawnGO( spawnObjectPrefabs[currentObjectNum],
Vector3.zero, Quaternion.identity );
WaveProperties tempProps= tempObj.GetComponent<WaveProperties>();
currentWave= tempProps.enemiesInWave;
}
public void Fragged()
{
// one enemy down
currentWave--;
Search WWH ::




Custom Search