Skip to content

Commit

Permalink
code smell fixes and updated levelSelect font
Browse files Browse the repository at this point in the history
  • Loading branch information
The-AhmadAA committed Oct 15, 2023
2 parents ba0b4c2 + f03a863 commit c2ab57b
Show file tree
Hide file tree
Showing 20 changed files with 486 additions and 411 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
}
}
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
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 @@ -34,8 +34,7 @@ public class EngineerCombatTask extends DefaultTask implements PriorityTask {
// weaponCapacity is the number of shots fired before the engineer has to reload
private static final int weaponCapacity = 10;
private int shotsFired = 0; // Tracks the number of shots fired in the current cycle

private Vector2 engineerPosition = new Vector2(10, 50); // Placeholder value for the Engineer's position.

private final Vector2 maxRangePosition = new Vector2();
private PhysicsEngine physics;
private GameTime timeSource;
Expand Down Expand Up @@ -68,7 +67,8 @@ public EngineerCombatTask(float maxRange) {
public void start() {
super.start();
// Set the tower's coordinates
this.engineerPosition = owner.getEntity().getCenterPosition();
// Placeholder value for the Engineer's position.
Vector2 engineerPosition = owner.getEntity().getCenterPosition();
this.maxRangePosition.set(engineerPosition.x + maxRange, engineerPosition.y);
// Default to idle mode
owner.getEntity().getEvents().trigger(IDLE_RIGHT);
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 c2ab57b

Please sign in to comment.