-
Notifications
You must be signed in to change notification settings - Fork 1
Spawning Enemies
Detailed information about how spawning enemies works, you can read from this page.
Enemies come from spawners placed on top of the stage scene. They are spawned constantly "refilling" missing units to the limit which is dependant on current difficulty level. Spawning process runs in the background and if number of enemies on the map is less than the limit and there are still enemies to spawn in queue (this is recognisable by black robot icons on the panel placed on the right side of the screen), then they are spawned after elapsed delay time, also affectable by difficulty levels.
After finding all spawners on the map, enemies are spawned from left to right (they are sorted by ordinal number, a field of enemy spawners). Their order is taken from data of the current stage (see the "Reading Stage Data Files" page for more information).
When an enemy is spawned by one of the spawners, the manager responsible for spawning enemies "goes" to the next spawner to avoid creating enemies by using always the same spawner. It works sequentially i.e. when the first one was used, then the second one will spawn the next enemy. When the last one spawned an enemy, it will back to the first one and so on.
Sometimes it may happen that one of already spawned enemies wandering around the map, can be close to the spawner which spawns another enemy. To avoid "denting" coming from detected collision, an another system was implemented to detect such situations and if it occurs, then sets the layer for both the enemies to ignore themselves and let them overlapping until they stop touching themselves. In this case, their layers are restored to their initial states.