Unit Spawning From Buildings - UQdeco2800/2022-studio-3 GitHub Wiki
Introduction
In prior sprints unit spawning was done with spawning methods called once when the game is started, however, this functionality is limited and doesn't reflect the requirements of the game. Units, both friendly and enemy are supposed to be spawned by a variety of events, they can include random/story events, direct player intervention, i.e. play selects a barracks and deploys n number of units, or auto spawning functions.
To fit the unit spawning to these new requirements we've implemented an event system for spawning units from buildings, events such as spawnHoplite
and spawnBlueJoker
are triggered by the UnitSpawningComponent
, the events triggered are dependant on the building type the component is attached to, currently it spawns a unit every 30 seconds, these events then process their respective spawning functions in AtlantisGameArea
, where the event manager instance is located. This system allows for successful deployment of units without having full access to classes like GameArea
.
UML Sequence Diagram
The following demonstrates how the Barracks uses the event system and UnitSpawningComponent
, this is a similar flow that happens with any buildings that has UnitSpawningComponent
.