Skip to content

Commit

Permalink
Merge branch 'team-2-ui' of github.com:UQcsse3200/2023-studio-3 into …
Browse files Browse the repository at this point in the history
…team-2-ui
  • Loading branch information
The-AhmadAA committed Oct 16, 2023
2 parents d620802 + e8f9d2c commit 781a328
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
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;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
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);

Expand All @@ -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);
Expand All @@ -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;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> wave : possibleMobs) {
Expand Down Expand Up @@ -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));
Expand All @@ -200,9 +200,9 @@ public static LevelWaves createLevel(int chosenLevel) {
// Add boss wave
HashMap<String, int[]> 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));


Expand Down

0 comments on commit 781a328

Please sign in to comment.