From b35878704e5450970f8a4f17af8de0763db5c3df Mon Sep 17 00:00:00 2001 From: cindyle1 Date: Sat, 9 Sep 2023 21:10:00 +1000 Subject: [PATCH] Tested size and speed of MobKingBall. Added implementation to RangeBossMovementTask --- .../tasks/RangeBossMovementTask.java | 23 ++++++++++++++++--- .../game/components/tasks/TrajectTask.java | 1 + .../entities/factories/ProjectileFactory.java | 11 +++++---- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/source/core/src/main/com/csse3200/game/components/tasks/RangeBossMovementTask.java b/source/core/src/main/com/csse3200/game/components/tasks/RangeBossMovementTask.java index 87f51b1a3..f18d89c94 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/RangeBossMovementTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/RangeBossMovementTask.java @@ -23,6 +23,13 @@ public class RangeBossMovementTask extends DefaultTask implements PriorityTask { private MovementTask movementTask; private WaitTask waitTask; private Task currentTask; + /** Animation event names */ + private static final String START = "startMobKing"; + private static final String FINAL = "startMobKingFinal"; + private enum STATE { + START, FINAL + } + private STATE bossBallState = STATE.START; /** * @param waitTime How long in seconds to wait between wandering. @@ -54,13 +61,23 @@ public void start() { this.owner.getEntity().getEvents().trigger("rangeBossMovementStart"); } + public void switchMobKingBallState() { + switch (bossBallState) { + case START: + owner.getEntity().getEvents().trigger(FINAL); + bossBallState = STATE.FINAL; + } + } + @Override public void update() { if (currentTask.getStatus() != Status.ACTIVE) { if (currentTask == movementTask) { - Entity newProjectile = ProjectileFactory.createFireBall(PhysicsLayer.OBSTACLE, new Vector2(0, currentPos.y + 0.75f), new Vector2(2f,2f)); - - newProjectile.scaleHeight(-0.4f); + Entity newProjectile = ProjectileFactory.createMobKingBall( + PhysicsLayer.HUMANS, new Vector2(0, currentPos.y + 0.75f), new Vector2(2f,2f)); + owner.getEntity().getEvents().trigger(START); + switchMobKingBallState(); + newProjectile.scaleHeight(-0.6f); newProjectile.setPosition((float) (currentPos.x), (float) (currentPos.y+0.75f)); ServiceLocator.getEntityService().register(newProjectile); startWaiting(); diff --git a/source/core/src/main/com/csse3200/game/components/tasks/TrajectTask.java b/source/core/src/main/com/csse3200/game/components/tasks/TrajectTask.java index 7b25061f5..04967ba8e 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/TrajectTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/TrajectTask.java @@ -40,6 +40,7 @@ public void start() { this.owner.getEntity().getEvents().trigger(START); this.owner.getEntity().getEvents().trigger("rotate"); this.owner.getEntity().getEvents().trigger("start"); + this.owner.getEntity().getEvents().trigger("startMobKing"); } public void switchProjectileState() { 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 0ac4646e2..bd6cf53e6 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 @@ -7,6 +7,7 @@ import com.csse3200.game.components.TouchAttackComponent; import com.csse3200.game.components.RicochetComponent; import com.csse3200.game.components.SplitFireworksComponent; +import com.csse3200.game.components.projectile.MobKingProjectAnimController; import com.csse3200.game.components.tasks.TrajectTask; import com.csse3200.game.ai.tasks.AITaskComponent; import com.csse3200.game.components.CombatStatsComponent; @@ -202,16 +203,16 @@ public static Entity createMobKingBall(short targetLayer, Vector2 destination, V new AnimationRenderComponent( ServiceLocator.getResourceService() .getAsset("images/projectiles/mobKing_projectile.atlas", TextureAtlas.class)); - animator.addAnimation("mob_boss", 0.1f, Animation.PlayMode.NORMAL); - animator.addAnimation("mob_bossFinal", 0.1f, Animation.PlayMode.NORMAL); + animator.addAnimation("mob_boss", 0.17f, Animation.PlayMode.NORMAL); + animator.addAnimation("mob_bossFinal", 0.17f, Animation.PlayMode.NORMAL); projectile .addComponent(animator) - .addComponent(new MobProjectileAnimationController()); + .addComponent(new MobKingProjectAnimController()); -// projectile -// .getComponent(AnimationRenderComponent.class).scaleEntity(); + projectile + .getComponent(AnimationRenderComponent.class).scaleEntity(); return projectile; }