Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mohamad juice #276

Merged
merged 4 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -358,8 +358,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
Loading