-
Notifications
You must be signed in to change notification settings - Fork 4
XenoAnimationController
The XenoAnimationController
has been modified to add listeners to the Xeno mob, handling the events wanderStart, runHurt, meleeStart, shootStart, dieStart
and stop
. While previously, each of these animation sets existed separately among different atlas files, changes have been made to combine them into a single atlas and PNG, making them easier to read from.
The key methods of this controller are outlined below. The associated assets for each method are outlined below in 'Xeno Grunt Assets'.
The animateRun()
function is called when a wanderStart
event occurs. This event is currently triggered by the WanderTask
class and the MobAttackTask
at instances where the entity is to either end their current task and continue to pace forward, or when the entity has no other task to perform. A check has been added to this function which ensures the shootStart
event is not being performed in order for a call to trigger the wanderStart
event to be successful
The animateHurt()
function is called whenever the xeno drops below the 60% threshold in health, and exists to indicate to the player that the entity is weakened. Its functionality in game is yet to be realised.
animateMelee()
, and animateShoot()
both correspond to their respective events, and are triggered within the MobAttackTask
class. 'animateShoot()' when called will begin the shoot animation. 'animateMelee()' will trigger one of the 2 melee animation, and is determined by a random number generated within the function. Basically, a random number (either 0 or 1) will determine if animation 1 or 2 is triggered.
int randAnim = rand.nextInt(2);
if (randAnim == 1) {
animator.startAnimation("xeno_melee_1");
} else {
animator.startAnimation("xeno_melee_2");
}
animateDie()
will play the death animation, and is only called once within the WanderTask
class, which is currently where a mob is determined to be dead.
The Xeno Grunt is a basic enemy mobs which spawns in high volume down each lane, capable of shooting at the tower directly in front, or swinging at it once close enough. This is the first basic mob to be implemented, and as such has a basic but diverse ability set, which serves as the basis for future general mob implementations.
The Xeno Grunt run animations are simple 8 frame loops, read from the xeno-grunt-run.png and xeno-grunt-run-damaged.png by xenoGruntRunning.atlas and xenoGruntRunningDamaged.atlas respectively.
Attack animations are read from the xeno-grunt-melee-attack.png and xeno-grunt-range-attack.png by xenoGruntRangedAttack.atlas and xenoGruntMeleeAttack.atlas respectively. These animations operate on different loop lengths, with the first melee attack having a 9 frame loop, the second melee attack having a 6 frame loop, and the ranged attack having a 5 frame loop.
The death animation is read from xeno-grunt-death.png by xenoGruntDeath.atlas, and has a 5 frame loop. This sprite sheet has been made up from the separate PNGs xeno-grunt-death-falling.png and xeno-grunt-death-grounded.png.
Currently, testing for XenoAnimationController is performed by XenoAnimationControllerTest. This class includes the 'testAnimateWander()', 'testAnimateHurt()', 'testAnimateMelee1()' and 'testAnimateDie()' functions, each of which is triggers an event of their respective type, then gets the currently running animation from the animation controller to verify correct behavior. Given the random aspect implemented for the melee animations, the test has been changed to catch the case where either animation is chosen. This has the unfortunate consequence of teasting a single animation each time the test is run.
public void testAnimateMelee1() {
xenoGrunt.getEvents().trigger("meleeStart");
assert(Objects.equals(xenoGrunt.getComponent(AnimationRenderComponent.class).getCurrentAnimation(), "xeno_melee_1")
|| Objects.equals(xenoGrunt.getComponent(AnimationRenderComponent.class).getCurrentAnimation(), "xeno_melee_2"));
}
Testing for the creation of a xeno grunt is executed withing the NPCFactoryTest class.