diff --git a/source/core/assets/images/mobs/skeleton.atlas b/source/core/assets/images/mobs/skeleton.atlas index f0117d879..9e1c78e17 100644 --- a/source/core/assets/images/mobs/skeleton.atlas +++ b/source/core/assets/images/mobs/skeleton.atlas @@ -69,7 +69,7 @@ skeleton_attack index: -1 skeleton_attack rotate: false - xy: 514, 2 + xy: 578, 52 size: 62, 48 orig: 62, 48 offset: 0, 0 @@ -83,7 +83,7 @@ skeleton_attack index: -1 skeleton_attack rotate: false - xy: 770, 2 + xy: 834, 52 size: 62, 48 orig: 62, 48 offset: 0, 0 @@ -95,41 +95,6 @@ skeleton_attack orig: 62, 48 offset: 0, 0 index: -1 -skeleton_death - rotate: false - xy: 1026, 2 - size: 62, 48 - orig: 62, 48 - offset: 0, 0 - index: -1 -skeleton_death - rotate: false - xy: 66, 52 - size: 62, 48 - orig: 62, 48 - offset: 0, 0 - index: -1 -skeleton_death - rotate: false - xy: 834, 52 - size: 62, 48 - orig: 62, 48 - offset: 0, 0 - index: -1 -skeleton_death - rotate: false - xy: 1154, 55 - size: 62, 45 - orig: 62, 45 - offset: 0, 0 - index: -1 -skeleton_death - rotate: false - xy: 578, 2 - size: 62, 48 - orig: 62, 48 - offset: 0, 0 - index: -1 skeleton_death rotate: false xy: 194, 52 @@ -188,7 +153,7 @@ skeleton_walk index: -1 skeleton_walk rotate: false - xy: 514, 52 + xy: 514, 2 size: 62, 48 orig: 62, 48 offset: 0, 0 @@ -202,7 +167,7 @@ skeleton_walk index: -1 skeleton_walk rotate: false - xy: 770, 52 + xy: 770, 2 size: 62, 48 orig: 62, 48 offset: 0, 0 @@ -237,21 +202,21 @@ skeleton_walk index: -1 skeleton_walk rotate: false - xy: 578, 52 + xy: 514, 52 size: 62, 48 orig: 62, 48 offset: 0, 0 index: -1 skeleton_walk rotate: false - xy: 130, 2 + xy: 66, 52 size: 62, 48 orig: 62, 48 offset: 0, 0 index: -1 skeleton_walk rotate: false - xy: 834, 2 + xy: 770, 52 size: 62, 48 orig: 62, 48 offset: 0, 0 diff --git a/source/core/assets/images/mobs/skeleton.png b/source/core/assets/images/mobs/skeleton.png index cbcbd1ed1..9d75bb066 100644 Binary files a/source/core/assets/images/mobs/skeleton.png and b/source/core/assets/images/mobs/skeleton.png differ 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 8fccaf74b..789f76d45 100644 --- a/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java +++ b/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java @@ -263,30 +263,9 @@ public void create() { waves = WaveFactory.createWaves(); spawnEntity(waves); waves.getEvents().addListener("spawnWave", this::spawnMob); - // spawnCoat(); -// spawnDodgingDragonKnight(17,4); -// spawnDeflectWizard(17, 3); -// spawnSplittingXenoGrunt(17, 2); -// spawnPatrick(); -// spawnDemonBoss(); - // spawnSplittingRocky(17, 4); - // spawnFireWizard(17, 3); - // spawnNecromancer(17, 2); - - - spawnScrap(); spawnGapScanners(); - -// spawnTNTTower(); -// spawnWeaponTower(); -// spawnGapScanners(); -// spawnDroidTower(); -// spawnFireWorksTower(); // Commented these out until they are needed for Demonstration -// spawnPierceTower(); -// spawnRicochetTower(); -// spawnBombship(); } private void displayUI() { @@ -344,90 +323,6 @@ private Entity spawnPlayer(GridPoint2 position) { return newPlayer; } - // commented 383 - 386 out as there was a missing arg? - private void spawnDemonBoss() { - Entity demon = MobBossFactory.createDemonBoss(5000); - spawnEntityAt(demon, new GridPoint2(19, 5), true, false); - } - - private void spawnPatrick() { - Entity patrick = MobBossFactory.createPatrickBoss(3000); - spawnEntityAt(patrick, new GridPoint2(18, 5), true, false); - } - - private void spawnPatrickDeath() { - Entity patrickDeath = MobBossFactory.patrickDead(); - spawnEntityAt(patrickDeath, new GridPoint2(18, 5), true, false); - } - // commented 398 - 401 out as there was a missing arg? -// private void spawnIceBaby() { -// Entity iceBaby = MobBossFactory.createIceBoss(); -// spawnEntityAt(iceBaby, new GridPoint2(19, 5), true, false); -// } - -// private void spawnDemonBoss() { -// Entity demon = MobBossFactory.createDemonBoss(); -// spawnEntityAt(demon, new GridPoint2(19, 5), true, false); -// } - -// private void spawnPatrick() { -// Entity patrick = MobBossFactory.createPatrickBoss(3000); -// spawnEntityAt(patrick, new GridPoint2(18, 5), true, false); -// } -// -// private void spawnPatrickDeath() { -// Entity patrickDeath = MobBossFactory.patrickDead(); -// spawnEntityAt(patrickDeath, new GridPoint2(18, 5), true, false); -// } -// -// private void spawnIceBaby() { -// Entity iceBaby = MobBossFactory.createIceBoss(); -// spawnEntityAt(iceBaby, new GridPoint2(19, 5), true, false); -// } - - /** - * 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); - Projectile.setPosition(position); - spawnEntity(Projectile); - } - - /** - * 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 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); - } - - /** - * 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); - Projectile.setPosition(position); - spawnEntity(Projectile); - } - /** * Spawn an entity on the map. Is called during a wave. Add cases here for each mob type * @param entity mob to be spawned @@ -449,7 +344,7 @@ public void spawnMob(String entity, GridPoint2 randomPos, int health) { case "Skeleton": mob = NPCFactory.createSkeleton(health); break; - case "DeflectWizard": + case "Wizard": mob = NPCFactory.createWizard(health); break; case "WaterQueen": @@ -499,401 +394,6 @@ public void spawnMob(String entity, GridPoint2 randomPos, int health) { spawnEntityAt(mob, randomPos, true, false); } - // * TEMPORARY FOR TESTING -// private void spawnSplittingXenoGrunt(int x, int y) { -// GridPoint2 pos = new GridPoint2(x, y); -// Entity xenoGrunt = NPCFactory.createSplittingXenoGrunt(); -// xenoGrunt.setScale(1.5f, 1.5f); -// spawnEntityAt(xenoGrunt, pos, true, true); -// } - // * TEMPORARY FOR TESTING - private void spawnSplittingRocky(int x, int y) { - GridPoint2 pos = new GridPoint2(x, y); - Entity rocky = NPCFactory.createSplittingRocky(60); - rocky.setScale(1.5f, 1.5f); - spawnEntityAt(rocky, pos, true, true); - } - - private void spawnFireWizard(int x, int y) { - GridPoint2 pos = new GridPoint2(x, y); - Entity firewiz = NPCFactory.createDeflectFireWizard(60); - firewiz.setScale(1.5f, 1.5f); - spawnEntityAt(firewiz, pos, true, true); - } - - private void spawnNecromancer(int x, int y) { - GridPoint2 pos = new GridPoint2(x, y); - Entity Necromancer = NPCFactory.createNecromancer(60); - Necromancer.setScale(1.5f, 1.5f); - spawnEntityAt(Necromancer, pos, true, true); - } - - // * TEMPORARY FOR TESTING -// private void spawnDodgingDragonKnight(int x, int y) { -// GridPoint2 pos = new GridPoint2(x, y); -// Entity fireworm = NPCFactory.createDodgingDragonKnight(); -// fireworm.setScale(1.5f, 1.5f); -// spawnEntityAt(fireworm, pos, true, true); -// } -// -// // * TEMPORARY FOR TESTING -// private void spawnDeflectXenoGrunt(int x, int y) { -// GridPoint2 pos = new GridPoint2(x, y); -// Entity xenoGrunt = NPCFactory.createDeflectXenoGrunt(); -// xenoGrunt.setScale(1.5f, 1.5f); -// spawnEntityAt(xenoGrunt, pos, true, true); -// } -// -// private void spawnFireWorm() { -// int[] pickedLanes = random.ints(1, 7) -// .distinct().limit(5).toArray(); -// for (int i = 0; i < NUM_GRUNTS; i++) { -// GridPoint2 randomPos = new GridPoint2(19, pickedLanes[i]); -// Entity fireWorm = NPCFactory.createFireWorm(); -// fireWorm.setScale(1.5f, 1.5f); -// spawnEntityAt(fireWorm, randomPos, true, false); -// } -// } -// -// private void spawnSkeleton() { -// int[] pickedLanes = new Random().ints(1, 7) -// .distinct().limit(5).toArray(); -// for (int i = 0; i < NUM_GRUNTS; i++) { -// GridPoint2 randomPos = new GridPoint2(19, pickedLanes[i]); -// Entity skeleton = NPCFactory.createSkeleton(); -// skeleton.setScale(1.5f, 1.5f); -// spawnEntityAt(skeleton, randomPos, true, false); -// } -// } - -// private void spawnDragonKnight() { -// int[] pickedLanes = random.ints(1, 7) -// .distinct().limit(5).toArray(); -// for (int i = 0; i < NUM_GRUNTS; i++) { -// GridPoint2 randomPos = new GridPoint2(19, pickedLanes[i]); -// Entity fireWorm = NPCFactory.createDragonKnight(); -// fireWorm.setScale(1.5f, 1.5f); -// spawnEntityAt(fireWorm, randomPos, true, false); -// } -// } -// -// private void spawnWizard() { -// int[] pickedLanes = new Random().ints(1, 7) -// .distinct().limit(5).toArray(); -// for (int i = 0; i < NUM_GRUNTS; i++) { -// GridPoint2 randomPos = new GridPoint2(19, pickedLanes[i]); -// Entity wizard = NPCFactory.createWizard(); -// wizard.setScale(1.5f, 1.5f); -// spawnEntityAt(wizard, randomPos, true, false); -// } -// } -// -// private void spawnWaterQueen() { -// int[] pickedLanes = new Random().ints(1, 7) -// .distinct().limit(5).toArray(); -// for (int i = 0; i < NUM_GRUNTS; i++) { -// GridPoint2 randomPos = new GridPoint2(19, pickedLanes[i]); -// Entity waterQueen = NPCFactory.createWaterQueen(); -// waterQueen.setScale(1.5f, 1.5f); -// spawnEntityAt(waterQueen, randomPos, true, false); -// } -// } -// -// private void spawnWaterSlime() { -// int[] pickedLanes = new Random().ints(1, 7) -// .distinct().limit(5).toArray(); -// for (int i = 0; i < NUM_GRUNTS; i++) { -// GridPoint2 randomPos = new GridPoint2(19, pickedLanes[i]); -// Entity waterSlime = NPCFactory.createWaterSlime(); -// waterSlime.setScale(1.5f, 1.5f); -// spawnEntityAt(waterSlime, randomPos, true, false); -// } -// } - - // * TEMPORARY FOR TESTING - private void spawnDodgingDragonKnight(int x, int y) { - GridPoint2 pos = new GridPoint2(x, y); - Entity fireworm = NPCFactory.createDodgingDragonKnight(100); - fireworm.setScale(1.5f, 1.5f); - spawnEntityAt(fireworm, pos, true, true); - } -// -// // * TEMPORARY FOR TESTING - private void spawnDeflectWizard(int x, int y) { - GridPoint2 pos = new GridPoint2(x, y); - Entity xenoGrunt = NPCFactory.createDeflectWizard(100); - xenoGrunt.setScale(1.5f, 1.5f); - spawnEntityAt(xenoGrunt, pos, true, true); - } -// -// private void spawnFireWorm() { -// -// int[] pickedLanes = rand.ints(0, ServiceLocator.getMapService().getHeight() ) -// -// .distinct().limit(5).toArray(); -// for (int i = 0; i < NUM_GRUNTS; i++) { -// GridPoint2 randomPos = new GridPoint2(19, pickedLanes[i]); -// Entity fireWorm = NPCFactory.createFireWorm(); -// fireWorm.setScale(1.5f, 1.5f); -// spawnEntityAt(fireWorm, randomPos, true, false); -// } -// } -// -// private void spawnSkeleton() { -// -// 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]); -// Entity skeleton = NPCFactory.createSkeleton(); -// skeleton.setScale(1.5f, 1.5f); -// spawnEntityAt(skeleton, randomPos, true, false); -// } -// } -// -// private void spawnDragonKnight() { -// -// int[] pickedLanes = rand.ints(0, ServiceLocator.getMapService().getHeight() ) -// -// .distinct().limit(5).toArray(); -// for (int i = 0; i < NUM_GRUNTS; i++) { -// GridPoint2 randomPos = new GridPoint2(19, pickedLanes[i]); -// Entity fireWorm = NPCFactory.createDodgingDragonKnight(); -// fireWorm.setScale(1.5f, 1.5f); -// spawnEntityAt(fireWorm, randomPos, true, false); -// } -// } -// -// private void spawnWizard() { -// -// int[] pickedLanes = rand.ints(0, ServiceLocator.getMapService().getHeight() ) -// -// .distinct().limit(5).toArray(); -// for (int i = 0; i < NUM_GRUNTS; i++) { -// GridPoint2 randomPos = new GridPoint2(19, pickedLanes[i]); -// Entity wizard = NPCFactory.createDeflectWizard(); -// wizard.setScale(1.5f, 1.5f); -// spawnEntityAt(wizard, randomPos, true, false); -// } -// } -// -// private void spawnWaterQueen() { -// -// 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]); -// Entity waterQueen = NPCFactory.createWaterQueen(); -// waterQueen.setScale(1.5f, 1.5f); -// spawnEntityAt(waterQueen, randomPos, true, false); -// } -// } -// -// private void spawnWaterSlime() { -// -// 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]); -// Entity waterSlime = NPCFactory.createSplittingWaterSlime(); -// waterSlime.setScale(1.5f, 1.5f); -// spawnEntityAt(waterSlime, randomPos, true, false); -// } -// } - - private void spawnCoat() { - Entity gregMob = NPCFactory.createCoat(100); - gregMob.setScale(1.5f, 1.5f); - spawnEntityAt(gregMob, new GridPoint2(17, 4), false, false); - } - - /** - * 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. - * @param space The space between the projectiles' destination. - * @param speed The speed of the projectiles. - * @param quantity The amount of projectiles to spawn. - */ - private void spawnMultiProjectile(Vector2 position, short targetLayer, int direction, int space, Vector2 speed, int quantity) { - int half = quantity / 2; - for (int i = 0; i < quantity; i++) { - spawnProjectile(position, targetLayer, space * half, direction, speed); - --half; - } - } - - /** - * 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. - * @param speed The speed of the projectiles. - * @param effect Type of effect. - * @param aoe Whether it is an aoe projectile. - */ - private void spawnEffectProjectile(Vector2 position, short targetLayer, int direction, Vector2 speed, - ProjectileEffects effect, boolean aoe) { - Entity Projectile = ProjectileFactory.createEffectProjectile(targetLayer, new Vector2(direction, position.y), speed, effect, aoe); - Projectile.setPosition(position); - spawnEntity(Projectile); - } - - /** - * Spawns a pierce fireball. - * Pierce fireball can go through targetlayers without disappearing but damage - * will still be applied. - * - * @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 spawnPierceFireBall(Vector2 position, short targetLayer, int direction, Vector2 speed) { - Entity projectile = ProjectileFactory.createPierceFireBall(targetLayer, new Vector2(direction, position.y), speed); - projectile.setPosition(position); - spawnEntity(projectile); - } - - /** - * Spawns a ricochet fireball - * Ricochet fireballs bounce off targets with a specified maximum count of 3 - * Possible extensions: Make the bounce count flexible with a param. - * - * @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 spawnRicochetFireball(Vector2 position, short targetLayer, int direction, Vector2 speed) { - // Bounce count set to 0. - Entity projectile = ProjectileFactory.createRicochetFireball(targetLayer, new Vector2(direction, position.y), speed, 0); - projectile.setPosition(position); - spawnEntity(projectile); - } - - /** - * Spawns a split firework fireball. - * Splits into mini projectiles that spreads out after collision. - * - * @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 towards. - * @param speed The speed of the projectiles. - * @param amount The amount of projectiles appearing after collision. - */ - private void spawnSplitFireWorksFireBall(Vector2 position, short targetLayer, int direction, Vector2 speed, int amount) { - Entity projectile = ProjectileFactory.createSplitFireWorksFireball(targetLayer, new Vector2(direction, position.y), speed, amount); - projectile.setPosition(position); - spawnEntity(projectile); - } - - 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 + 7 ; i++) { - GridPoint2 randomPos1 = RandomUtils.random(minPos, maxPos); - GridPoint2 randomPos2 = RandomUtils.random(minPos, maxPos); - Entity wallTower = TowerFactory.createWallTower(); - Entity fireTower = TowerFactory.createFireTower(); - Entity stunTower = TowerFactory.createStunTower(); - spawnEntityAt(fireTower, randomPos1, true, true); - spawnEntityAt(stunTower, randomPos2, true, true); - spawnEntityAt(wallTower, randomPos2, true, true); - } - } - - // * TEMPORARY FOR TESTING - private void spawnFireTowerAt(int x, int y) { - GridPoint2 pos = new GridPoint2(x, y); - Entity fireTower = TowerFactory.createFireTower(); - - spawnEntityAt(fireTower, pos, true, true); - } - private void spawnDroidTowerAt(int x, int y) { - GridPoint2 pos = new GridPoint2(x, y); - Entity droidTower = TowerFactory.createDroidTower(); - - spawnEntityAt(droidTower, pos, true, true); - } - - 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 + 5; i++) { - GridPoint2 randomPos = RandomUtils.random(minPos, maxPos); - Entity weaponTower = TowerFactory.createTNTTower(); - spawnEntityAt(weaponTower, randomPos, true, true); - } - - } - private void spawnFireWorksTower() { - GridPoint2 minPos = new GridPoint2(0, 2); - GridPoint2 maxPos = terrain.getMapBounds(0).sub(1, 1); - - for (int i = 0; i < NUM_WEAPON_TOWERS; i++) { - GridPoint2 randomPos = RandomUtils.random(minPos, maxPos); - Entity FireWorksTower = TowerFactory.createFireworksTower(); - spawnEntityAt(FireWorksTower, randomPos, true, true); - } - - } - private void spawnPierceTower() { - GridPoint2 minPos = new GridPoint2(0, 2); - GridPoint2 maxPos = terrain.getMapBounds(0).sub(3, 3); - - for (int i = 0; i < NUM_WEAPON_TOWERS; i++) { - GridPoint2 randomPos = RandomUtils.random(minPos, maxPos); - Entity PierceTower = TowerFactory.createPierceTower(); - spawnEntityAt(PierceTower, randomPos, true, true); - } - - } - private void spawnRicochetTower() { - GridPoint2 minPos = new GridPoint2(0, 2); - GridPoint2 maxPos = terrain.getMapBounds(0).sub(0, 3); - - for (int i = 0; i < NUM_WEAPON_TOWERS; i++) { - GridPoint2 randomPos = RandomUtils.random(minPos, maxPos); - Entity RicochetTower = TowerFactory.createRicochetTower(); - spawnEntityAt(RicochetTower, randomPos, true, true); - } - - } - - private void spawnBombship() { - GridPoint2 minPos = new GridPoint2(0, 0); - GridPoint2 maxPos = terrain.getMapBounds(0).sub(5, 1); - Entity bombship = BombshipFactory.createBombship(); - spawnEntityAt(bombship, minPos, true, true); - } - - 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 + 5; i++) { - GridPoint2 randomPos = RandomUtils.random(minPos, maxPos); - Entity weaponTower = TowerFactory.createDroidTower(); - spawnEntityAt(weaponTower, randomPos, true, false); - } - } - - private void playMusic() { - Music music = ServiceLocator.getResourceService().getAsset(BACKGROUND_MUSIC, Music.class); - music.setLooping(true); - music.setVolume(0.3f); - music.play(); - } - private void loadAssets() { logger.debug("Loading assets"); ResourceService resourceService = ServiceLocator.getResourceService(); @@ -941,17 +441,6 @@ private void spawnScrap() { } } - 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); - } - } - /** * Creates the scanners (one per lane) that detect absence of towers and presence of mobs, * and trigger engineer spawning diff --git a/source/core/src/main/com/csse3200/game/components/EffectsComponent.java b/source/core/src/main/com/csse3200/game/components/EffectsComponent.java index 596bb71f2..4fb249d6d 100644 --- a/source/core/src/main/com/csse3200/game/components/EffectsComponent.java +++ b/source/core/src/main/com/csse3200/game/components/EffectsComponent.java @@ -2,20 +2,13 @@ import java.util.ArrayList; -import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.physics.box2d.Fixture; -import com.csse3200.game.ai.tasks.AITaskComponent; -import com.csse3200.game.components.tower.TowerUpgraderComponent; import com.csse3200.game.entities.Entity; import com.csse3200.game.physics.BodyUserData; import com.csse3200.game.physics.PhysicsLayer; import com.csse3200.game.physics.components.HitboxComponent; -import com.csse3200.game.physics.components.PhysicsMovementComponent; import com.csse3200.game.services.ServiceLocator; -import com.badlogic.gdx.utils.Timer; -import com.badlogic.gdx.utils.Timer.Task; - import com.badlogic.gdx.utils.Array; /** @@ -102,6 +95,7 @@ public void applySingleEffect(ProjectileEffects effect, Entity targetEntity) { } effectComponent.applyEffect(effect, hostEntity, targetEntity); } + /** * Used for aoe projectiles to apply effects to all entities within the area of effect (radius). * @param effect effect to be applied to entities within radius @@ -136,132 +130,4 @@ public void applyAoeEffect(ProjectileEffects effect) { effectComponent.applyEffect(effect, hostEntity, targetEntity); } } - - /** - * Deals damage to target based on hosts' CombatStatsComponent - * @param target CombatStatsComponent of entity hit by projectile - * @param host CombatStatsComponent of projectile - */ - private void fireballEffect(CombatStatsComponent target, CombatStatsComponent host) { - target.hit(host); - } - -// /** -// * Applies 5 ticks of damage from hosts' CombatStatsComponent over 5 seconds -// * @param target CombatStatsComponent of entity hit by projectile -// * @param host CombatStatsComponent of projectile -// */ -// private void burnEffect(CombatStatsComponent target, CombatStatsComponent host) { -// // Ensure burn effects aren't applied multiple times by same projectile -// if (burnEntities.contains(target, false)) { -// return; -// } -// burnEntities.add(target); -// // Create a timer task to apply the effect repeatedly -// int numberOfTicks = 5; -// long delay = 1; -// Timer.schedule(new Timer.Task() { -// private int count = 0; -// -// @Override -// public void run() { -// if (count < numberOfTicks) { -// target.hit(host); -// count++; -// } else { -// // Ensure to cancel the task when it's done -// this.cancel(); -// } -// } -// }, delay, delay); -// } - - /** - * Applies slow effect to targetEntity. If entity is a mob, speed - * and firing rate will be slowed. If entity is a tower, firing rate - * will be slowed - * @param targetEntity Entity for slow effect to be applied to - */ - private void slowEffect(Entity targetEntity) { - boolean towerFlag = false; - boolean mobFlag = false; - - PhysicsMovementComponent targetPhysics = null; - float xSpeed = 0; - float ySpeed = 0; - - // Create a timer task to apply the effect repeatedly - if (PhysicsLayer.contains(PhysicsLayer.HUMANS, targetEntity.getComponent(HitboxComponent.class).getLayer())) { - // towers - towerFlag = true; - targetEntity.getEvents().trigger("upgradeTower", TowerUpgraderComponent.UPGRADE.FIRERATE, -30); - } else if (PhysicsLayer.contains(PhysicsLayer.NPC, targetEntity.getComponent(HitboxComponent.class).getLayer())) { - // mobs - mobFlag = true; - targetPhysics = targetEntity.getComponent(PhysicsMovementComponent.class); - if (targetPhysics == null) { - return; - } - - // Halve the mob speed - xSpeed = targetPhysics.getSpeed().x; - ySpeed = targetPhysics.getSpeed().y; - targetPhysics.setSpeed(new Vector2(xSpeed/2, ySpeed/2)); - } else { - return; - } - - // Reset speed - boolean finalTowerFlag = towerFlag; - boolean finalMobFlag = mobFlag; - PhysicsMovementComponent finalTargetPhysics = targetPhysics; - float finalXSpeed = xSpeed; - float finalYSpeed = ySpeed; - Timer.schedule(new Task() { - @Override - public void run() { - if (finalTowerFlag) { - targetEntity.getEvents().trigger("upgradeTower", TowerUpgraderComponent.UPGRADE.FIRERATE, 30); - } else if (finalMobFlag) { - finalTargetPhysics.setSpeed(new Vector2(finalXSpeed, finalYSpeed)); - } - } - }, 5); // 5 seconds delay - } - - /** - * Applies stun effect to a taget entity. - * @param targetEntity Entity for stun effect to be applied to. - */ - private void stunEffect(Entity targetEntity) { - CombatStatsComponent hostCombatStats = targetEntity.getComponent(CombatStatsComponent.class); - AITaskComponent taskComponent = targetEntity.getComponent(AITaskComponent.class); - - if (hostCombatStats == null || taskComponent == null) { - return; - } - - hostCombatStats.setBaseAttack(0); - - if (stunnedEntities.contains(targetEntity)) { - return; - } - - taskComponent.disposeAll(); - stunnedEntities.add(targetEntity); - - new java.util.Timer().schedule( - new java.util.TimerTask() { - @Override - public void run() { - taskComponent.restore(); - for (int i = 0; i < stunnedEntities.size(); i++) { - if (stunnedEntities.get(i).equals(targetEntity)) { - stunnedEntities.remove(stunnedEntities.get(i)); - } - } - this.cancel(); - } - }, 5000); - } } \ No newline at end of file diff --git a/source/core/src/main/com/csse3200/game/components/gamearea/EngineerCountDisplay.java b/source/core/src/main/com/csse3200/game/components/gamearea/EngineerCountDisplay.java index 6334e1b4a..40c0f3b04 100644 --- a/source/core/src/main/com/csse3200/game/components/gamearea/EngineerCountDisplay.java +++ b/source/core/src/main/com/csse3200/game/components/gamearea/EngineerCountDisplay.java @@ -64,13 +64,15 @@ private void addActors() { * Updates the engineer count on the UI component */ public void updateCount() { - int currentCount = ServiceLocator.getGameEndService().getEngineerCount(); - String text = String.format("%d", currentCount); - engineerTb.getLabel().setText(text); - if (currentCount < ServiceLocator.getGameEndService().getThreshold()) { + if (engineerTb != null) { // fix for null pointer exception + int currentCount = ServiceLocator.getGameEndService().getEngineerCount(); + String text = String.format("%d", currentCount); + engineerTb.getLabel().setText(text); + if (currentCount < ServiceLocator.getGameEndService().getThreshold()) { // engineerTb.addAction(Actions.color(Color.RED, 0.5f, Interpolation.swingIn)); - engineerTb.addAction(Actions.forever(new SequenceAction(Actions.fadeOut(0.5f), - Actions.fadeIn(0.5f)))); + engineerTb.addAction(Actions.forever(new SequenceAction(Actions.fadeOut(0.5f), + Actions.fadeIn(0.5f)))); + } } } diff --git a/source/core/src/main/com/csse3200/game/components/npc/ArcaneArcherAnimationController.java b/source/core/src/main/com/csse3200/game/components/npc/ArcaneArcherAnimationController.java index 71fa5359d..82c587f18 100644 --- a/source/core/src/main/com/csse3200/game/components/npc/ArcaneArcherAnimationController.java +++ b/source/core/src/main/com/csse3200/game/components/npc/ArcaneArcherAnimationController.java @@ -5,19 +5,14 @@ import com.csse3200.game.rendering.AnimationRenderComponent; import com.csse3200.game.services.ServiceLocator; -import java.security.SecureRandom; /** * This class listens to events relevant to a ghost entity's state and plays the animation when one * of the events is triggered. */ public class ArcaneArcherAnimationController extends Component { - // // For on collision sounds later - // private static final String COLLISION_SFX = "sounds/projectiles/on_collision.mp3"; - // Sound onCollisionSound = ServiceLocator.getResourceService().getAsset( - // COLLISION_SFX, Sound.class); + AnimationRenderComponent animator; - private SecureRandom rand = new SecureRandom(); private static final String ATTACK_SOUND = "sounds/mobs/archerArrow.mp3"; Sound attackSound = ServiceLocator.getResourceService().getAsset( diff --git a/source/core/src/main/com/csse3200/game/components/npc/CoatAnimationController.java b/source/core/src/main/com/csse3200/game/components/npc/CoatAnimationController.java index e9bf8170e..c023e0aa5 100644 --- a/source/core/src/main/com/csse3200/game/components/npc/CoatAnimationController.java +++ b/source/core/src/main/com/csse3200/game/components/npc/CoatAnimationController.java @@ -5,19 +5,13 @@ import com.csse3200.game.rendering.AnimationRenderComponent; import com.csse3200.game.services.ServiceLocator; -import java.security.SecureRandom; /** * This class listens to events relevant to a ghost entity's state and plays the animation when one * of the events is triggered. */ public class CoatAnimationController extends Component { - // // For on collision sounds later - // private static final String COLLISION_SFX = "sounds/projectiles/on_collision.mp3"; - // Sound onCollisionSound = ServiceLocator.getResourceService().getAsset( - // COLLISION_SFX, Sound.class); AnimationRenderComponent animator; - private SecureRandom rand = new SecureRandom(); private static final String ATTACK_SOUND = "sounds/mobs/coatAttack.mp3"; Sound attackSound = ServiceLocator.getResourceService().getAsset( diff --git a/source/core/src/main/com/csse3200/game/components/npc/DragonKnightAnimationController.java b/source/core/src/main/com/csse3200/game/components/npc/DragonKnightAnimationController.java index 6d9d54215..7302a1cdc 100644 --- a/source/core/src/main/com/csse3200/game/components/npc/DragonKnightAnimationController.java +++ b/source/core/src/main/com/csse3200/game/components/npc/DragonKnightAnimationController.java @@ -2,19 +2,13 @@ import com.csse3200.game.components.Component; import com.csse3200.game.rendering.AnimationRenderComponent; -import java.security.SecureRandom; /** * This class listens to events relevant to a ghost entity's state and plays the animation when one * of the events is triggered. */ public class DragonKnightAnimationController extends Component { - // // For on collision sounds later - // private static final String COLLISION_SFX = "sounds/projectiles/on_collision.mp3"; - // Sound onCollisionSound = ServiceLocator.getResourceService().getAsset( - // COLLISION_SFX, Sound.class); AnimationRenderComponent animator; - private SecureRandom rand = new SecureRandom(); @Override public void create() { diff --git a/source/core/src/main/com/csse3200/game/components/npc/FireWormAnimationController.java b/source/core/src/main/com/csse3200/game/components/npc/FireWormAnimationController.java index 141d43d69..28d118210 100644 --- a/source/core/src/main/com/csse3200/game/components/npc/FireWormAnimationController.java +++ b/source/core/src/main/com/csse3200/game/components/npc/FireWormAnimationController.java @@ -4,19 +4,13 @@ import com.csse3200.game.components.Component; import com.csse3200.game.rendering.AnimationRenderComponent; import com.csse3200.game.services.ServiceLocator; -import java.security.SecureRandom; /** * This class listens to events relevant to a ghost entity's state and plays the animation when one * of the events is triggered. */ public class FireWormAnimationController extends Component { - // // For on collision sounds later - // private static final String COLLISION_SFX = "sounds/projectiles/on_collision.mp3"; - // Sound onCollisionSound = ServiceLocator.getResourceService().getAsset( - // COLLISION_SFX, Sound.class); AnimationRenderComponent animator; - private SecureRandom rand = new SecureRandom(); private static final String ATTACK_SOUND = "sounds/mobs/fireWormRoar.mp3"; Sound attackSound = ServiceLocator.getResourceService().getAsset( diff --git a/source/core/src/main/com/csse3200/game/components/npc/FirewizardAnimationController.java b/source/core/src/main/com/csse3200/game/components/npc/FirewizardAnimationController.java index 267c23404..b10236761 100644 --- a/source/core/src/main/com/csse3200/game/components/npc/FirewizardAnimationController.java +++ b/source/core/src/main/com/csse3200/game/components/npc/FirewizardAnimationController.java @@ -3,12 +3,9 @@ import com.csse3200.game.components.Component; import com.csse3200.game.rendering.AnimationRenderComponent; -import java.security.SecureRandom; - public class FirewizardAnimationController extends Component { AnimationRenderComponent animator; - private SecureRandom rand = new SecureRandom(); @Override diff --git a/source/core/src/main/com/csse3200/game/components/npc/NecromancerAnimationController.java b/source/core/src/main/com/csse3200/game/components/npc/NecromancerAnimationController.java index 3bdad9407..dfbd4bc9a 100644 --- a/source/core/src/main/com/csse3200/game/components/npc/NecromancerAnimationController.java +++ b/source/core/src/main/com/csse3200/game/components/npc/NecromancerAnimationController.java @@ -3,13 +3,9 @@ import com.csse3200.game.components.Component; import com.csse3200.game.rendering.AnimationRenderComponent; -import java.security.SecureRandom; - public class NecromancerAnimationController extends Component { AnimationRenderComponent animator; - private SecureRandom rand = new SecureRandom(); - @Override public void create() { diff --git a/source/core/src/main/com/csse3200/game/components/npc/NightBorneAnimationController.java b/source/core/src/main/com/csse3200/game/components/npc/NightBorneAnimationController.java index d821f6cca..fccdfe580 100644 --- a/source/core/src/main/com/csse3200/game/components/npc/NightBorneAnimationController.java +++ b/source/core/src/main/com/csse3200/game/components/npc/NightBorneAnimationController.java @@ -2,7 +2,6 @@ import com.csse3200.game.components.Component; import com.csse3200.game.rendering.AnimationRenderComponent; -import java.security.SecureRandom; /** * This class listens to events relevant to a ghost entity's state and plays the animation when one @@ -13,9 +12,7 @@ public class NightBorneAnimationController extends Component { // private static final String COLLISION_SFX = "sounds/projectiles/on_collision.mp3"; // Sound onCollisionSound = ServiceLocator.getResourceService().getAsset( // COLLISION_SFX, Sound.class); - AnimationRenderComponent animator; - private SecureRandom rand = new SecureRandom(); - + AnimationRenderComponent animator; @Override public void create() { diff --git a/source/core/src/main/com/csse3200/game/components/npc/RockyAnimationController.java b/source/core/src/main/com/csse3200/game/components/npc/RockyAnimationController.java index f6743dd9d..63f850085 100644 --- a/source/core/src/main/com/csse3200/game/components/npc/RockyAnimationController.java +++ b/source/core/src/main/com/csse3200/game/components/npc/RockyAnimationController.java @@ -3,11 +3,8 @@ import com.csse3200.game.components.Component; import com.csse3200.game.rendering.AnimationRenderComponent; -import java.security.SecureRandom; - public class RockyAnimationController extends Component { AnimationRenderComponent animator; - private SecureRandom rand = new SecureRandom(); @Override diff --git a/source/core/src/main/com/csse3200/game/components/npc/SkeletonAnimationController.java b/source/core/src/main/com/csse3200/game/components/npc/SkeletonAnimationController.java index d5ea57bfa..7a821ef75 100644 --- a/source/core/src/main/com/csse3200/game/components/npc/SkeletonAnimationController.java +++ b/source/core/src/main/com/csse3200/game/components/npc/SkeletonAnimationController.java @@ -4,19 +4,13 @@ import com.csse3200.game.components.Component; import com.csse3200.game.rendering.AnimationRenderComponent; import com.csse3200.game.services.ServiceLocator; -import java.security.SecureRandom; /** * This class listens to events relevant to a ghost entity's state and plays the animation when one * of the events is triggered. */ public class SkeletonAnimationController extends Component { - // // For on collision sounds later - // private static final String COLLISION_SFX = "sounds/projectiles/on_collision.mp3"; - // Sound onCollisionSound = ServiceLocator.getResourceService().getAsset( - // COLLISION_SFX, Sound.class); AnimationRenderComponent animator; - private SecureRandom rand = new SecureRandom(); /** Sound variables */ private static final String ATTACK_SOUND = "sounds/mobs/boneBreak.mp3"; diff --git a/source/core/src/main/com/csse3200/game/components/npc/SplitMoblings.java b/source/core/src/main/com/csse3200/game/components/npc/SplitMoblings.java index 1b1d8497b..3fd20bb9d 100644 --- a/source/core/src/main/com/csse3200/game/components/npc/SplitMoblings.java +++ b/source/core/src/main/com/csse3200/game/components/npc/SplitMoblings.java @@ -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); } /** diff --git a/source/core/src/main/com/csse3200/game/components/npc/WaterQueenAnimationController.java b/source/core/src/main/com/csse3200/game/components/npc/WaterQueenAnimationController.java index 0b8a00b75..294f312b1 100644 --- a/source/core/src/main/com/csse3200/game/components/npc/WaterQueenAnimationController.java +++ b/source/core/src/main/com/csse3200/game/components/npc/WaterQueenAnimationController.java @@ -4,19 +4,13 @@ import com.csse3200.game.components.Component; import com.csse3200.game.rendering.AnimationRenderComponent; import com.csse3200.game.services.ServiceLocator; -import java.security.SecureRandom; /** * This class listens to events relevant to a ghost entity's state and plays the animation when one * of the events is triggered. */ public class WaterQueenAnimationController extends Component { - // // For on collision sounds later - // private static final String COLLISION_SFX = "sounds/projectiles/on_collision.mp3"; - // Sound onCollisionSound = ServiceLocator.getResourceService().getAsset( - // COLLISION_SFX, Sound.class); AnimationRenderComponent animator; - private SecureRandom rand = new SecureRandom(); private static final String ATTACK_SOUND = "sounds/mobs/waterQueenSpell.mp3"; Sound attackSound = ServiceLocator.getResourceService().getAsset( diff --git a/source/core/src/main/com/csse3200/game/components/npc/WaterSlimeAnimationController.java b/source/core/src/main/com/csse3200/game/components/npc/WaterSlimeAnimationController.java index 6909dad10..52163ddcb 100644 --- a/source/core/src/main/com/csse3200/game/components/npc/WaterSlimeAnimationController.java +++ b/source/core/src/main/com/csse3200/game/components/npc/WaterSlimeAnimationController.java @@ -2,19 +2,13 @@ import com.csse3200.game.components.Component; import com.csse3200.game.rendering.AnimationRenderComponent; -import java.security.SecureRandom; /** * This class listens to events relevant to a ghost entity's state and plays the animation when one * of the events is triggered. */ public class WaterSlimeAnimationController extends Component { - // // For on collision sounds later - // private static final String COLLISION_SFX = "sounds/projectiles/on_collision.mp3"; - // Sound onCollisionSound = ServiceLocator.getResourceService().getAsset( - // COLLISION_SFX, Sound.class); AnimationRenderComponent animator; - private SecureRandom rand = new SecureRandom(); @Override public void create() { diff --git a/source/core/src/main/com/csse3200/game/components/npc/WizardAnimationController.java b/source/core/src/main/com/csse3200/game/components/npc/WizardAnimationController.java index c8c8e7073..9b4660afb 100644 --- a/source/core/src/main/com/csse3200/game/components/npc/WizardAnimationController.java +++ b/source/core/src/main/com/csse3200/game/components/npc/WizardAnimationController.java @@ -4,19 +4,13 @@ import com.csse3200.game.components.Component; import com.csse3200.game.rendering.AnimationRenderComponent; import com.csse3200.game.services.ServiceLocator; -import java.security.SecureRandom; /** * This class listens to events relevant to a ghost entity's state and plays the animation when one * of the events is triggered. */ public class WizardAnimationController extends Component { - // // For on collision sounds later - // private static final String COLLISION_SFX = "sounds/projectiles/on_collision.mp3"; - // Sound onCollisionSound = ServiceLocator.getResourceService().getAsset( - // COLLISION_SFX, Sound.class); AnimationRenderComponent animator; - private SecureRandom rand = new SecureRandom(); /** Sound variables */ private static final String ATTACK_SOUND = "sounds/mobs/wizardSpell.mp3"; @@ -31,8 +25,6 @@ public void create() { entity.getEvents().addListener("mob_walk", this::animateWalk); entity.getEvents().addListener("mob_attack", this::animateAttack); entity.getEvents().addListener("mob_death", this::animateDeath); - - } void animateWalk() { 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 5bac6e0c6..60714c560 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 @@ -67,7 +67,7 @@ public FireTowerCombatTask(int priority, float maxRange) { public void start() { super.start(); // get the tower coordinates - this.towerPosition = owner.getEntity().getCenterPosition(); + this.towerPosition = owner.getEntity().getCenterPosition().sub(0.125f,0.125f); this.maxRangePosition.set(towerPosition.x + maxRange, towerPosition.y); owner.getEntity().getEvents().addListener("addFireRate",this::changeFireRateInterval); //default to idle state diff --git a/source/core/src/main/com/csse3200/game/components/tasks/MobTask/MobTask.java b/source/core/src/main/com/csse3200/game/components/tasks/MobTask/MobTask.java index 332188cdc..9eebbf1d4 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/MobTask/MobTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/MobTask/MobTask.java @@ -89,7 +89,6 @@ public void start() { super.start(); mob = owner.getEntity(); animation = mob.getComponent(AnimationRenderComponent.class); - mob.getComponent(PhysicsMovementComponent.class).setSpeed(MELEE_MOB_SPEED); melee = mobType.isMelee(); movementTask = new MovementTask(new Vector2(0f, mob.getPosition().y)); @@ -102,8 +101,10 @@ public void start() { if (melee) { mob.getComponent(PhysicsMovementComponent.class).setSpeed(MELEE_MOB_SPEED); + mob.getComponent(PhysicsMovementComponent.class).setNormalSpeed(MELEE_MOB_SPEED); } else { mob.getComponent(PhysicsMovementComponent.class).setSpeed(MELEE_RANGE_SPEED); + mob.getComponent(PhysicsMovementComponent.class).setNormalSpeed(MELEE_RANGE_SPEED); } } @@ -115,13 +116,14 @@ public void update() { if(mob.getCenterPosition().x <= 1) { mob.getComponent(CombatStatsComponent.class).setHealth(0); + ServiceLocator.getGameEndService().updateEngineerCount(); } // death check if ((mob.getComponent(CombatStatsComponent.class).getHealth() <= 0 && !deathFlag)) { // decrement engineer count // ! tests failing because of textbox - // ServiceLocator.getGameEndService().updateEngineerCount(); + changeState(State.DEATH); animate(); movementTask.stop(); diff --git a/source/core/src/main/com/csse3200/game/components/tasks/PierceTowerCombatTask.java b/source/core/src/main/com/csse3200/game/components/tasks/PierceTowerCombatTask.java index 7b5dd7069..75268d9b6 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/PierceTowerCombatTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/PierceTowerCombatTask.java @@ -63,7 +63,7 @@ public PierceTowerCombatTask(int priority, float maxRange) { public void start() { super.start(); // Get the tower coordinates - this.towerPosition = owner.getEntity().getCenterPosition(); + this.towerPosition = owner.getEntity().getCenterPosition().sub(0.25f, 0.25f); this.maxRangePosition.set(towerPosition.x + maxRange, towerPosition.y); // Set the default state to IDLE state owner.getEntity().getEvents().trigger(IDLE); diff --git a/source/core/src/main/com/csse3200/game/components/tasks/RicochetTowerCombatTask.java b/source/core/src/main/com/csse3200/game/components/tasks/RicochetTowerCombatTask.java index 0fdcdbd26..6e60bf01d 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/RicochetTowerCombatTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/RicochetTowerCombatTask.java @@ -65,7 +65,7 @@ public RicochetTowerCombatTask(int priority, float maxRange) { public void start() { super.start(); // Get the tower coordinates - this.towerPosition = owner.getEntity().getCenterPosition(); + this.towerPosition = owner.getEntity().getCenterPosition().sub(0.25f, 0.25f); this.maxRangePosition.set(towerPosition.x + maxRange, towerPosition.y); // Set the default state to IDLE state owner.getEntity().getEvents().trigger(IDLE); diff --git a/source/core/src/main/com/csse3200/game/components/tasks/SpawnWaveTask.java b/source/core/src/main/com/csse3200/game/components/tasks/SpawnWaveTask.java index 912a2451b..201e3823f 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/SpawnWaveTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/SpawnWaveTask.java @@ -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 { 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 000240e6a..03abc3552 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 @@ -67,7 +67,7 @@ public StunTowerCombatTask(int priority, float maxRange) { public void start() { super.start(); //get the tower coordinates - this.towerPosition = owner.getEntity().getCenterPosition(); + this.towerPosition = owner.getEntity().getCenterPosition().sub(0.25f, 0.25f); this.maxRangePosition.set(towerPosition.x + maxRange, towerPosition.y); owner.getEntity().getEvents().addListener("addFireRate",this::changeFireRateInterval); //set the default state to IDLE state diff --git a/source/core/src/main/com/csse3200/game/components/tasks/bosstask/IceBabyTask.java b/source/core/src/main/com/csse3200/game/components/tasks/bosstask/IceBabyTask.java index 80e703ebf..7cfea58df 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/bosstask/IceBabyTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/bosstask/IceBabyTask.java @@ -71,6 +71,7 @@ public void start() { animation = iceBaby.getComponent(AnimationRenderComponent.class); currentPos = iceBaby.getPosition(); iceBaby.getComponent(PhysicsMovementComponent.class).setSpeed(ICEBABY_SPEED); + iceBaby.getComponent(PhysicsMovementComponent.class).setNormalSpeed(ICEBABY_SPEED); Timer.schedule(new Timer.Task() { @Override public void run() { @@ -264,6 +265,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); } /** diff --git a/source/core/src/main/com/csse3200/game/components/tasks/bosstask/PatrickTask.java b/source/core/src/main/com/csse3200/game/components/tasks/bosstask/PatrickTask.java index bf5e6c30c..cb3f27b8f 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/bosstask/PatrickTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/bosstask/PatrickTask.java @@ -64,6 +64,7 @@ public void start() { patrick = owner.getEntity(); animation = owner.getEntity().getComponent(AnimationRenderComponent.class); // get animation patrick.getComponent(PhysicsMovementComponent.class).setSpeed(PATRICK_SPEED); // set speed + patrick.getComponent(PhysicsMovementComponent.class).setNormalSpeed(PATRICK_SPEED); // give game time to load Timer.schedule(new Timer.Task() { 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 7d9e0e731..cca65b2e5 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 @@ -124,11 +124,11 @@ public List 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(); } } diff --git a/source/core/src/main/com/csse3200/game/components/tasks/waves/WaveClass.java b/source/core/src/main/com/csse3200/game/components/tasks/waves/WaveClass.java index 3e197601e..635834811 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/waves/WaveClass.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/waves/WaveClass.java @@ -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 entities; private List wave; - private int mobIndex; /** * Constructor for the WaveClass @@ -18,7 +13,6 @@ public class WaveClass { public WaveClass(HashMap entities) { this.entities = entities; this.wave = entitiesToWave(); - this.mobIndex = 0; } /** diff --git a/source/core/src/main/com/csse3200/game/components/tasks/waves/WaveTask.java b/source/core/src/main/com/csse3200/game/components/tasks/waves/WaveTask.java index d49816692..04353f589 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/waves/WaveTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/waves/WaveTask.java @@ -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; @@ -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", @@ -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); } /** @@ -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(); @@ -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(); } diff --git a/source/core/src/main/com/csse3200/game/entities/factories/NPCFactory.java b/source/core/src/main/com/csse3200/game/entities/factories/NPCFactory.java index 513f92eeb..cecd77e99 100644 --- a/source/core/src/main/com/csse3200/game/entities/factories/NPCFactory.java +++ b/source/core/src/main/com/csse3200/game/entities/factories/NPCFactory.java @@ -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(); @@ -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 drops = new ArrayList<>(); @@ -396,7 +392,7 @@ public static Entity createNecromancer(int health) { } public static Entity createFirewizard(int health) { - Entity Firewizard = createBaseNPC(); + Entity fireWizard = createBaseNPC(); ArrayList drops = new ArrayList<>(); AnimationRenderComponent animator = @@ -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) { @@ -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()); @@ -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()) @@ -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()) @@ -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); @@ -653,9 +639,6 @@ 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); @@ -663,9 +646,6 @@ public static Entity createDodgingArcaneArcher(int health) { 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 diff --git a/source/core/src/test/com/csse3200/game/components/SplitMoblingsTest.java b/source/core/src/test/com/csse3200/game/components/SplitMoblingsTest.java index 265f1730b..4b1fcf15e 100644 --- a/source/core/src/test/com/csse3200/game/components/SplitMoblingsTest.java +++ b/source/core/src/test/com/csse3200/game/components/SplitMoblingsTest.java @@ -13,6 +13,7 @@ import java.util.ArrayList; import java.util.Arrays; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.extension.ExtendWith; @@ -57,6 +58,7 @@ public void setUp() { ServiceLocator.registerPhysicsService(new PhysicsService()); ServiceLocator.registerEntityService(new EntityService()); + ServiceLocator.registerGameEndService(new GameEndService()); RenderService render = new RenderService(); render.setDebug(mock(DebugRenderer.class)); @@ -67,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(); @@ -79,8 +81,7 @@ public void setUp() { @Test void shouldNotBeNull() { Entity mob = createSplitMob(5); - assertNotNull("Mobling components does not exists", - mob.getComponent(SplitMoblings.class)); + Assertions.assertNotNull(mob.getComponent(SplitMoblings.class), "Mobling components does not exists"); } @Test @@ -94,8 +95,7 @@ void shouldHaveAsset() { if (entity.equals(baseMob) || entity.equals(projectile)) continue; - assertTrue("moblings does not contain the right asset", - ServiceLocator.getResourceService().containsAsset(atlas[0], entity.getClass())); + Assertions.assertTrue(ServiceLocator.getResourceService().containsAsset(atlas[0], entity.getClass()), "moblings does not contain the right asset"); } } diff --git a/source/core/src/test/com/csse3200/game/components/tasks/SpawnWaveTaskTest.java b/source/core/src/test/com/csse3200/game/components/tasks/SpawnWaveTaskTest.java deleted file mode 100644 index 58fb2ae9b..000000000 --- a/source/core/src/test/com/csse3200/game/components/tasks/SpawnWaveTaskTest.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.csse3200.game.components.tasks; - -import com.csse3200.game.ai.tasks.AITaskComponent; -import com.csse3200.game.entities.Entity; -import com.csse3200.game.events.listeners.EventListener0; -import com.csse3200.game.extensions.GameExtension; -import com.csse3200.game.physics.components.PhysicsMovementComponent; -import com.csse3200.game.services.GameTime; -import com.csse3200.game.services.ServiceLocator; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; - -import static org.mockito.Mockito.*; - -@ExtendWith(GameExtension.class) -@ExtendWith(MockitoExtension.class) -class SpawnWaveTaskTest { - - @Test - void shouldTriggerSpawning() { - GameTime time = mock(GameTime.class); - when(time.getTime()).thenReturn(11000L); - ServiceLocator.registerTimeSource(time); - SpawnWaveTask waveTask = new SpawnWaveTask(); - - AITaskComponent aiTaskComponent = new AITaskComponent().addTask(waveTask); - Entity entity = new Entity().addComponent(aiTaskComponent).addComponent(new PhysicsMovementComponent()); - entity.create(); - - // Register callbacks - EventListener0 callback = mock(EventListener0.class); - entity.getEvents().addListener("spawnWave", callback); - - waveTask.update(); - - verify(callback).handle(); - } -} \ No newline at end of file diff --git a/source/core/src/test/com/csse3200/game/entities/factories/WaveFactoryTest.java b/source/core/src/test/com/csse3200/game/entities/factories/WaveFactoryTest.java index eca488c8f..6db312e94 100644 --- a/source/core/src/test/com/csse3200/game/entities/factories/WaveFactoryTest.java +++ b/source/core/src/test/com/csse3200/game/entities/factories/WaveFactoryTest.java @@ -155,7 +155,7 @@ void testLevel1Creation() { if (waveNum != 5) { Set mobNames = new HashSet<>(wave.getEntities().keySet()); Set 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); @@ -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 ++; @@ -207,7 +207,7 @@ void testLevel2Creation() { if (waveNum != 10) { Set mobNames = new HashSet<>(wave.getEntities().keySet()); Set 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); @@ -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 ++; @@ -266,7 +266,7 @@ void testLevel3Creation() { if (waveNum != 15) { Set mobNames = new HashSet<>(wave.getEntities().keySet()); Set 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); @@ -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 ++;