-
Notifications
You must be signed in to change notification settings - Fork 4
Engineer Factory
In keeping with the Factory Design Pattern in LibGDX, an EngineerFactory class is used to create instances of 'Engineer' entities, and configure them with all the required components.
Engineers are the on-screen manifestation of the humans' presence on the level. They represent the remaining 'life' of the player, and if they are all lost, the game ends.
The engineer
entity is created by first instantiating a baseHumanNPC
and then extending the instance with additional components specific to the entity.
The baseHumanNPC
instance has the following components:
PhysicsComponent
PhysicsMovementComponent
ColliderComponent
-
HitBoxComponent
, configured with theENGINEER
physical layer -
TouchAttackComponent
, configured to interact with theNPC
physical layer
The subsequent engineer
instance then has the following components added:
CombatStatsComponent
-
AnimationRenderComponent
, with a range of animations HumanAnimationController
-
AITaskComponent
, which has aHumanWanderTask
added.
The [HumanWanderTask](add link) gives the engineer entity in-game behaviour and state, and controls detection, movement, attacking, damage and death. This task has a set of subtasks which are triggered from within, which are the [HumanMovementTask], [HumanWaitTask], and [EngineerCombatTask](add link). These tasks are adapted from the existing Ghost tasks and TowerCombatTask and modified.
An engineer entity can be instantiated by the following syntax
Entity engineer = EngineerFactory.createEngineer();
then spawned into the game area as with any other entity using the spawnEntityAt
function.
The following sequence diagram shows the interaction of the EngineerFactory class with the game engine and the Entity class
The following UML diagram provides insight into the structure of the class and its super classes and interfaces.