Skip to content

Commit

Permalink
added a tracker of total mobs for enemy to to wave service
Browse files Browse the repository at this point in the history
  • Loading branch information
samsully committed Oct 15, 2023
1 parent 25ba43f commit ba6b98d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> wave : possibleMobs) {
Expand Down Expand Up @@ -189,6 +190,7 @@ public static LevelWaves createLevel(int chosenLevel) {
mobs.put(mob, mobStats);

leftToSort --;
totalMobs += num;
}
minMobs ++;

Expand All @@ -199,7 +201,9 @@ public static LevelWaves createLevel(int chosenLevel) {
// Add boss wave
HashMap<String, int[]> 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);
Expand Down
26 changes: 26 additions & 0 deletions source/core/src/main/com/csse3200/game/services/WaveService.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public class WaveService {

private boolean skipDelay = false;

private int levelEnemyCount = 0;
private int remainingLevelEnemyCount = 0;


/**
* Constructor for the Wave Service
Expand Down Expand Up @@ -56,6 +59,7 @@ public int getEnemyCount() {
*/
public void updateEnemyCount() {
enemyCount -= 1;
remainingLevelEnemyCount -= 1;
logger.info("{} enemies remaining in wave", getEnemyCount());
}

Expand Down Expand Up @@ -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;
}
}

0 comments on commit ba6b98d

Please sign in to comment.