Skip to content

Commit

Permalink
Merge branch 'Team-4---Waves' into Team-4---Blair
Browse files Browse the repository at this point in the history
  • Loading branch information
BlairCannon97 committed Sep 30, 2023
2 parents 6e056bc + 6ac2e1f commit 1dd91e6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 12 deletions.
11 changes: 0 additions & 11 deletions source/core/assets/configs/Level1.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public void spawnWave() {
do {
currentRandom = rand.nextInt(1, 7);
} while (currentRandom == previousRandom);
ServiceLocator.getWaveService().setNextLane(currentRandom);
GridPoint2 randomPos = new GridPoint2(19, currentRandom);
this.getEvents().trigger("spawnWave", waves.get(waveIndex)
.getMobs().get(mobIndex), randomPos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,24 @@ public void update() {
// Check if level has been completed - no more waves remaining
if (currentWaveIndex == this.level.getNumWaves()) {
logger.info("No waves remaining, level completed");
this.waveEnd.play();
ServiceLocator.getWaveService().setLevelCompleted();

} else {
// Spawn the next wave
logger.info("No enemies remaining, begin next wave");
this.waveEnd.play();
this.waveInProgress = true;
this.level.setWaveIndex(currentWaveIndex);
// Set the service wave count to the current wave index.
ServiceLocator.getWaveService().setWaveCount(currentWaveIndex);
this.currentWave = this.level.getWave(currentWaveIndex);
ServiceLocator.getWaveService().setEnemyCount(currentWave.getSize());
//endTime = globalTime.getTime() + (SPAWNING_INTERVAL * 1000L); // reset end time
}

} else {
logger.info("{} enemies remaining in wave {}", ServiceLocator.getWaveService().getEnemyCount(), currentWaveIndex);
logger.info("WAVE SERVICE NUMBER: Wave Number {}",ServiceLocator.getWaveService().getWaveCount());
if (waveInProgress) {
this.level.spawnWave();
}
Expand Down
21 changes: 21 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 @@ -6,6 +6,11 @@
public class WaveService {
private static final Logger logger = LoggerFactory.getLogger(WaveService.class);
private int enemyCount;
private boolean gameOver = false;
private int lane;

private int waveCount = 1;

private boolean levelCompleted = false;


Expand Down Expand Up @@ -53,11 +58,27 @@ public void setLevelCompleted() {
}
}

public void setNextLane(int lane) {
this.lane = lane;
}

public int getNextLane() {
return lane;
}

/**
* Returns the game over state
* @return (boolean) true if the game is over; false otherwise
*/
public boolean isLevelCompleted() {
return levelCompleted;
}

public int getWaveCount() {
return this.waveCount;
}

public void setWaveCount(int waveCount) {
this.waveCount += waveCount;
}
}

0 comments on commit 1dd91e6

Please sign in to comment.