diff --git a/source/core/assets/kenney-rpg-expansion/kenneyrpg.json b/source/core/assets/kenney-rpg-expansion/kenneyrpg.json index 427f3991d..6cc9cfdf3 100644 --- a/source/core/assets/kenney-rpg-expansion/kenneyrpg.json +++ b/source/core/assets/kenney-rpg-expansion/kenneyrpg.json @@ -35,7 +35,7 @@ "scaledSize": 18, "markupEnabled": false, "flip": false - } + }, "pixel_art": { "file": "mago3.fnt", "scaledSize": 18, @@ -131,7 +131,7 @@ }, "thin_black": { "font": "thin_black" - } + }, "pixel_art" : { "font" : "pixel_art" } diff --git a/source/core/assets/levels/blazes_refuge/main_area/entities/circle.json b/source/core/assets/levels/blazes_refuge/main_area/entities/circle.json index d6df1d911..7d5b59075 100644 --- a/source/core/assets/levels/blazes_refuge/main_area/entities/circle.json +++ b/source/core/assets/levels/blazes_refuge/main_area/entities/circle.json @@ -2,7 +2,7 @@ "entityType": "CircleConfig", "entities": [ { - class: com.csse3200.game.entities.configs.CircleConfig, + "class": "com.csse3200.game.entities.configs.CircleConfig", "spritePath": "images/npc/circle.png", "position" : { "x": 28, diff --git a/source/core/assets/levels/cryoheim/main_area/entities/fissures.json b/source/core/assets/levels/cryoheim/main_area/entities/fissures.json index c0aefb53b..81ac5a820 100644 --- a/source/core/assets/levels/cryoheim/main_area/entities/fissures.json +++ b/source/core/assets/levels/cryoheim/main_area/entities/fissures.json @@ -2,7 +2,7 @@ "entityType": "FissureConfig", "entities": [ { - class: com.csse3200.game.entities.configs.FissureConfig, + "class": "com.csse3200.game.entities.configs.FissureConfig", "resource": "Solstite", "position": { "x": 77, @@ -10,7 +10,7 @@ } }, { - class: com.csse3200.game.entities.configs.FissureConfig, + "class": "com.csse3200.game.entities.configs.FissureConfig", "resource": "Nebulite", "position": { "x": 59, @@ -18,7 +18,7 @@ } }, { - class: com.csse3200.game.entities.configs.FissureConfig, + "class": "com.csse3200.game.entities.configs.FissureConfig", "resource": "Durasteel", "position": { "x": 19, diff --git a/source/core/assets/levels/earth/main_area/entities/astro.json b/source/core/assets/levels/earth/main_area/entities/astro.json index 701e40f9a..bb8f0b4d0 100644 --- a/source/core/assets/levels/earth/main_area/entities/astro.json +++ b/source/core/assets/levels/earth/main_area/entities/astro.json @@ -2,7 +2,7 @@ "entityType": "AstroConfig", "entities": [ { - class: com.csse3200.game.entities.configs.AstroConfig, + "class": "com.csse3200.game.entities.configs.AstroConfig", "spritePath": "images/npc/caged_NPC.atlas", "position" : { "x": 24, diff --git a/source/core/assets/levels/earth/main_area/entities/portals.json b/source/core/assets/levels/earth/main_area/entities/portals.json index 567c88018..25dc8f000 100644 --- a/source/core/assets/levels/earth/main_area/entities/portals.json +++ b/source/core/assets/levels/earth/main_area/entities/portals.json @@ -11,7 +11,7 @@ } }, { - "class": com.csse3200.game.entities.configs.PortalConfig, + "class": "com.csse3200.game.entities.configs.PortalConfig", "teleportX" : 16, "teleportY" : 20, "position": { diff --git a/source/core/assets/levels/flora_haven/main_area/entities/fissures.json b/source/core/assets/levels/flora_haven/main_area/entities/fissures.json index 2a85a371b..d85826241 100644 --- a/source/core/assets/levels/flora_haven/main_area/entities/fissures.json +++ b/source/core/assets/levels/flora_haven/main_area/entities/fissures.json @@ -2,7 +2,7 @@ "entityType": "FissureConfig", "entities": [ { - class: com.csse3200.game.entities.configs.FissureConfig, + "class": "com.csse3200.game.entities.configs.FissureConfig", "resource": "Solstite", "position": { "x": 76, @@ -10,7 +10,7 @@ } }, { - class: com.csse3200.game.entities.configs.FissureConfig, + "class": "com.csse3200.game.entities.configs.FissureConfig", "resource": "Nebulite", "position": { "x": 66, @@ -18,7 +18,7 @@ } }, { - class: com.csse3200.game.entities.configs.FissureConfig, + "class": "com.csse3200.game.entities.configs.FissureConfig", "resource": "Durasteel", "position": { "x": 12, diff --git a/source/core/src/main/com/csse3200/game/areas/SpaceGameArea.java b/source/core/src/main/com/csse3200/game/areas/SpaceGameArea.java index 6193550e7..29f75e78a 100644 --- a/source/core/src/main/com/csse3200/game/areas/SpaceGameArea.java +++ b/source/core/src/main/com/csse3200/game/areas/SpaceGameArea.java @@ -34,6 +34,9 @@ public class SpaceGameArea extends GameArea { private static final int NUM_ASTEROIDS = 100; private TerrainFactory terrainFactory; private ArrayList targetTables; + private Random random; + int randomX, randomY; + private Vector2 goalPosition; /** * Constructor for initializing terrain area @@ -144,17 +147,15 @@ private void spawnAsteroids() { * Method for placing the exit point from the obstacle minigame */ public Entity spawnGoal() { - Random random = new Random(); - int randomX, randomY; - GridPoint2 position; + random = new Random(); // Continue generating random positions until an unoccupied position is found. do { randomX = random.nextInt(terrain.getMapBounds(0).x); randomY = random.nextInt(terrain.getMapBounds(0).y); - position = new GridPoint2(randomX, randomY); - } while (isPositionOccupied(position)); + goalPosition = new Vector2((float) randomX, (float) randomY); + } while (isPositionOccupied(goalPosition)); Entity newGoal = MinigameObjectFactory.createObstacleGameGoal(WORMHOLE_SIZE, WORMHOLE_SIZE); - spawnEntityAt(newGoal, position, false, false); + spawnEntityAtVector(newGoal, goalPosition); goal = newGoal; return goal; } @@ -162,9 +163,10 @@ public Entity spawnGoal() { /** * Check if a position is occupied by an entity. */ - public boolean isPositionOccupied(GridPoint2 position) { + public boolean isPositionOccupied(Vector2 position) { // Loop through the list of existing entities and check if any entity occupies the given position. for (Entity entity : targetTables) { + //GridPoint2 and Vector2 is unrelated if (entity != null && entity.getPosition().equals(position)) { return true; // Position is occupied. } diff --git a/source/core/src/main/com/csse3200/game/areas/map_config/MiniGameAssetsConfig.java b/source/core/src/main/com/csse3200/game/areas/map_config/MiniGameAssetsConfig.java index 0f31b5b91..25fb92ad9 100644 --- a/source/core/src/main/com/csse3200/game/areas/map_config/MiniGameAssetsConfig.java +++ b/source/core/src/main/com/csse3200/game/areas/map_config/MiniGameAssetsConfig.java @@ -13,6 +13,7 @@ public class MiniGameAssetsConfig { public String[] textureAtlasPaths = null; public String[] backgroundMusicPath = null; + @Override public boolean equals(Object o) { if (this == o) return true; @@ -28,6 +29,8 @@ public boolean equals(Object o) { return Objects.equals(backgroundMusicPath, that.backgroundMusicPath); } + /* + Arrays problem, will fix later, currently assume there is no need for hashcode. @Override public int hashCode() { int result = Arrays.hashCode(texturePaths); @@ -35,6 +38,7 @@ public int hashCode() { result = 31 * result + (backgroundMusicPath != null ? backgroundMusicPath.hashCode() : 0); return result; } + */ /** * Loads all assets contained within this config class diff --git a/source/core/src/main/com/csse3200/game/entities/factories/CompanionFactory.java b/source/core/src/main/com/csse3200/game/entities/factories/CompanionFactory.java index 9c48107f2..aaf4ec862 100644 --- a/source/core/src/main/com/csse3200/game/entities/factories/CompanionFactory.java +++ b/source/core/src/main/com/csse3200/game/entities/factories/CompanionFactory.java @@ -72,7 +72,8 @@ public static Entity createCompanion(CompanionConfig config) { .addComponent(new CompanionActions()) .addComponent(new CombatStatsComponent(config.health, config.maxHealth, config.baseAttack, config.attackMultiplier, config.isImmune)) - .addComponent(new CompanionInventoryComponent()) + //.addComponent(new CompanionInventoryComponent()) remove later if confirmed useless + //cannot add multiple copies of the same component, since already added as seen below .addComponent(inputComponent) .addComponent(animator) .addComponent(new CompanionWeaponComponent()) diff --git a/source/core/src/test/com/csse3200/game/areas/SpaceGameAreaTest.java b/source/core/src/test/com/csse3200/game/areas/SpaceGameAreaTest.java index 2f494f26c..37cc65f54 100644 --- a/source/core/src/test/com/csse3200/game/areas/SpaceGameAreaTest.java +++ b/source/core/src/test/com/csse3200/game/areas/SpaceGameAreaTest.java @@ -46,22 +46,13 @@ public void testCalculateDistanceWithNonZeroDistance() { } @Test public void testIsPositionOccupied() { - SpaceGameArea spaceGameArea = mock(SpaceGameArea.class); - - - - // Define an unoccupied position - GridPoint2 unoccupiedPosition = new GridPoint2(1, 1); - - + Vector2 unoccupiedPosition = new Vector2(1f, 1f); when(spaceGameArea.isPositionOccupied(unoccupiedPosition)).thenReturn(false); assertFalse(spaceGameArea.isPositionOccupied(unoccupiedPosition)); - // Define an occupied position - GridPoint2 occupiedPosition = new GridPoint2(2, 2); - + Vector2 occupiedPosition = new Vector2(2f, 2f); when(spaceGameArea.isPositionOccupied(occupiedPosition)).thenReturn(true); assertTrue(spaceGameArea.isPositionOccupied(occupiedPosition)); }