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 9f9933fa6..a6aaefae5 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 @@ -160,6 +160,7 @@ public static LevelWaves createLevel(int chosenLevel) { break; } + int totalMobs = 0; // Create mxWaves number of waves with mob stats increasing int atWave = 1; for (ArrayList wave : possibleMobs) { @@ -189,6 +190,7 @@ public static LevelWaves createLevel(int chosenLevel) { mobs.put(mob, mobStats); leftToSort --; + totalMobs += num; } minMobs ++; @@ -199,7 +201,9 @@ public static LevelWaves createLevel(int chosenLevel) { // Add boss wave HashMap bossMob = new HashMap<>(); bossMob.put(boss, new int[]{1, bossHealth}); + totalMobs ++; + ServiceLocator.getWaveService().setTotalMobs(totalMobs); level.addWave(new WaveClass(bossMob)); logger.info("Level created: " + level); diff --git a/source/core/src/main/com/csse3200/game/services/WaveService.java b/source/core/src/main/com/csse3200/game/services/WaveService.java index 476b87a89..a32f6c0f2 100644 --- a/source/core/src/main/com/csse3200/game/services/WaveService.java +++ b/source/core/src/main/com/csse3200/game/services/WaveService.java @@ -21,6 +21,9 @@ public class WaveService { private boolean skipDelay = false; + private int levelEnemyCount = 0; + private int remainingLevelEnemyCount = 0; + /** * Constructor for the Wave Service @@ -56,6 +59,7 @@ public int getEnemyCount() { */ public void updateEnemyCount() { enemyCount -= 1; + remainingLevelEnemyCount -= 1; logger.info("{} enemies remaining in wave", getEnemyCount()); } @@ -161,4 +165,26 @@ public void toggleDelay() { public boolean shouldSkip() { return this.skipDelay; } + + /** + * retrieve the number of enemies in the level + * */ + public int totalMobs() { + return this.levelEnemyCount; + } + + /** + * set the total number of enemies in the level + * */ + public void setTotalMobs(int total) { + this.levelEnemyCount = total; + this.remainingLevelEnemyCount = total; + } + + /** + * get the number of mobs remaining for the whole level() + * */ + public int remainingMobsForLevel() { + return this.remainingLevelEnemyCount; + } }