Enemies - UQcsse3200/2026-studio-2 GitHub Wiki
Description
Enemies are hostile NPCs the player will encounter during each level. These enemies will deal damage to the player through either melee or ranged attacks. It uses an EnemyFactory class to create each enemy type, and enemies' stats are modified through the config value.
Components:
EnemyFactory.java
The main class responsible for creating enemies
EnemiesConfig and EnemyConfig
EnemiesConfig contains config for all enemy types currently in the game, and EnemyConfig contain base values to modify an enemy's behaviour
ProjectileComponent
Component that creates the projectile
ProjectileFact.java
Projectile Factory for an enemy's ranged attack
RangedAttackTask
Allows the enemy to perform a ranged attack by firing a projectile at the player
DelayAttackTask.java
Allows the enemy to perform a melee attack with a given delay (See Enemy Delayed Attack)
EnemyDeathComponent.java
Handles Enemy Death when HP reaches 0.
Uses a listener on CombatStatsComponent setHealth() to call scheduleForDisposal() when health is set to 0.
EnemyItemDropComponent.java
Handles item dropping at arbitrary health. Specific health-item drops can be customised as a list within the Enemies.json config file.
Uses a listener on CombatStatsComponent setHealth() to loop through the health-item drops, checks if any health thresholds have been crossed, creates and registers items as necessary.
EnemyHealthRenderComponent.java
Renders a health bar for a given enemy.
Uses a listener on CombatStatsComponent setHealth() to update a Pixmap / SpriteBatch illustration of a simple thin flat bar filled proportionately to the given health.
UML Diagram
TBD
Testing
- JUnit Test DelayedAttackTaskTest.java
- JUnit Test EnemyDeathComponentTest.java
- Visual test to ensure that the enemy behaves as written in configs; archer enemy fires projectiles and takes damage when attacked by player