The forum contains a lot of great information on many things but I believe one topic is lacking that many other than me could benefit from: how to create a flexible wave system that can control multiple enemies and differences in both waves and maps. All posts on the topics (that I could find) seem to only refer to waves with only 1 type of creature and with the same increment from wave to wave (e.g. 5 more monsters per wave).
First of all, let me clarify what I mean by a flexible wave system. In most defense games (TD, BD) and games like Orcs Must Die and Dungeon Defenders, there is a spawner system which controls which enemies spawn at what time and how many of each. It is such a wave system that I'm trying to figure out how to go about in Construct 2. I have been unable to find any information about this on the forums, but please let me know if I've missed any! If someone has already made a system I hope they will share some of their ideas :)
Let's say we have a game with 5 levels each containing 5 waves. The game also includes 3 different monsters. In level 1, wave 1 I want 5 monsters of type 1 to spawn. In wave 2, I want 5 monsters of type 1 and 3 monsters of type 2. In wave 3, perhaps 10 monsters of type 1, 5 monsters of type 2 and 1 of type 3. The number of monsters will be different in the next levels as well. This quickly becomes very difficult for me to deal with in an efficient way.
What I've tried so far. The first example has random spawning - not fixed, which is what I would prefer.
1) In this system, I have a list (a dictionary, really) containing what monster types that are allowed to spawn in a given level. I also have an array which holds the number of monsters to spawn in a given wave. What I then do is when the monster is spawned I randomly make it one of the types that is allowed in that level. So, lets say wave 1 spawns 10 monsters that can be of either type 1 or 2. The function will then spawn 10 monsters with random types, e.g. 4 of type 1 and 6 of type 2. This actually works quite well and is relatively easy to scale from wave to wave and level to level. However, this is random spawning which really isn't what I want.
2) This system is what I'm trying to implement now but it just seems full of hassle. This would be done with arrays and the ability to count instances. Let's say we are in wave 1 of level 1 and want 8 enemies of type 1 and 2 of type 2. What I could do is make an array which would hold the wave number and the monsters to spawn. One way I could think off would be this: (1,1,1,1,1,1,1,1,2,2). I could then, when spawning enemies, use the count to set the monster type, e.g. when monster count is 3 it would choose monster type from index 3 (or 2 with zero-based but let's just ignore that for now to avoid confusion <img src="smileys/smiley1.gif" border="0" align="middle" />) which would be 1. And when monster count became 9 it would spawn a monster of type 2. I haven't tried this system yet but I believe it would work. The problem is, if I end up having a total of hundreds of waves each spawning dozens of enemies it quickly becomes extremely messy.
Does anyone have any ideas how to go about it? I was hoping that by posting here, we could together come up with a good way to create a flexible spawning system which makes it easy to control what monsters to spawn in what wave. I'm sure that this would help anyone who is trying to create e.g. a tower defense game and be a great resource to the community.