Best approach for scripting enemy waves

I’m trying to create a tower defense like wave spawner, and am looking for the best approach to make a non-random series of spawns on a set timeline. Every post or tutorial I’ve found on the subject seems to be based on random enemies, positions, and intervals.

I have 3 normal enemy types, 1 boss type, and want to have them spawn in a specific pattern (i.e.: after 3 seconds spawn 1 of enemy A, after 5 seconds spawn 2 of enemy B, etc).

Right now the spawner I created is throwing out random enemies at random intervals. I feel like I could pretty easily make a long script that has a bunch of IEnumerators set to spawn each type on each time, but that seems like a poor approach that would be error prone scale poorly.

What I’d like is something in editor where I can add an arbitrary number of fields, one for each spawn, which specifies the enemy type and time of spawn, so I could rapidly play around with timings in editor, as opposed to needing to jump back and forth between scripts, or instead of placing a ton of individual spawner game objects. I guess I want to make an array with multiple pieces of data for every entry, or something like that.

For reference, I’m using C# and am pretty much totally new to programming. Any advice for how I should approach this would be appreciated. Even just what I should be searching for, as I suspect I don’t even know the right terminology.

You could create a class for each enemy type. In that class have a variable for the amount of enemies to spawn.

In your spawn script you could Invoke the functions in the order you want with whatever amount you want.

This would be the way I would handle it I think

How about something like…

float timer = 10;
int phase = 0;

void Update()
{
	timer -= Time.deltaTime;
	switch(phase)
	{
	case 0:
		if(timer <= 10)
		{
			//spawn first set of enemies
			phase = 1;
		}
		break;
	case 1:
		if(timer <= 5)
		{
			//spawn second set of enemies
			phase = 2;
		}
		break;
	case 2:
		//etc, just continue this pattern
		break;
	}
}

Here, try out this video. I used the system laid out in it for a long time until I needed to get a little more complex. Works perfectly, and the video takes you through the whole thing line by line so its great for a new user. All the other videos on the series are good to watch too, you can learn alot of good things from them.

http://cgcookie.com/unity/lessons/5-waves/

Awesome, thanks for all the replies. I’ll check out the video.

I thought I might mention that Killer Waves is currently on sale 55% off:

http://forum.unity3d.com/threads/167910-Brand-new-Killer-Waves-(wave-spawning-plugin)-demo-video-up!

It’s a very comprehensive product that does wave spawning and more.

Just FYI - Dark Tonic just released the new version of Killer Waves, renamed to Core GameKit, in a 48-hour sale at just $5 USD.