diff --git a/source/core/src/main/com/csse3200/game/components/npc/SplitMoblings.java b/source/core/src/main/com/csse3200/game/components/npc/SplitMoblings.java index 13285d9ba..8e283f741 100644 --- a/source/core/src/main/com/csse3200/game/components/npc/SplitMoblings.java +++ b/source/core/src/main/com/csse3200/game/components/npc/SplitMoblings.java @@ -125,8 +125,8 @@ public void spawnAdditionalMob(float positionX, float positionY, Entity waterSlime = NPCFactory.createNightBorne(60); waterSlime.setPosition(positionX, positionY); - // waterSlime.setScale(initialScaleX * scaleX, initialScaleY * scaleY); - waterSlime.setScale(initialScaleX, initialScaleY); + waterSlime.setScale(initialScaleX * scaleX, initialScaleY * scaleY); + // waterSlime.setScale(initialScaleX, initialScaleY); ServiceLocator.getEntityService().register(waterSlime); } diff --git a/source/core/src/main/com/csse3200/game/components/tasks/bosstask/DemonBossTask.java b/source/core/src/main/com/csse3200/game/components/tasks/bosstask/DemonBossTask.java index f8661c8ca..45d482fbc 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/bosstask/DemonBossTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/bosstask/DemonBossTask.java @@ -64,6 +64,7 @@ public class DemonBossTask extends DefaultTask implements PriorityTask { private static int xLeftBoundary = 12; private ProjectileEffects effect = ProjectileEffects.BURN; private boolean aoe = true; + private Array nearbyEntities; // Flags private boolean startFlag = false; @@ -98,6 +99,7 @@ public void start() { animation = demon.getComponent(AnimationRenderComponent.class); // get animation currentPos = demon.getPosition(); // get current position demon.getComponent(PhysicsMovementComponent.class).setSpeed(DEMON_SPEED); // set speed + demon.getComponent(PhysicsMovementComponent.class).setNormalSpeed(DEMON_SPEED); Timer.schedule(new Timer.Task() { @Override @@ -166,11 +168,10 @@ public void update() { case IDLE -> jump(getJumpPos()); case SMASH -> { if (jumpComplete()) { - if (getNearbyHumans(SMASH_RADIUS).isEmpty()) { - fireBreath(); - } - else { + if (nearbyEntities != null && !nearbyEntities.isEmpty()) { cleave(); + } else { + fireBreath(); } } } @@ -246,34 +247,34 @@ public int getPriority() { return PRIORITY; } - /** - * Returns a list of nearby entities with PhysicsLayer.HUMAN. - * - * @return nearby entities with the PhysicsLayer of HUMAN - */ - private Array getNearbyHumans(int radius) { - Array nearbyEntities = ServiceLocator.getEntityService(). - getNearbyEntities(demon, radius); - Array nearbyHumans = new Array<>(); - - // iterate through nearby entities checking if they have desired properties - for (int i = 0; i < nearbyEntities.size; i++) { - Entity targetEntity = nearbyEntities.get(i); - HitboxComponent targetHitbox = targetEntity.getComponent(HitboxComponent.class); - if (targetHitbox == null) { - break; - } - - // check target layer - if (!PhysicsLayer.contains(PhysicsLayer.HUMANS, targetHitbox. - getLayer())) { - break; - } - - nearbyHumans.add(targetEntity); - } - return nearbyHumans; - } +// /** +// * Returns a list of nearby entities with PhysicsLayer.HUMAN. +// * +// * @return nearby entities with the PhysicsLayer of HUMAN +// */ +// private Array getNearbyHumans(int radius) { +// Array nearbyEntities = ServiceLocator.getEntityService(). +// getNearbyEntities(demon, radius); +// Array nearbyHumans = new Array<>(); +// +// // iterate through nearby entities checking if they have desired properties +// for (int i = 0; i < nearbyEntities.size; i++) { +// Entity targetEntity = nearbyEntities.get(i); +// HitboxComponent targetHitbox = targetEntity.getComponent(HitboxComponent.class); +// if (targetHitbox == null) { +// break; +// } +// +// // check target layer +// if (!PhysicsLayer.contains(PhysicsLayer.HUMANS, targetHitbox. +// getLayer())) { +// break; +// } +// +// nearbyHumans.add(targetEntity); +// } +// return nearbyHumans; +// } /** * Changes state of demon and moves it to the desired position. @@ -344,12 +345,20 @@ private Vector2 getJumpPos() { * @return if demon has completed jump or not */ private boolean jumpComplete() { - if (currentPos.dst(jumpPos) <= STOP_DISTANCE && isJumping) { - applyAoeDamage(getNearbyHumans(SMASH_RADIUS), SMASH_DAMAGE); // do damage upon landing + if (animation.isFinished() && isJumping) { + nearbyEntities = ServiceLocator.getEntityService().getEntitiesInLayer( + demon, SMASH_RADIUS, PhysicsLayer.HUMANS); + applyAoeDamage(nearbyEntities, SMASH_DAMAGE); // do damage upon landing isJumping = false; jumpTask.stop(); return true; } +// if (currentPos.dst(jumpPos) <= STOP_DISTANCE && isJumping) { +// applyAoeDamage(getNearbyHumans(SMASH_RADIUS), SMASH_DAMAGE); // do damage upon landing +// isJumping = false; +// jumpTask.stop(); +// return true; +// } return false; } @@ -500,5 +509,4 @@ public void run() { }, (float) (i + 1) * 2); } } -} - +} \ No newline at end of file diff --git a/source/core/src/main/com/csse3200/game/entities/factories/WaveFactory.java b/source/core/src/main/com/csse3200/game/entities/factories/WaveFactory.java index 31b0546c3..1875ee6e0 100644 --- a/source/core/src/main/com/csse3200/game/entities/factories/WaveFactory.java +++ b/source/core/src/main/com/csse3200/game/entities/factories/WaveFactory.java @@ -90,7 +90,7 @@ public static LevelWaves createLevel(int maxDiff, int maxWaves, int chosenLevel) // TODO hash out level1 test in NPCFactory when doing this. // ArrayList level1Mobs = new ArrayList<>(Arrays.asList("Xeno", "PatrickBoss", "WaterQueen")); // ArrayList level1Mobs = new ArrayList<>(Arrays.asList("Xeno", "IceBoss", "WaterQueen")); - ArrayList level2Mobs = new ArrayList<>(Arrays.asList("ArcaneArcher","SplittingNightBorne")); + ArrayList level2Mobs = new ArrayList<>(Arrays.asList("ArcaneArcher","SplittingNightBorne", "Skeleton", "DeflectWizard")); ArrayList level3Mobs = new ArrayList<>(Arrays.asList("Xeno", "DodgingDragon", "FireWorm")); // The mob bosses assigned to the associated levels (planets) diff --git a/source/core/src/main/com/csse3200/game/physics/components/PhysicsMovementComponent.java b/source/core/src/main/com/csse3200/game/physics/components/PhysicsMovementComponent.java index e1f88cb1d..032cf667f 100644 --- a/source/core/src/main/com/csse3200/game/physics/components/PhysicsMovementComponent.java +++ b/source/core/src/main/com/csse3200/game/physics/components/PhysicsMovementComponent.java @@ -12,6 +12,7 @@ public class PhysicsMovementComponent extends Component implements MovementController { private static final Logger logger = LoggerFactory.getLogger(PhysicsMovementComponent.class); private Vector2 maxSpeed = Vector2Utils.ONE; + private Vector2 normalSpeed; private float skipMovementTime = 0f; // in seconds, for knockback private PhysicsComponent physicsComponent; @@ -104,4 +105,13 @@ public void setSpeed(Vector2 speed) { public Vector2 getSpeed() { return this.maxSpeed; } -} + public void setNormalSpeed(Vector2 normalSpeed) { + this.normalSpeed = normalSpeed; + } + public Vector2 getNormalSpeed() { + if (normalSpeed == null) { + return maxSpeed; + } + return normalSpeed; + } +} \ No newline at end of file diff --git a/source/core/src/test/com/csse3200/game/components/SplitMoblingsTest.java b/source/core/src/test/com/csse3200/game/components/SplitMoblingsTest.java index c82d9f497..ba3da58ad 100644 --- a/source/core/src/test/com/csse3200/game/components/SplitMoblingsTest.java +++ b/source/core/src/test/com/csse3200/game/components/SplitMoblingsTest.java @@ -41,6 +41,7 @@ public class SplitMoblingsTest { private static final int BASE_AMOUNT = 5; private final String[] atlas = { "images/mobs/water_slime.atlas", + "images/mobs/night_borne.atlas" }; Entity baseMob; diff --git a/source/core/src/test/com/csse3200/game/entities/factories/WaveFactoryTest.java b/source/core/src/test/com/csse3200/game/entities/factories/WaveFactoryTest.java index 97058ffa7..3e4cfd845 100644 --- a/source/core/src/test/com/csse3200/game/entities/factories/WaveFactoryTest.java +++ b/source/core/src/test/com/csse3200/game/entities/factories/WaveFactoryTest.java @@ -51,7 +51,7 @@ class WaveFactoryTest { private final int LVL2_DIFF = 3; private final int LVL2_WAVES = 10; private final int LVL2_CHOSEN_LVL = 0; - private final ArrayList LVL2_MOBS = new ArrayList<>(Arrays.asList("Skeleton", "DeflectWizard")); + private final ArrayList LVL2_MOBS = new ArrayList<>(Arrays.asList("ArcaneArcher", "SplittingNightBorne", "Skeleton", "DeflectWizard")); private final String LVL2_BOSS = "PatrickBoss"; // level stats for level 3 - fire planet