Skip to content

Tower Animation Controller

Shivam edited this page Aug 29, 2023 · 34 revisions

Introduction

This component is responsible for responding to animation triggers ran by the TowerCombatTask by choosing the trigger-specific animation for the tower, as well as playing the respective sounds for each tower animation. The animations are ran by the AnimationRenderComponent present in the class, through its startAnimation method, which takes the animation name as an input argument. i.e. startAnimation(name);

The ServiceLocator class retrieves the sound and stores in a variable specific to its name as follows:

Sound [SOUND-NAME]sound = ServiceLocator.getResourceService().getAsset([PATH-TO-AUDIO-FILE], Sound.class);

Running .play(); on the sound variable plays the corresponding sound.

The following UML diagram gives a hierarchical overview of how TowerAnimationController links with other components and performs the required animations.

Screenshot 2023-08-29 125042

Initializer: create()

This method configures the AnimationRenderComponent animator; variable to refer to the AnimationRenderComponent present in the same entity as this component, by running animator = this.entity.getComponent(AnimationRenderComponent.class);

It further proceeds to add listeners for the tower's animation triggers as follows:

entity.getEvents().addListener(IDLE, this::animateIdle);
entity.getEvents().addListener(STOW, this::animateStow);
entity.getEvents().addListener(DEPLOY, this::animateDeploy);
entity.getEvents().addListener(FIRING, this::animateFiring);

Animators: animate[ANIMATION-NAME]()

The animator methods for this class are as follows:

void animateIdle();
void animateDeploy();
void animateFiring();
void animateStow();

The same methods ran in their respective order would look like:

tower

Clone this wiki locally