diff --git a/source/core/assets/images/mobboss/demon.atlas b/source/core/assets/images/mobboss/demon.atlas new file mode 100644 index 000000000..dc0fd573c --- /dev/null +++ b/source/core/assets/images/mobboss/demon.atlas @@ -0,0 +1,186 @@ +demon.png +size:2048,2048 +repeat:none +demon_cleave +index:6 +bounds:2,1622,288,160 +demon_cleave +index:11 +bounds:582,1784,288,160 +demon_cleave +index:3 +bounds:872,1784,288,160 +demon_cleave +index:8 +bounds:1162,1784,288,160 +demon_cleave +index:13 +bounds:582,1298,288,160 +demon_cleave +index:5 +bounds:582,1136,288,160 +demon_cleave +index:10 +bounds:1452,1622,288,160 +demon_cleave +index:15 +bounds:872,1136,288,160 +demon_cleave +index:2 +bounds:1162,1298,288,160 +demon_cleave +index:7 +bounds:292,650,288,160 +demon_cleave +index:12 +bounds:1162,1136,288,160 +demon_cleave +index:4 +bounds:872,812,288,160 +demon_cleave +index:9 +bounds:292,326,288,160 +demon_cleave +index:14 +bounds:1162,812,288,160 +demon_cleave +index:1 +bounds:1742,1136,288,160 +demon_death +index:11 +bounds:292,1784,288,160 +demon_death +index:4 +bounds:292,1622,288,160 +demon_death +index:16 +bounds:292,1460,288,160 +demon_death +index:9 +bounds:582,1622,288,160 +demon_death +index:1 +bounds:2,1136,288,160 +demon_death +index:21 +bounds:292,1298,288,160 +demon_death +index:22 +bounds:292,1298,288,160 +demon_death +index:13 +bounds:2,974,288,160 +demon_death +index:6 +bounds:292,1136,288,160 +demon_death +index:18 +bounds:2,812,288,160 +demon_death +index:10 +bounds:872,1298,288,160 +demon_death +index:3 +bounds:1162,1460,288,160 +demon_death +index:15 +bounds:292,812,288,160 +demon_death +index:8 +bounds:582,974,288,160 +demon_death +index:20 +bounds:1742,1622,288,160 +demon_death +index:12 +bounds:582,812,288,160 +demon_death +index:5 +bounds:872,974,288,160 +demon_death +index:17 +bounds:582,650,288,160 +demon_death +index:2 +bounds:1162,974,288,160 +demon_death +index:14 +bounds:582,488,288,160 +demon_death +index:7 +bounds:872,650,288,160 +demon_death +index:19 +bounds:582,326,288,160 +demon_idle +index:3 +bounds:2,1298,288,160 +demon_idle +index:5 +bounds:872,1460,288,160 +demon_idle +index:2 +bounds:1742,1784,288,160 +demon_idle +index:4 +bounds:1452,1298,288,160 +demon_idle +index:1 +bounds:1452,1136,288,160 +demon_idle +index:6 +bounds:1452,974,288,160 +demon_take_hit +index:2 +bounds:2,1784,288,160 +demon_take_hit +index:4 +bounds:872,1622,288,160 +demon_take_hit +index:1 +bounds:292,974,288,160 +demon_take_hit +index:3 +bounds:2,488,288,160 +demon_take_hit +index:5 +bounds:2,164,288,160 +demon_walk +index:8 +bounds:2,1460,288,160 +demon_walk +index:5 +bounds:582,1460,288,160 +demon_walk +index:11 +bounds:1162,1622,288,160 +demon_walk +index:2 +bounds:1452,1784,288,160 +demon_walk +index:7 +bounds:2,650,288,160 +demon_walk +index:4 +bounds:1452,1460,288,160 +demon_walk +index:9 +bounds:1742,1460,288,160 +demon_walk +index:10 +bounds:2,326,288,160 +demon_walk +index:1 +bounds:292,488,288,160 +demon_walk +index:6 +bounds:1742,1298,288,160 +demon_walk +index:12 +bounds:2,2,288,160 +demon_walk +index:3 +bounds:292,164,288,160 +default +index:1 +bounds:1452,1136,288,160 diff --git a/source/core/assets/images/mobboss/demon.png b/source/core/assets/images/mobboss/demon.png new file mode 100644 index 000000000..b7a9b8b85 Binary files /dev/null and b/source/core/assets/images/mobboss/demon.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 56edf129d..f219645bc 100644 --- a/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java +++ b/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java @@ -104,7 +104,8 @@ public class ForestGameArea extends GameArea { "images/projectiles/stun_effect.png", "images/projectiles/firework_anim.png", "images/projectiles/pierce_anim.png", - "images/projectiles/snow_ball.png" + "images/projectiles/snow_ball.png", + "images/mobboss/demon.png" }; private static final String[] forestTextureAtlases = { "images/economy/econ-tower.atlas", @@ -136,7 +137,8 @@ public class ForestGameArea extends GameArea { "images/projectiles/burn_effect.atlas", "images/projectiles/firework_anim.atlas", "images/projectiles/mobProjectile.atlas", - "images/projectiles/stun_effect.atlas" + "images/projectiles/stun_effect.atlas", + "images/mobboss/demon.atlas" }; private static final String[] forestSounds = { "sounds/Impact4.ogg", @@ -240,6 +242,9 @@ public void create() { spawnEffectProjectile(new Vector2(2, 6), PhysicsLayer.NPC, towardsMobs, new Vector2(2f, 2f), ProjectileEffects.SLOW, false); spawnXenoGrunts(); spawnWeaponTower(); + + spawnDemonBoss(); + //mobBoss1 = spawnMobBoss1(); startWaveTimer(); // spawnIncome(); @@ -384,6 +389,10 @@ private Entity spawnPlayer(GridPoint2 position) { // return ghostKing; // } + private void spawnDemonBoss() { + Entity demon = MobBossFactory.createDemonBoss(); + spawnEntityAt(demon, new GridPoint2(19, 4), true, false); + } private Entity spawnMobBoss1() { int[] pickedLanes = new Random().ints(0, 8) diff --git a/source/core/src/main/com/csse3200/game/components/bosses/DemonAnimationController.java b/source/core/src/main/com/csse3200/game/components/bosses/DemonAnimationController.java new file mode 100644 index 000000000..64f6fea98 --- /dev/null +++ b/source/core/src/main/com/csse3200/game/components/bosses/DemonAnimationController.java @@ -0,0 +1,23 @@ +package com.csse3200.game.components.bosses; + +import com.csse3200.game.components.Component; +import com.csse3200.game.rendering.AnimationRenderComponent; + +public class DemonAnimationController extends Component { + AnimationRenderComponent animator; + + /** + * Creation call for a TowerAnimationController, fetches the animationRenderComponent that this controller will + * be attached to and registers all the event listeners required to trigger the animations and sounds. + */ + @Override + public void create() { + super.create(); + animator = this.entity.getComponent(AnimationRenderComponent.class); + entity.getEvents().addListener("demon_walk", this::animateStart); + } + + void animateStart() { + animator.startAnimation("demon_walk"); + } +} diff --git a/source/core/src/main/com/csse3200/game/components/tasks/bosstask/DemonBossMovementTask.java b/source/core/src/main/com/csse3200/game/components/tasks/bosstask/DemonBossTask.java similarity index 86% rename from source/core/src/main/com/csse3200/game/components/tasks/bosstask/DemonBossMovementTask.java rename to source/core/src/main/com/csse3200/game/components/tasks/bosstask/DemonBossTask.java index 9e4f48ad5..9057c61ef 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/bosstask/DemonBossMovementTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/bosstask/DemonBossTask.java @@ -3,8 +3,6 @@ import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.TimeUtils; -import com.badlogic.gdx.utils.Timer; -import com.csse3200.game.ai.tasks.AITaskComponent; import com.csse3200.game.ai.tasks.DefaultTask; import com.csse3200.game.ai.tasks.PriorityTask; import com.csse3200.game.components.tasks.MovementTask; @@ -14,9 +12,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class DemonBossMovementTask extends DefaultTask implements PriorityTask { +public class DemonBossTask extends DefaultTask implements PriorityTask { - private static final Logger logger = LoggerFactory.getLogger(DemonBossMovementTask.class); + private static final Logger logger = LoggerFactory.getLogger(DemonBossTask.class); private static final int PRIORITY = 3; private Vector2 currentPos; private MovementTask movementTask; @@ -31,7 +29,7 @@ private enum STATE { } private STATE demonState = STATE.IDLE; - public DemonBossMovementTask() { + public DemonBossTask() { physics = ServiceLocator.getPhysicsService().getPhysics(); } @@ -39,15 +37,13 @@ public DemonBossMovementTask() { public void start() { super.start(); this.currentPos = owner.getEntity().getPosition(); - System.out.println(currentPos); jump(getJumpPos()); - System.out.println("DEMON: " + owner.getEntity().getPosition()); } @Override public void update() { this.currentPos = owner.getEntity().getPosition(); - if (currentPos == jumpPos) { + if (currentPos.equals(jumpPos)) { logger.debug("Demon jump completed"); } } @@ -58,6 +54,8 @@ public int getPriority() { } private void jump(Vector2 finalPos) { + // Start animation + owner.getEntity().getEvents().trigger("demon_walk"); MovementTask jump = new MovementTask(finalPos); jump.create(owner); owner.getEntity().getComponent(PhysicsMovementComponent.class).setSpeed(DEMON_JUMP_SPEED); diff --git a/source/core/src/main/com/csse3200/game/entities/factories/MobBossFactory.java b/source/core/src/main/com/csse3200/game/entities/factories/MobBossFactory.java index 2b1258645..7422aff01 100644 --- a/source/core/src/main/com/csse3200/game/entities/factories/MobBossFactory.java +++ b/source/core/src/main/com/csse3200/game/entities/factories/MobBossFactory.java @@ -4,9 +4,10 @@ import com.badlogic.gdx.graphics.g2d.TextureAtlas; import com.csse3200.game.ai.tasks.AITaskComponent; import com.csse3200.game.components.*; +import com.csse3200.game.components.bosses.DemonAnimationController; import com.csse3200.game.components.npc.Boss1AnimationController; import com.csse3200.game.components.npc.Boss2AnimationController; -import com.csse3200.game.components.tasks.bosstask.DemonBossMovementTask; +import com.csse3200.game.components.tasks.bosstask.DemonBossTask; import com.csse3200.game.components.tasks.bosstask.FinalBossMovementTask; import com.csse3200.game.components.tasks.bosstask.RangeBossTask; import com.csse3200.game.components.tasks.bosstask.bossDeathTask; @@ -25,20 +26,36 @@ public class MobBossFactory { private static final NPCConfigs configs = FileLoader.readClass(NPCConfigs.class, "configs/Boss.json"); private static final int PRIORITY = 1; private static final int BOSS_MOB_AGRO_RANGE = 10; + private static final int DEMON_HEALTH = 10000; + private static final int DEMON_ATTACK = 50; // Create Demon Boss - private static Entity createDemonBoss() { + public static Entity createDemonBoss() { MobBossConfigs config = configs.MobBoss; Entity demon = createBaseBoss(); // Animation addition + AnimationRenderComponent animator1 = new AnimationRenderComponent( + ServiceLocator.getResourceService().getAsset("images/mobboss/demon.atlas", TextureAtlas.class)); + animator1.addAnimation("demon_walk", 0.3f, Animation.PlayMode.LOOP); // AI task addition AITaskComponent aiTaskComponent = new AITaskComponent() - .addTask(new DemonBossMovementTask()); + .addTask(new DemonBossTask()); // Component addition + demon + .addComponent(animator1) + .addComponent(new DemonAnimationController()) + .addComponent(aiTaskComponent) + .addComponent(new CombatStatsComponent(DEMON_HEALTH, DEMON_ATTACK)); + + // Scale demon + demon.getComponent(AnimationRenderComponent.class).scaleEntity(); + demon.scaleHeight(3f); + demon.scaleWidth(3f); + System.out.println("Demon Created\n"); return demon; }