Soldier units - UQdeco2800/2022-studio-3 GitHub Wiki
Overview
Soldier units are the main defender of Atlantis City. Their goal is to defeat enemies while also defending the city at the same time. Every soldier unit has its own unique ability, stats and costs. Players are encouraged to utilize their unique stats and aim for victory.
Soldier types
Units information for soldiers can be seen as follows:
- Archer: The main range unit with low defense and hp, but high attack
- Swordsman: The main frontline with high attack, but low defense
- Spearman: The basic unit with decent stats
- Hoplite: The main frontline with high defense, but low attack
Functionality
Soldier Factory
Creating a Base Soldier
InputComponent inputComponent = ServiceLocator.getInputService().getInputFactory().createForFriendlyUnit();
AITaskComponent aiComponent = new AITaskComponent().addTask(new SoldierIdleTask());
Entity soldier =
new Entity()
.addComponent(new PhysicsComponent())
.addComponent(new PhysicsMovementComponent())
.addComponent(new ColliderComponent())
.addComponent(new HitboxComponent().setLayer(PhysicsLayer.SOLDIER))
.addComponent(new FriendlyComponent())
.addComponent(new SelectableComponent())
.addComponent(new HealthBarComponent(EntityType.FRIENDLY))
.addComponent(aiComponent)
.addComponent(inputComponent)
.addComponent(new TouchAttackComponent(PhysicsLayer.NPC));
SoldierFactory Sequence Diagram
Fighting Movement Task
Description
This implements a fighting task for a Soldier. A Soldier may chase down an enemy or move to a specified target until they arrive. In the game, a user selects a target enemy for the soldier and the soldier will follow the enemy. But if what the user selects is not an enemy, it will move to the clicked location.
FightingMovementTask Sequence Diagram
Soldier Class Diagram
The following is a class diagram of all the classes in the Soldier: