diff --git a/source/core/assets/images/projectiles/pierce_anim.atlas b/source/core/assets/images/projectiles/pierce_anim.atlas new file mode 100644 index 000000000..0dea23b97 --- /dev/null +++ b/source/core/assets/images/projectiles/pierce_anim.atlas @@ -0,0 +1,42 @@ + +pierce_anim.png +size: 256, 32 +format: RGBA8888 +filter: Nearest, Nearest +repeat: none +projectile + rotate: false + xy: 2, 2 + size: 35, 26 + orig: 35, 26 + offset: 0, 0 + index: -1 +projectile + rotate: false + xy: 76, 2 + size: 35, 26 + orig: 35, 26 + offset: 0, 0 + index: -1 +projectile + rotate: false + xy: 39, 2 + size: 35, 26 + orig: 35, 26 + offset: 0, 0 + index: -1 +projectile + rotate: false + xy: 113, 2 + size: 35, 26 + orig: 35, 26 + offset: 0, 0 + index: -1 +default +projectile + rotate: false + xy: 2, 2 + size: 35, 26 + orig: 35, 26 + offset: 0, 0 + index: -1 \ No newline at end of file diff --git a/source/core/assets/images/projectiles/pierce_anim.png b/source/core/assets/images/projectiles/pierce_anim.png new file mode 100644 index 000000000..e9c349e6f Binary files /dev/null and b/source/core/assets/images/projectiles/pierce_anim.png differ diff --git a/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java b/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java index 3d88bedb7..a163e4dde 100644 --- a/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java +++ b/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java @@ -116,7 +116,8 @@ public class ForestGameArea extends GameArea { "images/projectiles/snow_ball.png", "images/projectiles/burn_effect.png", "images/projectiles/stun_effect.png", - "images/projectiles/firework_anim.png" + "images/projectiles/firework_anim.png", + "images/projectiles/pierce_anim.png" }; @@ -145,7 +146,8 @@ public class ForestGameArea extends GameArea { "images/projectiles/snow_ball.atlas", "images/projectiles/burn_effect.atlas", "images/projectiles/stun_effect.atlas", - "images/projectiles/firework_anim.atlas" + "images/projectiles/firework_anim.atlas", + "images/projectiles/pierce_anim.atlas" }; private static final String[] forestSounds = { diff --git a/source/core/src/main/com/csse3200/game/components/projectile/PierceProjectileAnimationController.java b/source/core/src/main/com/csse3200/game/components/projectile/PierceProjectileAnimationController.java new file mode 100644 index 000000000..a5801aa80 --- /dev/null +++ b/source/core/src/main/com/csse3200/game/components/projectile/PierceProjectileAnimationController.java @@ -0,0 +1,25 @@ +package com.csse3200.game.components.projectile; + +import com.csse3200.game.components.Component; +import com.csse3200.game.rendering.AnimationRenderComponent; + +public class PierceProjectileAnimationController extends Component { + /** Event name constants */ + private static final String START = "startProjectile"; + /** Animation name constants */ + private static final String START_ANIM = "projectile"; + AnimationRenderComponent animator; + + + @Override + public void create() { + super.create(); + animator = this.entity.getComponent(AnimationRenderComponent.class); + entity.getEvents().addListener(START, this::animateStart); + + } + + void animateStart() { + animator.startAnimation(START_ANIM); + } +} diff --git a/source/core/src/main/com/csse3200/game/entities/factories/ProjectileFactory.java b/source/core/src/main/com/csse3200/game/entities/factories/ProjectileFactory.java index 0966e5c03..5977b2dba 100644 --- a/source/core/src/main/com/csse3200/game/entities/factories/ProjectileFactory.java +++ b/source/core/src/main/com/csse3200/game/entities/factories/ProjectileFactory.java @@ -120,7 +120,7 @@ public static Entity createEffectProjectile(short targetLayer, Vector2 destinati * Pierce fireball is basically a fireball that does damage but won't self destruct on hit. */ public static Entity createPierceFireBall(short targetLayer, Vector2 destination, Vector2 speed) { - Entity fireBall = createFireBall(targetLayer, destination, speed); + Entity fireBall = createPierceBallAnim(targetLayer, destination, speed); fireBall.getComponent(TouchAttackComponent.class).setDisposeOnHit(false); fireBall.getComponent(TouchAttackComponent.class).setKnockBack(0f); @@ -169,7 +169,7 @@ public static Entity createFireBall(short targetLayer, Vector2 destination, Vect projectile .addComponent(animator) - .addComponent(new ProjectileAnimationController()); + .addComponent(new PierceProjectileAnimationController()); // * TEMPORARY // .addComponent(new DeleteOnMapEdgeComponent()); // .addComponent(new SelfDestructOnHitComponent(PhysicsLayer.OBSTACLE)); @@ -177,6 +177,14 @@ public static Entity createFireBall(short targetLayer, Vector2 destination, Vect return projectile; } + /** + * Creates new animation and fireballs for SplitFireworkComponent. + * + * @param targetLayer The enemy layer that the projectile collides with. + * @param destination The destination the projectile heads towards. + * @param speed The speed of the projectile. + * @return Returns a new fireball projectile entity. + */ public static Entity createFireworks(short targetLayer, Vector2 destination, Vector2 speed) { Entity projectile = createBaseProjectile(targetLayer, destination, speed); @@ -192,6 +200,21 @@ public static Entity createFireworks(short targetLayer, Vector2 destination, Vec return projectile; } + public static Entity createPierceBallAnim(short targetLayer, Vector2 destination, Vector2 speed) { + Entity projectile = createBaseProjectile(targetLayer, destination, speed); + + AnimationRenderComponent animator = + new AnimationRenderComponent( + ServiceLocator.getResourceService() + .getAsset("images/projectiles/pierce_anim.atlas", TextureAtlas.class)); + animator.addAnimation(START_ANIM, 0.05f, Animation.PlayMode.LOOP); + projectile + .addComponent(animator) + .addComponent(new FireworkAnimationController()); + + return projectile; + } + /** * Creates a engineer bullet