Skip to content

Commit

Permalink
Merge pull request #267 from UQcsse3200/Mohamad_Juice
Browse files Browse the repository at this point in the history
Mohamad juice
  • Loading branch information
The-AhmadAA authored Oct 15, 2023
2 parents ba0b4c2 + 7f9c8c3 commit 6f0c14b
Show file tree
Hide file tree
Showing 19 changed files with 531 additions and 400 deletions.
53 changes: 34 additions & 19 deletions source/core/assets/configs/tower.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,52 @@
{
"weapon": {
"income": {
"health": 10,
"baseAttack": 10,
"baseAttack": 0,
"cost": 10
},
"wall": {
"health": 20,
"baseAttack": 0,
"cost": 5
},
"income": {
"health": 20,
"health": 300,
"baseAttack": 0,
"cost": 1
"cost": 45
},
"TNTTower": {
"health": 10,
"baseAttack": 5,
"cost": 1
"cost": 30
},
"weapon": {
"health": 75,
"baseAttack": 15,
"cost": 15
},
"DroidTower": {
"health": 50,
"baseAttack": 5,
"cost": 1
"health": 100,
"baseAttack": 25,
"cost": 45
},
"fireTower": {
"health": 10,
"baseAttack": 10,
"cost": 10
"health": 100,
"baseAttack": 25,
"cost": 45
},
"stunTower": {
"health": 10,
"baseAttack": 10,
"cost": 10
"health": 100,
"baseAttack": 25,
"cost": 45
},
"fireworksTower": {
"health": 125,
"baseAttack": 45,
"cost": 70
},
"pierceTower": {
"health": 125,
"baseAttack": 45,
"cost": 70
},
"ricochetTower": {
"health": 125,
"baseAttack": 45,
"cost": 70
}
}
Binary file added source/core/assets/images/skeleton.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added source/core/assets/images/skeleton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 7 additions & 7 deletions source/core/src/main/com/csse3200/game/areas/ForestGameArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,10 @@ public void create() {
// Set up infrastructure for end game tracking
// player = spawnPlayer();

waves = WaveFactory.createWaves();
spawnEntity(waves);
waves.getEvents().addListener("spawnWave", this::spawnMob);
logger.info("Creating waves");
waves = WaveFactory.createWaves();
spawnEntity(waves);
waves.getEvents().addListener("spawnWave", this::spawnMob);
// spawnCoat();
// spawnDodgingDragonKnight(17,4);
// spawnDeflectWizard(17, 3);
Expand Down Expand Up @@ -473,10 +474,9 @@ public void spawnMob(String entity, GridPoint2 randomPos, int health) {
case "WaterQueen":
mob = NPCFactory.createWaterQueen(health);
break;
//TODO implement when boss is ready
// case "FireBoss":
// mob = MobBossFactory.createDemonBoss(health);
// break;
case "FireBoss":
mob = MobBossFactory.createDemonBoss(health);
break;
case "IceBoss":
mob = MobBossFactory.createIceBoss(health);
break;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.csse3200.game.components.maingame;

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;

public class LevelProgressBar extends ProgressBar {

/**
* @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());
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);

setWidth(width);
setHeight(height);

setAnimateDuration(0.0f);
setValue(1f);

setAnimateDuration(0.25f);
}

public static Drawable getColoredDrawable(int width, int height, Color color) {
Pixmap pixmap = new Pixmap(width, height, Pixmap.Format.RGBA8888);
pixmap.setColor(color);
pixmap.fill();

TextureRegionDrawable drawable = new TextureRegionDrawable(new TextureRegion(new Texture(pixmap)));

pixmap.dispose();

return drawable;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class UIElementsDisplay extends UIComponent {
private final Table buttonTable = new Table();
private TextButton remainingMobsButton;
private TextButton timerButton;
private LevelProgressBar progressbar;
private final int timer = 110;

@Override
Expand All @@ -58,9 +59,17 @@ private void addActors() {

stage.addActor(buttonTable);

progressbar = new LevelProgressBar(500, 10);
progressbar.setPosition(500, Gdx.graphics.getHeight() - 200);
stage.addActor(progressbar);

createTimerButton();
}

public void updateLevelProgressBar() {
float totalSecs = (ServiceLocator.getTimeSource().getTime() / 1000);
progressbar.setValue(totalSecs);
}

/**
* This method updates the mob count button as mobs die in the game
Expand Down Expand Up @@ -144,5 +153,6 @@ public float getZIndex() {
public void dispose() {
super.dispose();
buttonTable.clear();
progressbar.clear();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ private void onDeath() {
float newXPosition = (float) (entity.getPosition().x - OFFSET_DISTANCE);
float newYPosition = (float) (entity.getPosition().y);

if (withinBounds(newXPosition, newYPosition))
if (withinBounds(newXPosition, newYPosition)) {
spawnAdditionalMob(newXPosition, newYPosition, initialScaleX, initialScaleY);
}
}

// Inspired by:
Expand All @@ -103,8 +104,9 @@ private void onDeath() {
float newY = entity.getPosition().y + (float) OFFSET_DISTANCE *
(float) Math.sin(radians);

if (withinBounds(newX, newY))
if (withinBounds(newX, newY)) {
spawnAdditionalMob(newX, newY, initialScaleX, initialScaleY);
}
}
}

Expand All @@ -129,6 +131,7 @@ public void spawnAdditionalMob(float positionX, float positionY,
// waterSlime.setScale(initialScaleX, initialScaleY);

ServiceLocator.getEntityService().register(waterSlime);
//ServiceLocator.getWaveService().setEnemyCount(ServiceLocator.getWaveService().getEnemyCount() + 1);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class CurrencyTask extends DefaultTask implements PriorityTask {
private long endTime;
private int interval;
private final Scrap scrap = new Scrap(); // currency to update
private final int currencyAmount = scrap.getAmount(); // amount of currency to update
private final int currencyAmount = 30; // amount of currency to update
private static final String IDLE = "idleStartEco";
private static final String MOVE = "moveStartEco";
private static final String DEATH = "deathStartEco";
Expand Down Expand Up @@ -49,7 +49,6 @@ public CurrencyTask(int priority, int interval) {
public void start() {
super.start();
owner.getEntity().getEvents().addListener("addIncome",this::changeInterval);
// TODO: changed 30 TIMES MULTIPLIER to 5 times
endTime = timeSource.getTime() + (interval * 1500L);
owner.getEntity().getEvents().trigger(IDLE);
}
Expand Down Expand Up @@ -98,11 +97,11 @@ public void updateTowerState() {
* Updates the currency based on time intervals.
*/
public void updateCurrency() {
//logger.info("Updating currency");
ServiceLocator.getCurrencyService().getScrap().modify(currencyAmount/2);
logger.info("Updating currency");
ServiceLocator.getCurrencyService().getScrap().modify(currencyAmount);

Vector2 coordinates = this.owner.getEntity().getCenterPosition();
ServiceLocator.getCurrencyService().getDisplay().currencyPopUp(coordinates.x, coordinates.y, currencyAmount/2, 25);
ServiceLocator.getCurrencyService().getDisplay().currencyPopUp(coordinates.x, coordinates.y, currencyAmount, 25);

ServiceLocator.getCurrencyService().getDisplay().updateScrapsStats(); // update currency display

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public void update() {
movementTask.stop();
deathFlag = true;
} else if (deathFlag && animation.isFinished()) {
ServiceLocator.getWaveService().updateEnemyCount();
mob.setFlagForDelete(true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.csse3200.game.services.ServiceLocator;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Random;

Expand Down Expand Up @@ -69,7 +68,7 @@ public void spawnWave() {
ServiceLocator.getWaveService().setNextLane(currentRandom);
GridPoint2 randomPos = new GridPoint2(19, currentRandom);
Tuple mobStats = waves.get(waveIndex).getMobs().get(mobIndex);
this.getEvents().trigger("spawnWave", mobStats.mob, randomPos, mobStats.health);
this.getEvents().trigger("spawnWave", mobStats.mob, randomPos, mobStats.value);
startTime = gameTime.getTime();
mobIndex++;
previousRandom = currentRandom;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ public class Tuple {

public String mob;

public int health;
public int value;

public Tuple(String mob, int health) {
public Tuple(String mob, int value) {
this.mob = mob;
this.health = health;
this.value = value;
}

@Override
public String toString(){
return "Mob: " + mob + " Health: " + health;
return "Mob: " + mob + " Health: " + value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void start() {
this.level = (LevelWaves) this.owner.getEntity();
this.currentWave = level.getWave(currentWaveIndex);
ServiceLocator.getWaveService().setEnemyCount(currentWave.getSize());
// logger.info("Wave {} starting with {} enemies", currentWaveIndex, ServiceLocator.getWaveService().getEnemyCount());
logger.info("Wave {} starting with {} enemies", currentWaveIndex, ServiceLocator.getWaveService().getEnemyCount());
this.waveStart.play();
// endTime = globalTime.getTime() + (SPAWNING_INTERVAL * 1000);
}
Expand All @@ -94,13 +94,6 @@ public void start() {
@Override
public void update() {
if (ServiceLocator.getWaveService().getEnemyCount() == 0) {
// currentWaveIndex++;

long currentTime = ServiceLocator.getTimeSource().getTime();
// Setting the timestamp for when the next mobs will spawn.
// Currently, the delay of mobs spawning after wave start
int spawnDelay = ServiceLocator.getWaveService().getSpawnDelay();
ServiceLocator.getWaveService().setNextWaveTime(currentTime + (spawnDelay * 1000));

// Check if level has been completed - no more waves remaining
if (currentWaveIndex == this.level.getNumWaves() - 1) {
Expand All @@ -116,7 +109,6 @@ public void update() {
ServiceLocator.getWaveService().setNextWaveTime(nextWaveAt);
} else {
if (globalTime.getTime() >= nextWaveAt || ServiceLocator.getWaveService().shouldSkip()) {
logger.info("Next wave starting");
ServiceLocator.getWaveService().toggleDelay();
currentWaveIndex++;
ServiceLocator.getWaveService().setNextWaveTime(0);
Expand All @@ -128,6 +120,7 @@ public void update() {
ServiceLocator.getWaveService().setWaveCount(currentWaveIndex);
this.currentWave = this.level.getWave(currentWaveIndex);
ServiceLocator.getWaveService().setEnemyCount(currentWave.getSize());
logger.info("Next wave {} starting with {} enemies", currentWaveIndex, ServiceLocator.getWaveService().getEnemyCount());
//endTime = globalTime.getTime() + (SPAWNING_INTERVAL * 1000L); // reset end time
}
}
Expand Down
Loading

0 comments on commit 6f0c14b

Please sign in to comment.