Skip to content

Commit

Permalink
Co-authored-by: Chia-Chuan Tsou (Jason) <[email protected]
Browse files Browse the repository at this point in the history
…b.com>

Co-authored-by: gregchan550 <[email protected]>
  • Loading branch information
MiniSoda17 committed Oct 16, 2023
2 parents fc92869 + 2efa8df commit 869ac9d
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public void spawnAdditionalMob(float positionX, float positionY,

ServiceLocator.getEntityService().register(entityType);

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import com.csse3200.game.ai.tasks.PriorityTask;
import com.csse3200.game.services.GameTime;
import com.csse3200.game.services.ServiceLocator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class SpawnWaveTask extends DefaultTask implements PriorityTask {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ private void spawnMob() {
Entity newMob = NPCFactory.createSplittingWaterSlime(80);
newMob.setPosition((float) (iceBaby.getPosition().x + 0.5), (float) (iceBaby.getPosition().y + 0.5));
ServiceLocator.getEntityService().register(newMob);
ServiceLocator.getWaveService().setEnemyCount(ServiceLocator.getWaveService().getEnemyCount() + 1);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ public List<WaveClass> getWaves() {

@Override
public String toString() {
String result = "";
for (WaveClass wave : waves) {
result += wave.toString() + "\n";
}
return result;
StringBuilder result = new StringBuilder();
for (WaveClass wave : waves) {
result.append(wave.toString()).append("\n");
}
return result.toString();
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
package com.csse3200.game.components.tasks.waves;


import com.csse3200.game.services.GameTime;


import java.util.*;

public class WaveClass {
private HashMap<String, int[]> entities;
private List<Tuple> wave;
private int mobIndex;

/**
* Constructor for the WaveClass
Expand All @@ -18,7 +13,6 @@ public class WaveClass {
public WaveClass(HashMap<String, int[]> entities) {
this.entities = entities;
this.wave = entitiesToWave();
this.mobIndex = 0;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
package com.csse3200.game.components.tasks.waves;

import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.audio.Sound;
import com.csse3200.game.ai.tasks.DefaultTask;
import com.csse3200.game.ai.tasks.PriorityTask;
import com.csse3200.game.ai.tasks.Task;
import com.csse3200.game.services.GameTime;
import com.csse3200.game.services.ResourceService;
import com.csse3200.game.services.ServiceLocator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

public class WaveTask extends DefaultTask implements PriorityTask {
private static final Logger logger = LoggerFactory.getLogger(WaveTask.class);
private LevelWaves level;
Expand All @@ -21,10 +17,6 @@ public class WaveTask extends DefaultTask implements PriorityTask {
private long nextWaveAt = 0;
private int currentWaveIndex = 0;
private boolean waveInProgress;
private float startTime = 0;
private float endTime = 0;
private final float INITIAL_WAIT_INTERVAL = 10;
private final int SPAWNING_INTERVAL = 10;

private static final String[] waveSounds = {
"sounds/waves/wave-start/Wave_Start_Alarm.ogg",
Expand Down Expand Up @@ -83,7 +75,6 @@ public void start() {
this.currentWave = level.getWave(currentWaveIndex);
ServiceLocator.getWaveService().setEnemyCount(currentWave.getSize());
logger.info("Wave {} starting with {} enemies", currentWaveIndex, ServiceLocator.getWaveService().getEnemyCount());
// endTime = globalTime.getTime() + (SPAWNING_INTERVAL * 1000);
}

/**
Expand All @@ -101,7 +92,6 @@ public void update() {

} else {
// Spawn the next wave
// logger.info("No enemies remaining, begin next wave");
if (nextWaveAt == 0) {
logger.info("Next wave in 10 seconds");
this.waveEnd.play();
Expand All @@ -121,16 +111,11 @@ public void update() {
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
}
}
}

} else {
//logger.info("{} enemies remaining in wave {}", ServiceLocator.getWaveService().getEnemyCount(), currentWaveIndex);
//logger.info("WAVE SERVICE NUMBER: Wave Number {}",ServiceLocator.getWaveService().getWaveCount());
//logger.info("NEXT WAVE AT {}", ServiceLocator.getWaveService().getNextWaveTime());
//logger.info("TIME IS {}", ServiceLocator.getTimeSource().getTime());
if (waveInProgress) {
this.level.spawnWave();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ public static Entity createGhost() {
**/
ghost
.addComponent(new CombatStatsComponent(config.health, config.baseAttack))
// .addComponent(animator)
.addComponent(new TextureRenderComponent("images/mobs/satyr.png"));
// .addComponent(new GhostAnimationController());

ghost.getComponent(TextureRenderComponent.class).scaleEntity();

Expand Down Expand Up @@ -103,8 +101,6 @@ public static Entity createGhostKing() {
*
* @return entity
*/
// public static Entity createSkeleton(int health) {
// Entity skeleton = createBaseNPC(int health);
public static Entity createSkeleton(int health) {
Entity skeleton = createBaseNPC();
ArrayList<Currency> drops = new ArrayList<>();
Expand Down Expand Up @@ -396,7 +392,7 @@ public static Entity createNecromancer(int health) {
}

public static Entity createFirewizard(int health) {
Entity Firewizard = createBaseNPC();
Entity fireWizard = createBaseNPC();
ArrayList<Currency> drops = new ArrayList<>();

AnimationRenderComponent animator =
Expand All @@ -410,16 +406,16 @@ public static Entity createFirewizard(int health) {
AITaskComponent aiTaskComponent = new AITaskComponent()
.addTask(new MobTask(MobType.FIREWIZARD));

Firewizard
fireWizard
.addComponent(new CombatStatsComponent(health, 0, drops))
.addComponent(animator)
.addComponent(new FirewizardAnimationController())
.addComponent(aiTaskComponent);

Firewizard.getComponent(HitboxComponent.class).setAsBoxAligned(new Vector2(.3f, .5f), PhysicsComponent.AlignX.RIGHT, PhysicsComponent.AlignY.BOTTOM);
Firewizard.getComponent(AnimationRenderComponent.class).scaleEntity();
fireWizard.getComponent(HitboxComponent.class).setAsBoxAligned(new Vector2(.3f, .5f), PhysicsComponent.AlignX.RIGHT, PhysicsComponent.AlignY.BOTTOM);
fireWizard.getComponent(AnimationRenderComponent.class).scaleEntity();

return Firewizard;
return fireWizard;
}

public static Entity createArcaneArcher(int health) {
Expand Down Expand Up @@ -503,7 +499,6 @@ public static Entity createXenoGrunt(int health) {
animator.addAnimation(DEFAULT, 0.1f);
xenoGrunt
.addComponent(new CombatStatsComponent(health, config.baseAttack, drops, melee, projectiles))
// .addComponent(new CombatStatsComponent(config.fullHeath, config.baseAttack, drops, melee, projectiles))
.addComponent(animator)
.addComponent(new XenoAnimationController());

Expand Down Expand Up @@ -536,10 +531,7 @@ public static Entity createMeleeBaseNPC() {
new AITaskComponent()
.addTask(new MobWanderTask(2f))
.addTask(new MobMeleeAttackTask(2));
// .addTask(new MobAttackTask(2, 2f));
// .addTask(new MeleeMobTask(new Vector2(2f, 2f), 2f));

// .addTask(new MobAttackTask(2, 40));
Entity npc =
new Entity()
.addComponent(new PhysicsComponent())
Expand All @@ -560,11 +552,8 @@ public static Entity createRangedBaseNPC() {
AITaskComponent aiComponent =
new AITaskComponent()
.addTask(new MobWanderTask(2f))
// .addTask(new MobAttackTask(2, 2f));
.addTask(new MobRangedAttackTask(2));
// .addTask(new MeleeMobTask(new Vector2(2f, 2f), 2f));

// .addTask(new MobAttackTask(2, 40));
Entity npc =
new Entity()
.addComponent(new PhysicsComponent())
Expand Down Expand Up @@ -634,9 +623,6 @@ public static Entity createDodgingDragonKnight(int health) {
Entity dodgeKnight = createDragonKnight(health);

dodgeKnight.addComponent(new DodgingComponent(PhysicsLayer.PROJECTILE, 0.25f, 5f));
// dodgeKnight.getComponent(AITaskComponent.class).addTask(new MobDodgeTask(new Vector2(2f, 2f), 2f, 5));
// dodgeKnight.getComponent(AITaskComponent.class).
// addTask(new MobDodgeTask(MobType.DRAGON_KNIGHT, 5));
dodgeKnight.getComponent(AITaskComponent.class).getTask(MobTask.class).setDodge(true);
PhysicsUtils.setScaledCollider(dodgeKnight, 0.3f, 1f);
dodgeKnight.setScale(0.3f, 1f);
Expand All @@ -653,19 +639,13 @@ public static Entity createDodgingArcaneArcher(int health) {
Entity dodgeKnight = createArcaneArcher(health);

dodgeKnight.addComponent(new DodgingComponent(PhysicsLayer.PROJECTILE, 0.25f));
// dodgeKnight.getComponent(AITaskComponent.class).addTask(new MobDodgeTask(new Vector2(2f, 2f), 2f, 5));
// dodgeKnight.getComponent(AITaskComponent.class).
// addTask(new MobDodgeTask(MobType.DRAGON_KNIGHT, 5));
dodgeKnight.getComponent(AITaskComponent.class).getTask(MobTask.class).setDodge(true);
PhysicsUtils.setScaledCollider(dodgeKnight, 0.3f, 0.7f);
dodgeKnight.setScale(0.3f, 0.7f);

return dodgeKnight;
}

// public static Entity createDeflectXenoGrunt(int health) {
// Entity deflectXenoGrunt = createXenoGrunt(health);
// deflectXenoGrunt.addComponent(new DeflectingComponent(
/**
* Creates a wizard that can deflect bullets
* @return Deflecting wizard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void setUp() {
resourceService.loadTextureAtlases(atlas);
resourceService.loadAll();

WaveService waveService = new WaveService();
WaveService waveService = mock(WaveService.class);
ServiceLocator.registerWaveService(waveService);

GameEndService gameEndService = new GameEndService();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ void testLevel1Creation() {
if (waveNum != 5) {
Set<String> mobNames = new HashSet<>(wave.getEntities().keySet());
Set<String> expectedMobNames = new HashSet<>(LVL1_WAVES_STRUC.get(waveNum - 1));
assertTrue(mobNames.equals(expectedMobNames), "The mobs in the wave should be " + expectedMobNames + " .");
assertEquals(mobNames, expectedMobNames, "The mobs in the wave should be " + expectedMobNames + " .");

for (String key: wave.getEntities().keySet()) {
int[] values = wave.getEntities().get(key);
Expand All @@ -164,16 +164,16 @@ void testLevel1Creation() {
mobsRemaining --;

if (MELEE_MOBS.contains(key)) {
assertTrue(values[1] == MIN_MELEE_HEALTH + waveNum, "The health of the mob should be " + MIN_MELEE_HEALTH + waveNum + " .");
assertEquals(values[1], MIN_MELEE_HEALTH + waveNum, "The health of the mob should be " + MIN_MELEE_HEALTH + waveNum + " .");
} else {
assertTrue(values[1] == MIN_RANGE_HEALTH + waveNum, "The health of the mob should be " + MIN_RANGE_HEALTH + waveNum + " .");
assertEquals(values[1], MIN_RANGE_HEALTH + waveNum, "The health of the mob should be " + MIN_RANGE_HEALTH + waveNum + " .");
}
}
} else {
assertTrue(wave.getEntities().keySet().size() == 1);
assertEquals(wave.getEntities().keySet().size(), 1);
for (String key: wave.getEntities().keySet()) {
int[] values = wave.getEntities().get(key);
assertTrue(values[1] == bossHealth, "The health of the boss should be " + MIN_BOSS_HEALTH);
assertEquals(values[1], bossHealth, "The health of the boss should be " + MIN_BOSS_HEALTH);
}
}
mobCount ++;
Expand Down Expand Up @@ -207,7 +207,7 @@ void testLevel2Creation() {
if (waveNum != 10) {
Set<String> mobNames = new HashSet<>(wave.getEntities().keySet());
Set<String> expectedMobNames = new HashSet<>(LVL2_WAVES_STRUC.get(waveNum - 1));
assertTrue(mobNames.equals(expectedMobNames), "The mobs in the wave should be " + expectedMobNames + " .");
assertEquals(mobNames, expectedMobNames, "The mobs in the wave should be " + expectedMobNames + " .");

for (String key: wave.getEntities().keySet()) {
int[] values = wave.getEntities().get(key);
Expand All @@ -231,7 +231,7 @@ void testLevel2Creation() {
assertTrue(wave.getEntities().keySet().size() == 1);
for (String key: wave.getEntities().keySet()) {
int[] values = wave.getEntities().get(key);
assertTrue(values[1] == bossHealth, "The health of the boss should be " + MIN_BOSS_HEALTH);
assertEquals(values[1], bossHealth, "The health of the boss should be " + MIN_BOSS_HEALTH);
}
}
mobCount ++;
Expand Down Expand Up @@ -266,7 +266,7 @@ void testLevel3Creation() {
if (waveNum != 15) {
Set<String> mobNames = new HashSet<>(wave.getEntities().keySet());
Set<String> expectedMobNames = new HashSet<>(LVL3_WAVES_STRUC.get(waveNum - 1));
assertTrue(mobNames.equals(expectedMobNames), "The mobs in the wave should be " + expectedMobNames + " .");
assertEquals(mobNames, expectedMobNames, "The mobs in the wave should be " + expectedMobNames + " .");

for (String key: wave.getEntities().keySet()) {
int[] values = wave.getEntities().get(key);
Expand All @@ -283,10 +283,10 @@ void testLevel3Creation() {
}

} else {
assertTrue(wave.getEntities().keySet().size() == 1);
assertEquals(wave.getEntities().keySet().size(), 1);
for (String key: wave.getEntities().keySet()) {
int[] values = wave.getEntities().get(key);
assertTrue(values[1] == bossHealth, "The health of the boss should be " + MIN_BOSS_HEALTH);
assertEquals(values[1], bossHealth, "The health of the boss should be " + MIN_BOSS_HEALTH);
}
}
mobCount ++;
Expand Down

0 comments on commit 869ac9d

Please sign in to comment.