From 50ab0d7d63237fe01213eda0dc9a9dd47b3128a5 Mon Sep 17 00:00:00 2001 From: Mohamad Date: Mon, 2 Oct 2023 02:26:26 +1000 Subject: [PATCH] fixed spawnAt bounderies --- .../csse3200/game/areas/ForestGameArea.java | 18 +++++++++--------- .../components/tasks/waves/LevelWaves.java | 2 +- 2 files changed, 10 insertions(+), 10 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 99ef6b1f7..da8a32674 100644 --- a/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java +++ b/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java @@ -527,7 +527,7 @@ private void spawnDeflectWizard(int x, int y) { private void spawnFireWorm() { - int[] pickedLanes = rand.ints(0, ServiceLocator.getMapService().getHeight() + 1) + int[] pickedLanes = rand.ints(0, ServiceLocator.getMapService().getHeight() ) .distinct().limit(5).toArray(); for (int i = 0; i < NUM_GRUNTS; i++) { @@ -540,7 +540,7 @@ private void spawnFireWorm() { private void spawnSkeleton() { - int[] pickedLanes = new Random().ints(0, ServiceLocator.getMapService().getHeight() + 1) + int[] pickedLanes = new Random().ints(0, ServiceLocator.getMapService().getHeight() ) .distinct().limit(5).toArray(); for (int i = 0; i < NUM_GRUNTS; i++) { GridPoint2 randomPos = new GridPoint2(19, pickedLanes[i]); @@ -552,7 +552,7 @@ private void spawnSkeleton() { private void spawnDragonKnight() { - int[] pickedLanes = rand.ints(0, ServiceLocator.getMapService().getHeight() + 1) + int[] pickedLanes = rand.ints(0, ServiceLocator.getMapService().getHeight() ) .distinct().limit(5).toArray(); for (int i = 0; i < NUM_GRUNTS; i++) { @@ -565,7 +565,7 @@ private void spawnDragonKnight() { private void spawnWizard() { - int[] pickedLanes = rand.ints(0, ServiceLocator.getMapService().getHeight() + 1) + int[] pickedLanes = rand.ints(0, ServiceLocator.getMapService().getHeight() ) .distinct().limit(5).toArray(); for (int i = 0; i < NUM_GRUNTS; i++) { @@ -578,7 +578,7 @@ private void spawnWizard() { private void spawnWaterQueen() { - int[] pickedLanes = new Random().ints(0, ServiceLocator.getMapService().getHeight() + 1) + int[] pickedLanes = new Random().ints(0, ServiceLocator.getMapService().getHeight() ) .distinct().limit(5).toArray(); for (int i = 0; i < NUM_GRUNTS; i++) { @@ -591,7 +591,7 @@ private void spawnWaterQueen() { private void spawnWaterSlime() { - int[] pickedLanes = new Random().ints(0, ServiceLocator.getMapService().getHeight() + 1) + int[] pickedLanes = new Random().ints(0, ServiceLocator.getMapService().getHeight() ) .distinct().limit(5).toArray(); for (int i = 0; i < NUM_GRUNTS; i++) { @@ -705,7 +705,7 @@ private void spawnWeaponTower() { GridPoint2 minPos = new GridPoint2(0, 0); GridPoint2 maxPos = terrain.getMapBounds(0).sub(5, 1); - for (int i = 0; i < NUM_WEAPON_TOWERS + 10 ; i++) { + for (int i = 0; i < NUM_WEAPON_TOWERS + 7 ; i++) { GridPoint2 randomPos1 = RandomUtils.random(minPos, maxPos); GridPoint2 randomPos2 = RandomUtils.random(minPos, maxPos); Entity wallTower = TowerFactory.createWallTower(); @@ -734,7 +734,7 @@ private void spawnTNTTower() { GridPoint2 minPos = new GridPoint2(0, 0); GridPoint2 maxPos = terrain.getMapBounds(0).sub(5, 1); - for (int i = 0; i < NUM_WEAPON_TOWERS + 15; i++) { + for (int i = 0; i < NUM_WEAPON_TOWERS + 5; i++) { GridPoint2 randomPos = RandomUtils.random(minPos, maxPos); Entity weaponTower = TowerFactory.createTNTTower(); spawnEntityAt(weaponTower, randomPos, true, true); @@ -746,7 +746,7 @@ private void spawnDroidTower() { GridPoint2 minPos = new GridPoint2(0, 0); GridPoint2 maxPos = terrain.getMapBounds(0).sub(5, 1); - for (int i = 0; i < NUM_WEAPON_TOWERS + 15; i++) { + for (int i = 0; i < NUM_WEAPON_TOWERS + 5; i++) { GridPoint2 randomPos = RandomUtils.random(minPos, maxPos); Entity weaponTower = TowerFactory.createDroidTower(); spawnEntityAt(weaponTower, randomPos, true, false); diff --git a/source/core/src/main/com/csse3200/game/components/tasks/waves/LevelWaves.java b/source/core/src/main/com/csse3200/game/components/tasks/waves/LevelWaves.java index 7ab167d9c..54010fb54 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/waves/LevelWaves.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/waves/LevelWaves.java @@ -65,7 +65,7 @@ public WaveClass getWave(int index) { public void spawnWave() { if (gameTime.getTime() >= startTime + spawnDelay * 1000) { do { - currentRandom = rand.nextInt(0, ServiceLocator.getMapService().getHeight() + 1); + currentRandom = rand.nextInt(0, ServiceLocator.getMapService().getHeight()); } while (currentRandom == previousRandom); ServiceLocator.getWaveService().setNextLane(currentRandom); GridPoint2 randomPos = new GridPoint2(19, currentRandom);