Skip to content

Commit

Permalink
Animation checks added to XenoAnimation controller to assist with ani…
Browse files Browse the repository at this point in the history
…mation timing.
  • Loading branch information
BlairCannon97 committed Sep 10, 2023
1 parent f277fd4 commit 4d3ab82
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.csse3200.game.components.npc;

import com.badlogic.gdx.graphics.g2d.Animation;
import com.csse3200.game.components.Component;
import com.csse3200.game.rendering.AnimationRenderComponent;

import java.util.Objects;

/**
* This class listens to events relevant to a ghost entity's state and plays the animation when one
* of the events is triggered.
Expand All @@ -24,26 +27,34 @@ public void create() {
}

void animateRun() {
animator.startAnimation("xeno_run");
if (!Objects.equals(animator.getCurrentAnimation(), "xeno_shoot")) {
animator.stopAnimation();
animator.startAnimation("xeno_run");
}
}

void animateHurt() {
animator.stopAnimation();
animator.startAnimation("xeno_hurt");
}

void animateShoot() {
animator.stopAnimation();
animator.startAnimation("xeno_shoot");
}

void animateMelee1() {
animator.stopAnimation();
animator.startAnimation("xeno_melee_1");
}

void animateMelee2() {
animator.stopAnimation();
animator.startAnimation("xeno_melee_2");
}

void animateDie() {
animator.stopAnimation();
animator.startAnimation("xeno_die");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.csse3200.game.physics.PhysicsEngine;
import com.csse3200.game.physics.PhysicsLayer;
import com.csse3200.game.physics.raycast.RaycastHit;
import com.csse3200.game.rendering.AnimationRenderComponent;
import com.csse3200.game.services.ServiceLocator;
import com.csse3200.game.services.GameTime;
import com.csse3200.game.entities.factories.ProjectileFactory;
Expand Down Expand Up @@ -125,6 +126,7 @@ public void updateMobState() {
owner.getEntity().getEvents().trigger(STOW);
mobState = STATE.STOW;
} else {
System.out.printf("ANIMATION: " + owner.getEntity().getComponent(AnimationRenderComponent.class).getCurrentAnimation() + "\n");
owner.getEntity().getEvents().trigger(FIRING);
Entity newProjectile = ProjectileFactory.createMobBall(PhysicsLayer.HUMANS, new Vector2(0, owner.getEntity().getPosition().y), new Vector2(2f,2f));
newProjectile.setPosition((float) (owner.getEntity().getPosition().x), (float) (owner.getEntity().getPosition().y));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public static Entity createXenoGrunt(Entity target) {
.addComponent(animator)
.addComponent(new XenoAnimationController());

// xenoGrunt.getComponent(AnimationRenderComponent.class).scaleEntity();
xenoGrunt.getComponent(AnimationRenderComponent.class).scaleEntity();

return xenoGrunt;
}
Expand Down

0 comments on commit 4d3ab82

Please sign in to comment.