From e8657d1c19bbb19d2b58455380843f8a0c2411d3 Mon Sep 17 00:00:00 2001 From: praneetdhoolia Date: Thu, 7 Sep 2023 14:38:24 +1000 Subject: [PATCH 1/9] stash --- .../src/main/com/csse3200/game/areas/ForestGameArea.java | 6 +++--- 1 file changed, 3 insertions(+), 3 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 335049762..2effe531a 100644 --- a/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java +++ b/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java @@ -141,7 +141,7 @@ public void create() { // Spawn Entities player = spawnPlayer(); spawnWeaponTower(); - spawnEngineer(); + spawnEngineer(player); bossKing1 = spawnBossKing1(); bossKing2 = spawnBossKing2(); } @@ -446,12 +446,12 @@ private void spawnIncome() { } } - private void spawnEngineer() { + private void spawnEngineer(Entity target) { GridPoint2 minPos = new GridPoint2(0, 0); GridPoint2 maxPos = terrain.getMapBounds(0).sub(2, 2); GridPoint2 randomPos = RandomUtils.random(minPos, maxPos); - Entity engineer = EngineerFactory.createEngineer(); + Entity engineer = EngineerFactory.createEngineer(target); spawnEntityAt(engineer, randomPos, true, true); } From 44686b973b13a57240aac52d0da3c717181cdfaa Mon Sep 17 00:00:00 2001 From: praneetdhoolia Date: Thu, 7 Sep 2023 14:38:24 +1000 Subject: [PATCH 2/9] Resolved branch updating issue. --- .../src/main/com/csse3200/game/areas/ForestGameArea.java | 6 +++--- 1 file changed, 3 insertions(+), 3 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 335049762..2effe531a 100644 --- a/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java +++ b/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java @@ -141,7 +141,7 @@ public void create() { // Spawn Entities player = spawnPlayer(); spawnWeaponTower(); - spawnEngineer(); + spawnEngineer(player); bossKing1 = spawnBossKing1(); bossKing2 = spawnBossKing2(); } @@ -446,12 +446,12 @@ private void spawnIncome() { } } - private void spawnEngineer() { + private void spawnEngineer(Entity target) { GridPoint2 minPos = new GridPoint2(0, 0); GridPoint2 maxPos = terrain.getMapBounds(0).sub(2, 2); GridPoint2 randomPos = RandomUtils.random(minPos, maxPos); - Entity engineer = EngineerFactory.createEngineer(); + Entity engineer = EngineerFactory.createEngineer(target); spawnEntityAt(engineer, randomPos, true, true); } From e242bc230d7fc1efe274fa12551537588085d206 Mon Sep 17 00:00:00 2001 From: praneetdhoolia Date: Fri, 8 Sep 2023 13:58:03 +1000 Subject: [PATCH 3/9] Fixed updating bugs. --- .../csse3200/game/areas/ForestGameArea.java | 32 +++++-------- .../entities/factories/EngineerFactory.java | 46 ++++++++----------- 2 files changed, 31 insertions(+), 47 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 01fff275a..0a3946ff9 100644 --- a/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java +++ b/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java @@ -163,7 +163,7 @@ public void create() { spawnGhosts(); spawnWeaponTower(); - spawnEngineer(player); + spawnEngineer(); bossKing1 = spawnBossKing1(); bossKing2 = spawnBossKing2(); spawnTNTTower(); @@ -265,7 +265,7 @@ private void spawnGhosts() { private Entity spawnBossKing1() { GridPoint2 minPos = new GridPoint2(0, 0); GridPoint2 maxPos = terrain.getMapBounds(0).sub(2, 2); - GridPoint2 randomPos + GridPoint2 randomPos = new GridPoint2(0, 0); Entity ghostKing = NPCFactory.createGhostKing(player); spawnEntityAt(ghostKing, randomPos, true, true); @@ -274,12 +274,12 @@ private Entity spawnBossKing1() { /** * Spawns a projectile that only heads towards the enemies in its lane. - * + * * @param position The position of the Entity that's shooting the projectile. * @param targetLayer The enemy layer of the "shooter". * @param direction The direction the projectile should head towards. * @param speed The speed of the projectiles. - * + * */ private void spawnProjectile(Vector2 position, short targetLayer, int direction, Vector2 speed) { Entity Projectile = ProjectileFactory.createFireBall(targetLayer, new Vector2(direction, position.y), speed); @@ -288,12 +288,12 @@ private void spawnProjectile(Vector2 position, short targetLayer, int direction, } /** * Spawns a projectile specifically for general mobs/xenohunters - * + * * @param position The position of the Entity that's shooting the projectile. * @param targetLayer The enemy layer of the "shooter". * @param direction The direction the projectile should head towards. * @param speed The speed of the projectiles. - * + * */ private void spawnMobBall(Vector2 position, short targetLayer, int direction, Vector2 speed) { Entity Projectile = ProjectileFactory.createMobBall(targetLayer, new Vector2(direction, position.y), speed); @@ -303,13 +303,13 @@ private void spawnMobBall(Vector2 position, short targetLayer, int direction, Ve /** * Spawns a projectile to be used for multiple projectile function. - * + * * @param position The position of the Entity that's shooting the projectile. * @param targetLayer The enemy layer of the "shooter". * @param space The space between the projectiles' destination. * @param direction The direction the projectile should head towards. * @param speed The speed of the projectiles. - * + * */ private void spawnProjectile(Vector2 position, short targetLayer, int space, int direction, Vector2 speed) { Entity Projectile = ProjectileFactory.createFireBall(targetLayer, new Vector2(direction, position.y + space), speed); @@ -375,9 +375,9 @@ private Entity spawnBossKing2() { } /** - * Creates multiple projectiles that travel simultaneous. They all have same + * Creates multiple projectiles that travel simultaneous. They all have same * the starting point but different destinations. - * + * * @param position The position of the Entity that's shooting the projectile. * @param targetLayer The enemy layer of the "shooter". * @param direction The direction the projectile should head towards. @@ -395,7 +395,7 @@ private void spawnMultiProjectile(Vector2 position, short targetLayer, int direc /** * Returns projectile that can do an area of effect damage - * + * * @param position The position of the Entity that's shooting the projectile. * @param targetLayer The enemy layer of the "shooter". * @param direction The direction the projectile should head towards. @@ -495,15 +495,6 @@ private void spawnIncome() { } } -<<<<<<< HEAD - private void spawnEngineer(Entity target) { - GridPoint2 minPos = new GridPoint2(0, 0); - GridPoint2 maxPos = terrain.getMapBounds(0).sub(2, 2); - GridPoint2 randomPos = RandomUtils.random(minPos, maxPos); - - Entity engineer = EngineerFactory.createEngineer(target); - spawnEntityAt(engineer, randomPos, true, true); -======= private void spawnEngineer() { for (int i = 0; i < terrain.getMapBounds(0).x; i += 3) { @@ -516,6 +507,5 @@ private void spawnEngineer() { // // Entity engineer = EngineerFactory.createEngineer(); // spawnEntityAt(engineer, randomPos, true, true); ->>>>>>> b2d74629c8d3e8a1164ef90a433ff06e126011d2 } } \ No newline at end of file diff --git a/source/core/src/main/com/csse3200/game/entities/factories/EngineerFactory.java b/source/core/src/main/com/csse3200/game/entities/factories/EngineerFactory.java index 9eff38843..7bdd6396a 100644 --- a/source/core/src/main/com/csse3200/game/entities/factories/EngineerFactory.java +++ b/source/core/src/main/com/csse3200/game/entities/factories/EngineerFactory.java @@ -35,11 +35,11 @@ public class EngineerFactory { private static final int COMBAT_TASK_PRIORITY = 2; private static final int ENGINEER_RANGE = 10; private static final EngineerConfigs configs = - FileLoader.readClass(EngineerConfigs.class, "configs/Engineers.json"); - + FileLoader.readClass(EngineerConfigs.class, "configs/Engineers.json"); + private static final float HUMAN_SCALE_X = 1f; private static final float HUMAN_SCALE_Y = 0.8f; - + /** * Creates an Engineer entity, based on a base Human entity, with the appropriate components and animations * @@ -49,7 +49,7 @@ public class EngineerFactory { public static Entity createEngineer() { Entity engineer = createBaseHumanNPC(); BaseEntityConfig config = configs.engineer; - + AnimationRenderComponent animator = new AnimationRenderComponent( new TextureAtlas("images/engineers/engineer.atlas")); animator.addAnimation("walk_left", 0.2f, Animation.PlayMode.LOOP); @@ -61,49 +61,43 @@ public static Entity createEngineer() { animator.addAnimation("prep", 0.05f, Animation.PlayMode.NORMAL); animator.addAnimation("hit", 0.01f, Animation.PlayMode.NORMAL); animator.addAnimation("death", 0.1f, Animation.PlayMode.NORMAL); - + AITaskComponent aiComponent = new AITaskComponent(); - + engineer .addComponent(new CombatStatsComponent(config.health, config.baseAttack)) .addComponent(animator) .addComponent(new HumanAnimationController()) .addComponent(aiComponent); - + engineer.getComponent(AITaskComponent.class).addTask(new HumanWanderTask(COMBAT_TASK_PRIORITY, ENGINEER_RANGE)); engineer.getComponent(AnimationRenderComponent.class).scaleEntity(); - engineer.getComponent(AITaskComponent.class) - .addTask(new EngineerCombatTask(COMBAT_TASK_PRIORITY, ENGINEER_RANGE)); - engineer.setScale(1.5f, 1.2f); engineer.setScale(HUMAN_SCALE_X, HUMAN_SCALE_Y); return engineer; } - + /** * Creates a generic human npc to be used as a base entity by more specific NPC creation methods. * * @return entity */ - public static Entity createBaseHumanNPC(Entity target) { - AITaskComponent aiComponent = - new AITaskComponent() - .addTask(new HumanWanderTask(target, 1f)); public static Entity createBaseHumanNPC() { - + + Entity human = - new Entity() - .addComponent(new PhysicsComponent()) - .addComponent(new PhysicsMovementComponent()) - .addComponent(new ColliderComponent()) - .addComponent(new HitboxComponent().setLayer(PhysicsLayer.ENGINEER)) - .addComponent(new TouchAttackComponent(PhysicsLayer.NPC, 1.5f)); - - + new Entity() + .addComponent(new PhysicsComponent()) + .addComponent(new PhysicsMovementComponent()) + .addComponent(new ColliderComponent()) + .addComponent(new HitboxComponent().setLayer(PhysicsLayer.ENGINEER)) + .addComponent(new TouchAttackComponent(PhysicsLayer.NPC, 1.5f)); + + PhysicsUtils.setScaledCollider(human, 0.9f, 0.4f); return human; } - + private EngineerFactory() { throw new IllegalStateException("Instantiating static util class"); } -} +} \ No newline at end of file From 58ceeb8594c685e5125989d6265ec22b8ed6dab4 Mon Sep 17 00:00:00 2001 From: praneetdhoolia Date: Mon, 11 Sep 2023 01:33:10 +1000 Subject: [PATCH 4/9] Added EngineerCombatTaskTest --- .../csse3200/game/components/tasks/EngineerCombatTaskTest.java | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 source/core/src/test/com/csse3200/game/components/tasks/EngineerCombatTaskTest.java diff --git a/source/core/src/test/com/csse3200/game/components/tasks/EngineerCombatTaskTest.java b/source/core/src/test/com/csse3200/game/components/tasks/EngineerCombatTaskTest.java new file mode 100644 index 000000000..e890470ca --- /dev/null +++ b/source/core/src/test/com/csse3200/game/components/tasks/EngineerCombatTaskTest.java @@ -0,0 +1,2 @@ +package com.csse3200.game.components.tasks;public class EngineerCombatTaskTest { +} From 32725aa01a2024754df4adec3e1afa99495b2095 Mon Sep 17 00:00:00 2001 From: praneetdhoolia Date: Mon, 11 Sep 2023 02:50:00 +1000 Subject: [PATCH 5/9] Removed extra code from EngineerCombatTask. --- .../components/tasks/human/EngineerCombatTask.java | 13 +------------ .../components/tasks/EngineerCombatTaskTest.java | 3 ++- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/source/core/src/main/com/csse3200/game/components/tasks/human/EngineerCombatTask.java b/source/core/src/main/com/csse3200/game/components/tasks/human/EngineerCombatTask.java index 23dbea9c0..34b0b1157 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/human/EngineerCombatTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/human/EngineerCombatTask.java @@ -26,8 +26,6 @@ public class EngineerCombatTask extends DefaultTask implements PriorityTask { private static final short TARGET = PhysicsLayer.NPC; // The type of targets that the Engineer will detect. // Animation event names for the Engineer's state machine. - private static final String STOW = ""; - private static final String DEPLOY = ""; private static final String FIRING = "firingSingleStart"; private static final String IDLE_LEFT = "idleLeft"; private static final String IDLE_RIGHT = "idleRight"; @@ -96,7 +94,7 @@ public void update() { * Engineer state machine */ public void updateEngineerState() { - // configure tower state depending on target visibility + // configure engineer state depending on target visibility switch (engineerState) { case IDLE_LEFT -> { // targets detected in idle mode - start deployment @@ -113,15 +111,6 @@ public void updateEngineerState() { combatState(); } } - case DEPLOY -> { - // currently deploying, - if (isTargetVisible()) { - combatState(); - } else { - owner.getEntity().getEvents().trigger(STOW); - engineerState = STATE.STOW; - } - } case FIRING -> { // targets gone - stop firing if (!isTargetVisible()) { diff --git a/source/core/src/test/com/csse3200/game/components/tasks/EngineerCombatTaskTest.java b/source/core/src/test/com/csse3200/game/components/tasks/EngineerCombatTaskTest.java index e890470ca..94d4b9f7c 100644 --- a/source/core/src/test/com/csse3200/game/components/tasks/EngineerCombatTaskTest.java +++ b/source/core/src/test/com/csse3200/game/components/tasks/EngineerCombatTaskTest.java @@ -1,2 +1,3 @@ -package com.csse3200.game.components.tasks;public class EngineerCombatTaskTest { +package com.csse3200.game.components.tasks; +public class EngineerCombatTaskTest { } From bbd5cef43c9a8cf3ef2870b95ac5575d1d8a33ce Mon Sep 17 00:00:00 2001 From: praneetdhoolia Date: Mon, 11 Sep 2023 02:58:08 +1000 Subject: [PATCH 6/9] Cleaned up code smells. --- .../components/tasks/human/EngineerCombatTask.java | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/source/core/src/main/com/csse3200/game/components/tasks/human/EngineerCombatTask.java b/source/core/src/main/com/csse3200/game/components/tasks/human/EngineerCombatTask.java index 34b0b1157..428b21f40 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/human/EngineerCombatTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/human/EngineerCombatTask.java @@ -27,9 +27,7 @@ public class EngineerCombatTask extends DefaultTask implements PriorityTask { // Animation event names for the Engineer's state machine. private static final String FIRING = "firingSingleStart"; - private static final String IDLE_LEFT = "idleLeft"; private static final String IDLE_RIGHT = "idleRight"; - private static final String DYING = "deathStart"; // The Engineer's attributes. private final float maxRange; // The maximum range of the Engineer's weapon. @@ -50,7 +48,7 @@ public class EngineerCombatTask extends DefaultTask implements PriorityTask { /** The Engineer's states. */ private enum STATE { - IDLE_LEFT, IDLE_RIGHT, DEPLOY, FIRING, STOW + IDLE_RIGHT, FIRING } private STATE engineerState = STATE.IDLE_RIGHT; @@ -96,15 +94,6 @@ public void update() { public void updateEngineerState() { // configure engineer state depending on target visibility switch (engineerState) { - case IDLE_LEFT -> { - // targets detected in idle mode - start deployment - if (isTargetVisible()) { - owner.getEntity().getEvents().trigger(FIRING); - engineerState = STATE.FIRING; - } else { - - } - } case IDLE_RIGHT -> { // targets detected in idle mode - start deployment if (isTargetVisible()) { From a56cc165a0eba397fc2208f393a34e36a3ba9bda Mon Sep 17 00:00:00 2001 From: praneetdhoolia Date: Mon, 11 Sep 2023 03:00:12 +1000 Subject: [PATCH 7/9] Optimized code further. --- .../game/components/tasks/human/EngineerCombatTask.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/core/src/main/com/csse3200/game/components/tasks/human/EngineerCombatTask.java b/source/core/src/main/com/csse3200/game/components/tasks/human/EngineerCombatTask.java index 428b21f40..79600a12c 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/human/EngineerCombatTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/human/EngineerCombatTask.java @@ -106,7 +106,7 @@ public void updateEngineerState() { owner.getEntity().getEvents().trigger(IDLE_RIGHT); engineerState = STATE.IDLE_RIGHT; } else { - if (shotsFired <= 10) { + if (shotsFired <= weaponCapacity) { owner.getEntity().getEvents().trigger(FIRING); // this might be changed to an event which gets triggered everytime the tower enters the firing state Entity newProjectile = ProjectileFactory.createEngineerBullet(PhysicsLayer.NPC, @@ -115,7 +115,7 @@ public void updateEngineerState() { newProjectile.setScale(0.8f, 0.8f); newProjectile.setPosition((float) (owner.getEntity().getPosition().x + 0.3), (float) (owner.getEntity().getPosition().y + 0.15)); ServiceLocator.getEntityService().register(newProjectile); - shotsFired += 1; + shotsFired ++; reloadTime = timeSource.getTime(); } else { // engineer needs to reload From d9e8a15b962b1c9dc2c66bad07e338267f3787c8 Mon Sep 17 00:00:00 2001 From: praneetdhoolia Date: Mon, 11 Sep 2023 03:15:03 +1000 Subject: [PATCH 8/9] Optimized code further. --- .../game/components/tasks/human/EngineerCombatTask.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/core/src/main/com/csse3200/game/components/tasks/human/EngineerCombatTask.java b/source/core/src/main/com/csse3200/game/components/tasks/human/EngineerCombatTask.java index 79600a12c..c5b5aae48 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/human/EngineerCombatTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/human/EngineerCombatTask.java @@ -113,7 +113,8 @@ public void updateEngineerState() { new Vector2(100, owner.getEntity().getPosition().y), new Vector2(4f, 4f)); newProjectile.setScale(0.8f, 0.8f); - newProjectile.setPosition((float) (owner.getEntity().getPosition().x + 0.3), (float) (owner.getEntity().getPosition().y + 0.15)); + newProjectile.setPosition((float) (owner.getEntity().getPosition().x + 0.3), + (float) (owner.getEntity().getPosition().y + 0.15)); ServiceLocator.getEntityService().register(newProjectile); shotsFired ++; reloadTime = timeSource.getTime(); From 8904c8830ac2bf1cdf95252774c6f0b45612b3f1 Mon Sep 17 00:00:00 2001 From: praneetdhoolia Date: Tue, 12 Sep 2023 11:45:20 +1000 Subject: [PATCH 9/9] Resolved merge conflicts --- .../csse3200/game/areas/ForestGameArea.java | 162 +++++++----------- 1 file changed, 58 insertions(+), 104 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 c6799d01d..83b392814 100644 --- a/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java +++ b/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java @@ -34,15 +34,15 @@ public class ForestGameArea extends GameArea { private static final int NUM_GHOSTS = 0; private static final int NUM_GRUNTS = 5; private static final int NUM_BOSS = 4; - - + + private Timer bossSpawnTimer; private int bossSpawnInterval = 10000; // 1 minute in milliseconds private static final int NUM_WEAPON_TOWERS = 3; private static final GridPoint2 PLAYER_SPAWN = new GridPoint2(0, 0); // Temporary spawn point for testing private static final float WALL_WIDTH = 0.1f; - + // Required to load assets before using them private static final String[] forestTextures = { "images/ingamebg.png", @@ -142,17 +142,17 @@ public class ForestGameArea extends GameArea { }; private static final String backgroundMusic = "sounds/background/Sci-Fi1.ogg"; private static final String[] forestMusic = {backgroundMusic}; - + private final TerrainFactory terrainFactory; - + private Entity player; - + // Variables to be used with spawn projectile methods. This is the variable // that should occupy the direction param. private static final int towardsMobs = 100; private Entity bossKing2; - - + + /** * Initialise this ForestGameArea to use the provided TerrainFactory. * @@ -163,7 +163,7 @@ public ForestGameArea(TerrainFactory terrainFactory) { super(); this.terrainFactory = terrainFactory; } - + /** * Create the game area, including terrain, static entities (trees), dynamic entities (player) */ @@ -173,15 +173,16 @@ public void create() { loadAssets(); displayUI(); spawnTerrain(); +// spawnBuilding1(); +// spawnBuilding2(); +// spawnMountains(); - playMusic(); - - // Spawn Entities + // Set up infrastructure for end game tracking player = spawnPlayer(); player.getEvents().addListener("spawnWave", this::spawnXenoGrunts); - + playMusic(); - + // Types of projectile // spawnAoeProjectile(new Vector2(0, 10), player, towardsMobs, new Vector2(2f, 2f), 1); spawnProjectile(new Vector2(0, 10), PhysicsLayer.NPC, towardsMobs, new Vector2(2f, 2f)); @@ -202,10 +203,10 @@ public void create() { // spawnGapScanners(); // bossKing1 = spawnBossKing1(); // bossKing2 = spawnBossKing2(); - + bossKing2 = spawnBossKing2(); } - + private void displayUI() { Entity ui = new Entity(); ui.addComponent(new GameAreaDisplay("Box Forest")); @@ -213,17 +214,17 @@ private void displayUI() { ui.addComponent(ServiceLocator.getCurrencyService().getDisplay()); spawnEntity(ui); } - + private void spawnTerrain() { // Background terrain terrain = terrainFactory.createTerrain(TerrainType.FOREST_DEMO); spawnEntity(new Entity().addComponent(terrain)); - + // Terrain walls float tileSize = terrain.getTileSize(); GridPoint2 tileBounds = terrain.getMapBounds(0); Vector2 worldBounds = new Vector2(tileBounds.x * tileSize, tileBounds.y * tileSize); - + // Left // ! THIS ONE DOESNT WORK. GRIDPOINTS2UTIL.ZERO is (0, 4), not (0, 0) spawnEntityAt( @@ -287,26 +288,26 @@ private void spawnTerrain() { // spawnEntityAt(building1, randomPos, true, false); // } // } - + private void spawnBuilding2() { GridPoint2 minPos = new GridPoint2(0, 0); GridPoint2 maxPos = terrain.getMapBounds(0).sub(2, 2); - + for (int i = 0; i < NUM_BUILDINGS; i++) { GridPoint2 randomPos = RandomUtils.random(minPos, maxPos); Entity building2 = ObstacleFactory.createBuilding2(); spawnEntityAt(building2, randomPos, true, false); } } - - + + private Entity spawnPlayer() { Entity newPlayer = PlayerFactory.createPlayer(); spawnEntityAt(newPlayer, PLAYER_SPAWN, true, true); newPlayer.addComponent(new TouchAttackComponent(PhysicsLayer.NPC)); return newPlayer; } - + // Spawn player at a specific position private Entity spawnPlayer(GridPoint2 position) { Entity newPlayer = PlayerFactory.createPlayer(); @@ -337,25 +338,6 @@ private Entity spawnPlayer(GridPoint2 position) { // return ghostKing; // } - private Entity spawnBossKing1() { - GridPoint2 minPos = new GridPoint2(0, 0); - GridPoint2 maxPos = terrain.getMapBounds(0).sub(2, 2); - GridPoint2 randomPos - = new GridPoint2(0, 0); - Entity ghostKing = NPCFactory.createGhostKing(player); - spawnEntityAt(ghostKing, randomPos, true, true); - return ghostKing; - } - - /** - * Spawns a projectile that only heads towards the enemies in its lane. - * - * @param position The position of the Entity that's shooting the projectile. - * @param targetLayer The enemy layer of the "shooter". - * @param direction The direction the projectile should head towards. - * @param speed The speed of the projectiles. - * -======= /** * Spawns a projectile that only heads towards the enemies in its lane. * @@ -363,47 +345,28 @@ private Entity spawnBossKing1() { * @param targetLayer The enemy layer of the "shooter". * @param direction The direction the projectile should head towards. * @param speed The speed of the projectiles. ->>>>>>> 92874c64074b73bbc0cd494b332a657dee66f150 */ private void spawnProjectile(Vector2 position, short targetLayer, int direction, Vector2 speed) { Entity Projectile = ProjectileFactory.createFireBall(targetLayer, new Vector2(direction, position.y), speed); Projectile.setPosition(position); spawnEntity(Projectile); } - + /** * Spawns a projectile specifically for general mobs/xenohunters * -<<<<<<< HEAD - * @param position The position of the Entity that's shooting the projectile. - * @param targetLayer The enemy layer of the "shooter". - * @param direction The direction the projectile should head towards. - * @param speed The speed of the projectiles. - * -======= * @param position The position of the Entity that's shooting the projectile. * @param targetLayer The enemy layer of the "shooter". * @param direction The direction the projectile should head towards. * @param speed The speed of the projectiles. ->>>>>>> 92874c64074b73bbc0cd494b332a657dee66f150 */ private void spawnProjectileTest(Vector2 position, short targetLayer, int direction, Vector2 speed) { Entity Projectile = ProjectileFactory.createEngineerBullet(targetLayer, new Vector2(direction, position.y), speed); Projectile.setPosition(position); spawnEntity(Projectile); } - + /** -<<<<<<< HEAD - * Spawns a projectile to be used for multiple projectile function. - * - * @param position The position of the Entity that's shooting the projectile. - * @param targetLayer The enemy layer of the "shooter". - * @param space The space between the projectiles' destination. - * @param direction The direction the projectile should head towards. - * @param speed The speed of the projectiles. - * -======= * Spawns a projectile to be used for multiple projectile function. * * @param position The position of the Entity that's shooting the projectile. @@ -411,7 +374,6 @@ private void spawnProjectileTest(Vector2 position, short targetLayer, int direct * @param space The space between the projectiles' destination. * @param direction The direction the projectile should head towards. * @param speed The speed of the projectiles. ->>>>>>> 92874c64074b73bbc0cd494b332a657dee66f150 */ private void spawnProjectile(Vector2 position, short targetLayer, int space, int direction, Vector2 speed) { Entity Projectile = ProjectileFactory.createFireBall(targetLayer, new Vector2(direction, position.y + space), speed); @@ -434,8 +396,8 @@ private void spawnProjectile(Vector2 position, short targetLayer, int space, int // return bossKing1; // // } - - + + private void spawnXenoGrunts() { int[] pickedLanes = new Random().ints(1, 7) .distinct().limit(5).toArray(); @@ -476,11 +438,11 @@ private void spawnXenoGrunts() { // } // return bossKing2; // } - + private Entity spawnBossKing2() { GridPoint2 minPos = new GridPoint2(0, 0); GridPoint2 maxPos = terrain.getMapBounds(0).sub(2, 2); - + for (int i = 0; i < NUM_BOSS; i++) { int fixedX = terrain.getMapBounds(0).x - 1; // Rightmost x-coordinate int randomY = MathUtils.random(0, maxPos.y); @@ -493,16 +455,12 @@ private Entity spawnBossKing2() { } return bossKing2; } - + /** * Creates multiple projectiles that travel simultaneous. They all have same * the starting point but different destinations. * -<<<<<<< HEAD - * @param position The position of the Entity that's shooting the projectile. -======= * @param position The position of the Entity that's shooting the projectile. ->>>>>>> 92874c64074b73bbc0cd494b332a657dee66f150 * @param targetLayer The enemy layer of the "shooter". * @param direction The direction the projectile should head towards. * @param space The space between the projectiles' destination. @@ -516,15 +474,11 @@ private void spawnMultiProjectile(Vector2 position, short targetLayer, int direc --half; } } - + /** * Returns projectile that can do an area of effect damage * -<<<<<<< HEAD - * @param position The position of the Entity that's shooting the projectile. -======= * @param position The position of the Entity that's shooting the projectile. ->>>>>>> 92874c64074b73bbc0cd494b332a657dee66f150 * @param targetLayer The enemy layer of the "shooter". * @param direction The direction the projectile should head towards. * @param speed The speed of the projectiles. @@ -537,7 +491,7 @@ private void spawnEffectProjectile(Vector2 position, short targetLayer, int dire Projectile.setPosition(position); spawnEntity(Projectile); } - + /** * Spawns a pierce fireball. * Pierce fireball can go through targetlayers without disappearing but damage @@ -553,7 +507,7 @@ private void spawnPierceFireBall(Vector2 position, short targetLayer, int direct projectile.setPosition(position); spawnEntity(projectile); } - + /** * Spawns a ricochet fireball * Ricochet fireballs bounce off targets with a specified maximum count of 3 @@ -570,7 +524,7 @@ private void spawnRicochetFireball(Vector2 position, short targetLayer, int dire projectile.setPosition(position); spawnEntity(projectile); } - + /** * Spawns a split firework fireball. * Splits into mini projectiles that spreads out after collision. @@ -586,11 +540,11 @@ private void spawnSplitFireWorksFireBall(Vector2 position, short targetLayer, in projectile.setPosition(position); spawnEntity(projectile); } - + private void spawnWeaponTower() { GridPoint2 minPos = new GridPoint2(0, 0); GridPoint2 maxPos = terrain.getMapBounds(0).sub(2, 2); - + for (int i = 0; i < NUM_WEAPON_TOWERS; i++) { GridPoint2 randomPos1 = RandomUtils.random(minPos, maxPos); GridPoint2 randomPos2 = RandomUtils.random(minPos, maxPos); @@ -601,27 +555,27 @@ private void spawnWeaponTower() { spawnEntityAt(stunTower, randomPos2, true, true); } } - + private void spawnTNTTower() { GridPoint2 minPos = new GridPoint2(0, 0); GridPoint2 maxPos = terrain.getMapBounds(0).sub(2, 2); - + for (int i = 0; i < NUM_WEAPON_TOWERS; i++) { GridPoint2 randomPos = RandomUtils.random(minPos, maxPos); Entity weaponTower = TowerFactory.createTNTTower(); spawnEntityAt(weaponTower, randomPos, true, true); } - + } - - + + private void playMusic() { Music music = ServiceLocator.getResourceService().getAsset(backgroundMusic, Music.class); music.setLooping(true); music.setVolume(0.3f); music.play(); } - + private void loadAssets() { logger.debug("Loading assets"); ResourceService resourceService = ServiceLocator.getResourceService(); @@ -629,13 +583,13 @@ private void loadAssets() { resourceService.loadTextureAtlases(forestTextureAtlases); resourceService.loadSounds(forestSounds); resourceService.loadMusic(forestMusic); - + while (!resourceService.loadForMillis(10)) { // This could be upgraded to a loading screen logger.info("Loading... {}%", resourceService.getProgress()); } } - + private void unloadAssets() { logger.debug("Unloading assets"); ResourceService resourceService = ServiceLocator.getResourceService(); @@ -644,53 +598,53 @@ private void unloadAssets() { resourceService.unloadAssets(forestSounds); resourceService.unloadAssets(forestMusic); } - + @Override public void dispose() { super.dispose(); ServiceLocator.getResourceService().getAsset(backgroundMusic, Music.class).stop(); this.unloadAssets(); } - + private void spawnScrap() { GridPoint2 minPos = new GridPoint2(0, 0); GridPoint2 maxPos = terrain.getMapBounds(0).sub(2, 2); - + for (int i = 0; i < 5; i++) { GridPoint2 randomPos = RandomUtils.random(minPos, maxPos); Entity scrap = DropFactory.createScrapDrop(); spawnEntityAt(scrap, randomPos, true, false); } - + for (int i = 0; i < 5; i++) { GridPoint2 randomPos = RandomUtils.random(minPos, maxPos); Entity crystal = DropFactory.createCrystalDrop(); spawnEntityAt(crystal, randomPos, true, false); } } - + private void spawnIncome() { GridPoint2 minPos = new GridPoint2(0, 0); GridPoint2 maxPos = terrain.getMapBounds(0).sub(2, 2); - + for (int i = 0; i < 50; i++) { GridPoint2 randomPos = RandomUtils.random(minPos, maxPos); Entity towerfactory = TowerFactory.createIncomeTower(); spawnEntityAt(towerfactory, randomPos, true, true); } } - + private void spawnEngineer() { for (int i = 0; i < terrain.getMapBounds(0).x; i += 3) { Entity engineer = EngineerFactory.createEngineer(); spawnEntityAt(engineer, new GridPoint2(1, i), true, true); } } - - /** - * Creates the scanners (one per lane) that detect absence of towers and presence of mobs, - * and trigger engineer spawning - */ + + /** + * Creates the scanners (one per lane) that detect absence of towers and presence of mobs, + * and trigger engineer spawning + */ // private void spawnGapScanners() { // for (int i = 0; i < terrain.getMapBounds(0).y; i++) { // Entity scanner = GapScannerFactory.createScanner();