From 84f9eade07cc2c9e78315a6868abb0a176815643 Mon Sep 17 00:00:00 2001 From: BlairCannon97 Date: Tue, 17 Oct 2023 12:44:09 +1000 Subject: [PATCH 1/4] Reverted a change in MainGameScreen where a hostile mob would cause a game crash at the end of their lane --- .../main/com/csse3200/game/screens/MainGameScreen.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/source/core/src/main/com/csse3200/game/screens/MainGameScreen.java b/source/core/src/main/com/csse3200/game/screens/MainGameScreen.java index c1c1459d4..f11a4aa01 100644 --- a/source/core/src/main/com/csse3200/game/screens/MainGameScreen.java +++ b/source/core/src/main/com/csse3200/game/screens/MainGameScreen.java @@ -213,14 +213,11 @@ public void render(float delta) { ServiceLocator.getWaveService().getDisplay().updateMobCount(); renderer.render(); - // Check if the game has ended // Check if the game has ended if (ServiceLocator.getGameEndService().hasGameEnded()) { ui.getEvents().trigger("lose"); - } - - // Check if all waves are completed and the level has been completed - if (ServiceLocator.getWaveService().isLevelCompleted()) { + } else if (ServiceLocator.getWaveService().isLevelCompleted()) { + // Check if all waves are completed and the level has been completed if (selectedLevel == 2) { // Lava level // If it's the lava level, go to the "win" screen ui.getEvents().trigger("win"); @@ -232,7 +229,6 @@ public void render(float delta) { } } } - // Add something in to unlock the next planet/level? @Override public void resize(int width, int height) { From efa53ee3b0a7c34c257e82c9e054e8b6d28a09b8 Mon Sep 17 00:00:00 2001 From: Deven Bhasin Date: Tue, 17 Oct 2023 12:52:30 +1000 Subject: [PATCH 2/4] Removed the unused tower variable --- .../core/src/main/com/csse3200/game/areas/ForestGameArea.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java b/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java index 26c3f3ee1..30ada73cc 100644 --- a/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java +++ b/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java @@ -22,8 +22,6 @@ public class ForestGameArea extends GameArea { private static final Logger logger = LoggerFactory.getLogger(ForestGameArea.class); private Timer waveTimer; - - private static final int NUM_WEAPON_TOWERS = 3; private static final GridPoint2 PLAYER_SPAWN = new GridPoint2(2, 4); // Temporary spawn point for testing private static final float WALL_WIDTH = 0.1f; From 7213c3ae56874726db59d06e6059d12f9ef97f38 Mon Sep 17 00:00:00 2001 From: Deven Bhasin Date: Tue, 17 Oct 2023 12:56:51 +1000 Subject: [PATCH 3/4] cleaned up tower tasks --- .../components/tasks/FireTowerCombatTask.java | 25 ------------------- .../components/tasks/StunTowerCombatTask.java | 16 ------------ 2 files changed, 41 deletions(-) diff --git a/source/core/src/main/com/csse3200/game/components/tasks/FireTowerCombatTask.java b/source/core/src/main/com/csse3200/game/components/tasks/FireTowerCombatTask.java index 7e4cb7a3b..68a93d935 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/FireTowerCombatTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/FireTowerCombatTask.java @@ -132,22 +132,6 @@ public int getPriority() { return !isTargetVisible() ? 0 : priority; } - /** - * not currently used. - * @return the priority for this task - */ - public int getActivePriority() { - return !isTargetVisible() ? 0 : priority; - } - - /** - * not currently used. - * @return - */ - public int getInactivePriority() { - return isTargetVisible() ? priority : 0; - } - /** * detects targets from the centre of the tower to maxRange in a straight line. * @return true if mobs are present and false otherwise. @@ -160,15 +144,6 @@ private void changeFireRateInterval(int newInterval) { fireRateInterval = 1 / ((float) newInterval / 5); } - /** - * Function for getting the turret's fire rate. - * - * @return The fireRateInterval variable - */ - public float getFireRateInterval() { - return fireRateInterval; - } - /** * Function for getting the tower's state. * diff --git a/source/core/src/main/com/csse3200/game/components/tasks/StunTowerCombatTask.java b/source/core/src/main/com/csse3200/game/components/tasks/StunTowerCombatTask.java index 03abc3552..d708de81e 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/StunTowerCombatTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/StunTowerCombatTask.java @@ -175,14 +175,6 @@ public int getPriority() { return !isTargetVisible() ? 0 : priority; } - public int getActivePriority() { - return !isTargetVisible() ? 0 : priority; - } - - public int getInactivePriority() { - return isTargetVisible() ? priority : 0; - } - /** * Searches for enemies/mobs in a straight line from the centre of the tower to maxRange in a straight line. * @return true if targets are detected, false otherwise @@ -195,12 +187,4 @@ private void changeFireRateInterval(int newInterval) { fireRateInterval = 1 / ((float) newInterval / 5); } - /** - * Function for getting the turret's fire rate. - * - * @return The fireRateInterval variable - */ - public float getFireRateInterval() { - return fireRateInterval; - } } From c1d8bc414b439c1e2127090ae16ca90195f09bed Mon Sep 17 00:00:00 2001 From: Deven Bhasin Date: Tue, 17 Oct 2023 12:58:10 +1000 Subject: [PATCH 4/4] cleaned up tower factory --- .../game/entities/factories/TowerFactory.java | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/source/core/src/main/com/csse3200/game/entities/factories/TowerFactory.java b/source/core/src/main/com/csse3200/game/entities/factories/TowerFactory.java index 9f5f3bac3..386f470d4 100644 --- a/source/core/src/main/com/csse3200/game/entities/factories/TowerFactory.java +++ b/source/core/src/main/com/csse3200/game/entities/factories/TowerFactory.java @@ -34,10 +34,6 @@ * the properties stores in 'BaseTowerConfigs'. */ public class TowerFactory { - private static final Logger logger = LoggerFactory.getLogger(TowerFactory.class); - - // Define a set to keep track of occupied lanes - private static final Set occupiedLanes = new HashSet<>(); private static final int COMBAT_TASK_PRIORITY = 2; private static final int WEAPON_TOWER_MAX_RANGE = 40; private static final int TNT_TOWER_MAX_RANGE = 6; @@ -466,28 +462,4 @@ public static Entity createBaseTower() { tower.getComponent(ColliderComponent.class).setAsBoxAligned(new Vector2(1f, 1f), PhysicsComponent.AlignX.CENTER, PhysicsComponent.AlignY.CENTER); return tower; } - - public static Entity createAndPlaceTower(int lane) { - if (isLaneOccupied(lane)) { - logger.info(String.format("Lane %d is already occupied by a tower", lane)); - return null; - } - - Entity tower = createBaseTower(); - // Customize the tower creation here based on the chosen tower type - - // Add the lane to the set of occupied lanes - occupiedLanes.add(lane); - - return tower; - } - - /** - * Checks if a lane is already occupied by a tower. - * @param lane The lane to check. - * @return True if the lane is occupied, false otherwise. - */ - public static boolean isLaneOccupied(int lane) { - return occupiedLanes.contains(lane); - } } \ No newline at end of file