diff --git a/source/core/src/main/com/csse3200/game/components/maingame/LevelProgressBar.java b/source/core/src/main/com/csse3200/game/components/maingame/LevelProgressBar.java index cfc80f820..d885beb87 100644 --- a/source/core/src/main/com/csse3200/game/components/maingame/LevelProgressBar.java +++ b/source/core/src/main/com/csse3200/game/components/maingame/LevelProgressBar.java @@ -1,5 +1,6 @@ package com.csse3200.game.components.maingame; +import com.badlogic.gdx.audio.Music; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Pixmap; import com.badlogic.gdx.graphics.Texture; @@ -7,17 +8,20 @@ import com.badlogic.gdx.scenes.scene2d.ui.ProgressBar; import com.badlogic.gdx.scenes.scene2d.utils.Drawable; import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; +import com.csse3200.game.screens.GameLevelData; +import com.csse3200.game.services.ServiceLocator; public class LevelProgressBar extends ProgressBar { + static int selectedLevel = GameLevelData.getSelectedLevel(); + /** * @param width of the health bar * @param height of the health bar */ public LevelProgressBar(int width, int height) { - super(0f, 100f, 0.01f, false, new ProgressBarStyle()); + super(0f, getMobCount(), 0.01f, false, new ProgressBarStyle()); getStyle().background = getColoredDrawable(width, height, Color.RED); -// getStyle().knob = getColoredDrawable(0, height, Color.GREEN); getStyle().knob = new TextureRegionDrawable(new TextureRegion(new Texture("images/skeleton.png"))); getStyle().knobBefore = getColoredDrawable(width, height, Color.GREEN); @@ -30,6 +34,13 @@ public LevelProgressBar(int width, int height) { setAnimateDuration(0.25f); } + /** + * Color filling for the Progress Bar + * @param width the width in pixels + * @param height the height in pixels + * @param color the color of the filling + * @return Drawable + */ public static Drawable getColoredDrawable(int width, int height, Color color) { Pixmap pixmap = new Pixmap(width, height, Pixmap.Format.RGBA8888); pixmap.setColor(color); @@ -41,4 +52,27 @@ public static Drawable getColoredDrawable(int width, int height, Color color) { return drawable; } + + /** + * Get the number of mobs based on the level + * @return number of total mobs + */ + public static int getMobCount() { + + switch (selectedLevel) { + // Desert + case 1 -> { // Ice + ServiceLocator.getWaveService().setTotalMobs(91); + return 91; + } + case 2 -> { // Lava + ServiceLocator.getWaveService().setTotalMobs(204); + return 204; + } + default -> { + ServiceLocator.getWaveService().setTotalMobs(27); + return 27; + } + } + } } diff --git a/source/core/src/main/com/csse3200/game/components/maingame/MainGameDisplay.java b/source/core/src/main/com/csse3200/game/components/maingame/MainGameDisplay.java index 937b6250f..f9d6c4de1 100644 --- a/source/core/src/main/com/csse3200/game/components/maingame/MainGameDisplay.java +++ b/source/core/src/main/com/csse3200/game/components/maingame/MainGameDisplay.java @@ -356,8 +356,11 @@ public void draw(SpriteBatch batch) { towerUpdate(); } + /** + * Update the level progress bar value + */ public void updateLevelProgressBar() { - float totalSecs = ((float) ServiceLocator.getTimeSource().getTime() / 1000); + int totalSecs = ServiceLocator.getWaveService().totalMobs() - ServiceLocator.getWaveService().remainingMobsForLevel(); progressbar.setValue(totalSecs); } 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 c0526e42b..20d1781f2 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,7 +160,7 @@ public static LevelWaves createLevel(int chosenLevel) { break; } - int totalMobs = 0; +// int totalMobs = 0; // Create mxWaves number of waves with mob stats increasing int atWave = 1; for (ArrayList wave : possibleMobs) { @@ -190,7 +190,7 @@ public static LevelWaves createLevel(int chosenLevel) { mobs.put(mob, mobStats); leftToSort --; - totalMobs += num; +// totalMobs += num; } minMobs ++; level.addWave(new WaveClass(mobs)); @@ -200,9 +200,9 @@ public static LevelWaves createLevel(int chosenLevel) { // Add boss wave HashMap bossMob = new HashMap<>(); bossMob.put(boss, new int[]{1, bossHealth}); - totalMobs ++; +// totalMobs ++; - ServiceLocator.getWaveService().setTotalMobs(totalMobs); +// ServiceLocator.getWaveService().setTotalMobs(totalMobs); level.addWave(new WaveClass(bossMob));