Skip to content

Engineer Factory

Ahmad Abu-Aysha edited this page Sep 11, 2023 · 6 revisions

Introduction

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.

Engineer Entities

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.

Entity components

The baseHumanNPC instance has the following components:

  • PhysicsComponent
  • PhysicsMovementComponent
  • ColliderComponent
  • HitBoxComponent, configured with the ENGINEER physical layer
  • TouchAttackComponent, configured to interact with the NPC physical layer

The subsequent engineer instance then has the following components added:

  • CombatStatsComponent
  • AnimationRenderComponent, with a range of animations
  • HumanAnimationController
  • AITaskComponent, which has a HumanWanderTask 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.

Usage

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.

Sequence diagram

The following sequence diagram shows the interaction of the EngineerFactory class with the game engine and the Entity class

EngineerFactoryGapScannerFactorySequenceDiagram

UML diagram

The following UML diagram provides insight into the structure of the class and its super classes and interfaces.

EngineerFactoryUML

Clone this wiki locally