Enemy NPC Test Cases - UQcsse3200/2024-studio-2 GitHub Wiki
The following components are being tested as part of the enemy creation and combat feature:
Enemy NPC Factory Tests
Enemy Factory Tests
Methods
CreateMonkey()
: Creates monkey entity
createchicken()
: Creates chicken entity
createFrog
: Creates Frog entity
createBaseEnemy
: Creates Base Enemy
Chicken Animation Controller:
Methods
create()
: Initialises the component and sets up event listeners
animateSpawn()
: Plays the "spawn" animation
animateChaseLeft()
: Plays the "walk" animation and flips the sprite to face left
animateChaseRight()
: Plays the "walk" animation and flips the sprite to face right
animateWanderLeft()
: Plays the "walk" animation and flips the sprite to face left
animateWanderRight()
: Plays the "walk" animation and flips the sprite to face right
Frog Animation Tests:
Methods
create()
: Initialises the component and sets up event listeners
animateWanderLeft()
: Plays the "float" animation and flips the sprite to face left
animateWanderRight()
: Plays the "float" animation and flips the sprite to face right
animateChaseLeft()
: Plays the "angry_float" animation and flips the sprite to face left
animateChaseRight()
: Plays the "angry_float" animation and flips the sprite to face right
Monkey Animation Tests:
Methods
create()
: Initialises the component and sets up event listeners
animateRunDown()
: Plays the "run_down" animation, likely used when the character is running downwards
animateRunUp()
: Plays the "run_up" animation, likely used when the character is running upwards
animateRunLeft()
: Plays the "run_left" animation, likely used when the character is running to the left
animateRunRight()
: Plays the "run_right" animation, likely used when the character is running to the right
animateRunLeftDown()
: Plays the "run_left_down" animation, likely used when the character is running diagonally down to the left
animateRunRightDown()
: Plays the "run_right_down" animation, likely used when the character is running diagonally down to the right
animateRunLeftUp()
: Plays the "run_left_up" animation, likely used when the character is running diagonally up to the left
animateRunRightUp()
: Plays the "run_right_up" animation, likely used when the character is running diagonally up to the right
Spawn Task
Method
SpawnTask(Vector2 spawnPosition, float spawnDuration)
: Constructor for the SpawnTask class, initialises the task with the spawn position and duration
getSpawnPosition()
: Returns the position where the entity will be spawned
getSpawnDuration()
: Returns the duration of the spawn task
getElapsedTime()
: Returns the elapsed time since the spawn task started
getPriority()
: Returns the priority of this task, with higher values indicating higher priority
start()
: Starts the spawn task, positioning the entity at the spawn location and triggering the "spawnChicken" event
completeTask()
: Completes the spawn task, stopping it and cleaning up if necessary
stop()
: Stops the spawn task, cleaning up if necessary. Inherits from DefaultTask.
ProximityComponent
Methods
ProximityComponent()
: Constructor for the ProximityComponent
update()
: Updates the component's state based on the entity's position relative to the target
setupSpawnAnimation(Entity entity)
: Sets up the spawn animation for the given entity.
Touch Attack Component
Methods
View Touch Attack Component Tests
TouchAttackComponent()
: Constructor for the TouchAttackComponent
create()
: Creates the component and sets up event listeners
onCollisionStart
: Handles the "collisionStart" event
Projectile Factory Tests
Tests the creation of projectiles, which is currently only the banana, to ensure they are instantiated correctly with the necessary components.
Methods
TestBananaCreation()
: Tests the creation of a banana projectile.TestBananaIsEntity()
: Verifies that the created banana is an instance of theEntity
class.TestBananaHasComponents()
: Ensures that the banana has all required components, such asPhysicsComponent
,PhysicsMovementComponent
,BananaAnimationController
,ProjectileAttackComponent
,HitboxComponent
, andColliderComponent
.
Touch Attack Component Tests
Tests the TouchAttackComponent
to verify that it correctly handles collision-based attack logic.
Methods
shouldNotAttackOtherLayer()
: Verifies that the attack does not occur if the target entity is on a different physics layer.shouldNotAttackWithoutCombatComponent()
: Ensures that the attack is ignored if the target entity does not have aCombatStatsComponent
.
Shoot Task Tests
Tests the ShootTask
to verify its behaviour for firing projectiles when within range and the correct wait time has elapsed.
Methods
shouldShootWhenInRangeAndWaitTimeElapsed()
: Verifies that theShootTask
fires a projectile (triggers the "FireBanana" event) when the target is within range and the wait time has passed.shouldShootOnlyWhenInDistance()
: Ensures that theShootTask
only fires when the target is within a specified distance range and does not shoot when the target is too far away.