Skip to content

Commit

Permalink
When all the waves are completed, the screen transitions to the lose …
Browse files Browse the repository at this point in the history
…screen. This will need to be changed to the win screen when it has been created by team 3

Changes need to be made in MainGameScreen, line 230 - link to "win" rather than lose.

Potentially need to also link to unlocking the next level/planet also.
  • Loading branch information
meganroxburgh committed Oct 12, 2023
1 parent 5856ccc commit e533bb4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public MainGameActions(GdxGame game) {
public void create() {
entity.getEvents().addListener("exit", this::onExit);
entity.getEvents().addListener("lose", this::onLose);
//entity.getEvents().addListener("win", this::onWin);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ public void update() {
ServiceLocator.getWaveService().setNextWaveTime(currentTime + (spawnDelay * 1000));

// Check if level has been completed - no more waves remaining
if (currentWaveIndex == this.level.getNumWaves()) {
logger.info("No waves remaining, level completed");
if (currentWaveIndex == this.level.getNumWaves() - 1) {
logger.info("No waves remaining");
ServiceLocator.getWaveService().setLevelCompleted();

} else {
Expand Down
14 changes: 11 additions & 3 deletions source/core/src/main/com/csse3200/game/screens/MainGameScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,21 @@ public void render(float delta) {
// Checks if tower selected is dead
this.getUpgradedInputHandler().checkForDispose();

ServiceLocator.getWaveService().getDisplay().updateTimerButton();
ServiceLocator.getWaveService().getDisplay().updateMobCount();
renderer.render();

// Check if the game has ended
if (ServiceLocator.getGameEndService().hasGameEnded()) {
ui.getEvents().trigger("lose");
}

ServiceLocator.getWaveService().getDisplay().updateTimerButton();
ServiceLocator.getWaveService().getDisplay().updateMobCount();
renderer.render();
// Check if all waves are completed and the level has been completed
if (ServiceLocator.getWaveService().isLevelCompleted()) {
logger.info("Main game level completed detected, go to win screen");
ui.getEvents().trigger("lose"); // needs to change to: ui.getEvents().trigger("win");
// Add something in to unlock the next planet/level?
}
}

@Override
Expand Down Expand Up @@ -297,6 +304,7 @@ private void createUI() {
.addComponent(ServiceLocator.getWaveService().getDisplay())
.addComponent(new MainGameExitDisplay())
.addComponent(new MainGameLoseDisplay())
//.addComponent(new MainGameWinDisplay()) <- needs to be uncommented when team 3 have implemented the ui
.addComponent(new MainGamePauseDisplay(this.game))
.addComponent(new Terminal())
.addComponent(inputComponent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public void updateEnemyCount() {
*/
public void setLevelCompleted() {
if (!levelCompleted) {
logger.info("Level set to completed");
levelCompleted = true;
}
}
Expand Down

0 comments on commit e533bb4

Please sign in to comment.