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

Feature/team4/wave adjustments #265

Merged
merged 13 commits into from
Oct 15, 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
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 @@ -284,9 +284,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 @@ -477,10 +478,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 @@ -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
Loading