diff --git a/source/core/src/main/com/csse3200/game/components/maingame/UIElementsDisplay.java b/source/core/src/main/com/csse3200/game/components/maingame/UIElementsDisplay.java index 7e3b1fac3..a095f30ac 100644 --- a/source/core/src/main/com/csse3200/game/components/maingame/UIElementsDisplay.java +++ b/source/core/src/main/com/csse3200/game/components/maingame/UIElementsDisplay.java @@ -1,8 +1,10 @@ package com.csse3200.game.components.maingame; +import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.ui.Button; +import com.badlogic.gdx.scenes.scene2d.ui.Skin; import com.badlogic.gdx.scenes.scene2d.ui.Table; import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; @@ -21,7 +23,8 @@ public class UIElementsDisplay extends UIComponent { private static final float Z_INDEX = 2f; private final Table mobsButtonTable = new Table(); private final Table timerTable = new Table(); - private final TextButton remainingMobsButton = new ButtonFactory().createButton("Mobs left:"); + Skin skin = new Skin(Gdx.files.internal("flat-earth/skin/flat-earth-ui.json")); + private TextButton remainingMobsButton = new ButtonFactory().createButton("Mobs left:"); private final TextButton timerButton = new ButtonFactory().createButton("Next wave:");; @Override @@ -62,7 +65,7 @@ private void addActors() { * This method updates the mob count button as mobs die in the game */ public void updateMobCount() { - remainingMobsButton.setText("Mobs left:" + ServiceLocator.getWaveService().getEnemyCount()); + remainingMobsButton.getLabel().setText("Mobs:" + ServiceLocator.getWaveService().getEnemyCount()); } @Override diff --git a/source/core/src/main/com/csse3200/game/screens/MainGameScreen.java b/source/core/src/main/com/csse3200/game/screens/MainGameScreen.java index c530fbc4a..529748428 100644 --- a/source/core/src/main/com/csse3200/game/screens/MainGameScreen.java +++ b/source/core/src/main/com/csse3200/game/screens/MainGameScreen.java @@ -230,7 +230,7 @@ private void createUI() { .addComponent(new PerformanceDisplay()) .addComponent(new MainGameActions(this.game)) .addComponent(new MainGameExitDisplay()) - .addComponent(new UIElementsDisplay()) + .addComponent(ServiceLocator.getWaveService().getDisplay()) .addComponent(new MainGameLoseDisplay()) .addComponent(new Terminal()) .addComponent(inputComponent) 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 b473391e7..a8416b11f 100644 --- a/source/core/src/main/com/csse3200/game/services/WaveService.java +++ b/source/core/src/main/com/csse3200/game/services/WaveService.java @@ -23,7 +23,7 @@ public class WaveService { */ public WaveService() { this.enemyCount = 0; - display = new UIElementsDisplay(); + this.display = new UIElementsDisplay(); } /** @@ -121,4 +121,13 @@ public long getNextWaveTime() { public void setNextWaveTime(long nextWaveTime) { this.nextWaveTime = nextWaveTime; } + + /** + * Used for adding this instance of UIElementsDisplay to the mainGameScreen. This is needed as update is performed + * for this instance of the display. + * @return the updating instance of UIElementsDisplay + */ + public UIElementsDisplay getDisplay() { + return this.display; + } }