diff --git a/source/core/assets/configs/Boss.json b/source/core/assets/configs/Boss.json index d4b3c32ef..3567235fb 100644 --- a/source/core/assets/configs/Boss.json +++ b/source/core/assets/configs/Boss.json @@ -1,5 +1,5 @@ { - "MobBoss": { + "mobBoss": { "health": 100, "baseAttack": 25, "spookyFactor": 7 diff --git a/source/core/src/main/com/csse3200/game/GdxGame.java b/source/core/src/main/com/csse3200/game/GdxGame.java index 43f525990..8cbb484cb 100644 --- a/source/core/src/main/com/csse3200/game/GdxGame.java +++ b/source/core/src/main/com/csse3200/game/GdxGame.java @@ -3,7 +3,6 @@ import com.badlogic.gdx.Game; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Screen; -import com.csse3200.game.components.CombatStatsComponent; import com.csse3200.game.files.UserSettings; import com.csse3200.game.screens.*; import org.slf4j.Logger; 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 1b07c15f1..8e80cc56d 100644 --- a/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java +++ b/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java @@ -15,7 +15,6 @@ import com.csse3200.game.services.ResourceService; import com.csse3200.game.services.ServiceLocator; import com.csse3200.game.components.gamearea.GameAreaDisplay; -import com.csse3200.game.components.npc.SplitMoblings; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,6 +34,8 @@ public class ForestGameArea extends GameArea { private static final int NUM_MOBBOSS2=3; private static final int NUM_MOBBOSS1=1; + private Random random = new Random(); + private int wave = 0; private Timer waveTimer; @@ -263,12 +264,26 @@ public void create() { // spawnSplitFireWorksFireBall(new Vector2(2, 5), PhysicsLayer.NPC, towardsMobs, new Vector2(2f, 2f), 12); // spawnEffectProjectile(new Vector2(2, 6), PhysicsLayer.NPC, towardsMobs, new Vector2(2f, 2f), ProjectileEffects.SLOW, false); // spawnXenoGrunts(); - spawnWeaponTower(); + // spawnWeaponTower(); // spawnDragonKnight(); - // spawnFireWorm(19, 5); // * TEMPORARY for testing - // spawnSplittingXenoGrunt(17, 5); - spawnDemonBoss(); + spawnFireWorm(19, 5); // * TEMPORARY for testing + spawnFireTowerTowerAt(3, 1); + spawnFireTowerTowerAt(3, 2); + spawnFireTowerTowerAt(3, 3); + spawnFireTowerTowerAt(3, 4); + spawnFireTowerTowerAt(3, 5); + spawnDroidTowerAt(3, 1); + spawnDroidTowerAt(3, 2); + spawnDroidTowerAt(3, 3); + spawnDroidTowerAt(3, 4); + spawnDroidTowerAt(3, 5); + // spawnSplittingXenoGrunt(15, 5); + spawnDeflectXenoGrunt(15, 5); + // spawnSplittingXenoGrunt(15, 4); + // spawnSplittingXenoGrunt(15, 5); + // spawnDodgingDragonKnight(15, 3); + // spawnDemonBoss(); // spawnFireWorm(); //mobBoss1 = spawnMobBoss1(); @@ -315,7 +330,7 @@ private void spawnTerrain() { // Top spawnEntityAt( ObstacleFactory.createWall(worldBounds.x, WALL_WIDTH * 7), - new GridPoint2(0, tileBounds.y - 1), + new GridPoint2(0, tileBounds.y), false, false); // Bottom @@ -421,7 +436,7 @@ private void spawnDemonBoss() { } private Entity spawnMobBoss1() { - int[] pickedLanes = new Random().ints(0, 8) + int[] pickedLanes = random.ints(0, 8) .distinct().limit(5).toArray(); for (int i = 0; i < NUM_MOBBOSS1; i++) { GridPoint2 randomPos = new GridPoint2(19, pickedLanes[i]); @@ -496,12 +511,12 @@ private void spawnProjectile(Vector2 position, short targetLayer, int space, int private void spawnXenoGrunts() { - int[] pickedLanes = new Random().ints(1, 7) + 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]); System.out.println(randomPos); - Entity xenoGrunt = NPCFactory.createXenoGrunt(player); + Entity xenoGrunt = NPCFactory.createXenoGrunt(); xenoGrunt.setScale(1.5f, 1.5f); spawnEntityAt(xenoGrunt, randomPos, true, false); } @@ -512,40 +527,63 @@ 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, false, true); + spawnEntityAt(xenoGrunt, 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 = new Random().ints(1, 7) + 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]); System.out.println(randomPos); - Entity fireWorm = NPCFactory.createFireWorm(player); + Entity fireWorm = NPCFactory.createFireWorm(); fireWorm.setScale(1.5f, 1.5f); spawnEntityAt(fireWorm, randomPos, true, false); } } + // * TEMPORARY FOR TESTING + private void spawnFireWorm(int x, int y) { + GridPoint2 poistion = new GridPoint2(x, y); + Entity fireWorm = NPCFactory.createFireWorm(); + fireWorm.setScale(1.5f, 1.5f); + spawnEntityAt(fireWorm, poistion, true, true); + } 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]); System.out.println(randomPos); - Entity skeleton = NPCFactory.createSkeleton(player); + Entity skeleton = NPCFactory.createSkeleton(); skeleton.setScale(1.5f, 1.5f); spawnEntityAt(skeleton, randomPos, true, false); } } private void spawnDragonKnight() { - int[] pickedLanes = new Random().ints(1, 7) + 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]); System.out.println(randomPos); - Entity fireWorm = NPCFactory.createDragonKnight(player); + Entity fireWorm = NPCFactory.createDragonKnight(); fireWorm.setScale(1.5f, 1.5f); spawnEntityAt(fireWorm, randomPos, true, false); } @@ -556,7 +594,7 @@ private void spawnWizard() { .distinct().limit(5).toArray(); for (int i = 0; i < NUM_GRUNTS; i++) { GridPoint2 randomPos = new GridPoint2(19, pickedLanes[i]); - Entity wizard = NPCFactory.createWizard(player); + Entity wizard = NPCFactory.createWizard(); wizard.setScale(1.5f, 1.5f); spawnEntityAt(wizard, randomPos, true, false); } @@ -567,7 +605,7 @@ private void spawnWaterQueen() { .distinct().limit(5).toArray(); for (int i = 0; i < NUM_GRUNTS; i++) { GridPoint2 randomPos = new GridPoint2(19, pickedLanes[i]); - Entity waterQueen = NPCFactory.createWaterQueen(player); + Entity waterQueen = NPCFactory.createWaterQueen(); waterQueen.setScale(1.5f, 1.5f); spawnEntityAt(waterQueen, randomPos, true, false); } @@ -577,7 +615,7 @@ private void spawnWaterSlime() { .distinct().limit(5).toArray(); for (int i = 0; i < NUM_GRUNTS; i++) { GridPoint2 randomPos = new GridPoint2(19, pickedLanes[i]); - Entity waterSlime = NPCFactory.createWaterSlime(player); + Entity waterSlime = NPCFactory.createWaterSlime(); waterSlime.setScale(1.5f, 1.5f); spawnEntityAt(waterSlime, randomPos, true, false); } @@ -615,7 +653,7 @@ private void spawnWaterSlime() { // } private Entity spawnMobBoss2() { - int[] pickedLanes = new Random().ints(0, 8) + int[] pickedLanes = random.ints(0, 8) .distinct().limit(5).toArray(); for (int i = 0; i < NUM_MOBBOSS2; i++) { GridPoint2 randomPos = new GridPoint2(19, pickedLanes[i]); @@ -717,7 +755,7 @@ 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++) { + for (int i = 0; i < NUM_WEAPON_TOWERS + 10; i++) { GridPoint2 randomPos1 = RandomUtils.random(minPos, maxPos); GridPoint2 randomPos2 = RandomUtils.random(minPos, maxPos); Entity wallTower = TowerFactory.createWallTower(); @@ -727,6 +765,20 @@ private void spawnWeaponTower() { spawnEntityAt(stunTower, randomPos2, true, true); } } + + // * TEMPORARY FOR TESTING + private void spawnFireTowerTowerAt(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); diff --git a/source/core/src/main/com/csse3200/game/components/CombatStatsComponent.java b/source/core/src/main/com/csse3200/game/components/CombatStatsComponent.java index cdf8bacbe..aa5ccc5d5 100644 --- a/source/core/src/main/com/csse3200/game/components/CombatStatsComponent.java +++ b/source/core/src/main/com/csse3200/game/components/CombatStatsComponent.java @@ -6,8 +6,6 @@ import com.csse3200.game.entities.configs.ProjectileConfig; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - - import java.util.ArrayList; import java.util.Currency; import java.util.Random; @@ -41,6 +39,7 @@ public class CombatStatsComponent extends Component { private ArrayList drops; private ArrayList closeRangeAbilities; private ArrayList longRangeAbilities; //TODO change String to Projectiles + private Random rand = new Random(); public CombatStatsComponent(int health, int baseAttack) { setHealth(health); @@ -171,10 +170,9 @@ public void hit(CombatStatsComponent attacker) { } /** - * pick a random number from range 0 to the size of the list provided - * */ + * Picks a random number from range 0 to the size of the list provided. + */ public int pickRandom(ArrayList pickFrom) { - Random rand = new Random(); return rand.nextInt(pickFrom.size()); } diff --git a/source/core/src/main/com/csse3200/game/components/CostComponent.java b/source/core/src/main/com/csse3200/game/components/CostComponent.java index 43cbcbfe1..6d7e5fbeb 100644 --- a/source/core/src/main/com/csse3200/game/components/CostComponent.java +++ b/source/core/src/main/com/csse3200/game/components/CostComponent.java @@ -1,15 +1,10 @@ package com.csse3200.game.components; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * Component used to store information related to cost. * Any entities that necessitate a cost should register an instance of this class. */ public class CostComponent extends Component { - - private int cost; public CostComponent(int cost) { diff --git a/source/core/src/main/com/csse3200/game/components/DeleteOnMapEdgeComponent.java b/source/core/src/main/com/csse3200/game/components/DeleteOnMapEdgeComponent.java index e3e272878..2e6243828 100644 --- a/source/core/src/main/com/csse3200/game/components/DeleteOnMapEdgeComponent.java +++ b/source/core/src/main/com/csse3200/game/components/DeleteOnMapEdgeComponent.java @@ -2,7 +2,6 @@ import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.physics.box2d.Fixture; -import com.csse3200.game.components.tasks.bosstask.DemonBossTask; import com.csse3200.game.entities.Entity; import com.csse3200.game.physics.BodyUserData; import com.csse3200.game.physics.PhysicsLayer; diff --git a/source/core/src/main/com/csse3200/game/components/SplitFireworksComponent.java b/source/core/src/main/com/csse3200/game/components/SplitFireworksComponent.java index 6527271e8..c8a578d88 100644 --- a/source/core/src/main/com/csse3200/game/components/SplitFireworksComponent.java +++ b/source/core/src/main/com/csse3200/game/components/SplitFireworksComponent.java @@ -60,7 +60,7 @@ private void onCollisionEnd(Fixture me, Fixture other) { // * RIGHT NOW TARGET IS NPC, SUBJECT TO CHANGE // Speed is a bit faster than normal but can change. Entity newProjectile = ProjectileFactory.createFireworks(PhysicsLayer.NPC, - new Vector2(100, projectile.getPosition().y + (newDirection - (TOTAL_RANGE/2))), new Vector2(3f, 3f)); + new Vector2(100, (float) (projectile.getPosition().y + (newDirection - (TOTAL_RANGE/2)))), new Vector2(3f, 3f)); newProjectile.setPosition(newXPosition, (float) projectile.getPosition().y); diff --git a/source/core/src/main/com/csse3200/game/components/TouchAttackComponent.java b/source/core/src/main/com/csse3200/game/components/TouchAttackComponent.java index 80c93f434..46ef5ebc9 100644 --- a/source/core/src/main/com/csse3200/game/components/TouchAttackComponent.java +++ b/source/core/src/main/com/csse3200/game/components/TouchAttackComponent.java @@ -3,6 +3,7 @@ import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.physics.box2d.Body; import com.badlogic.gdx.physics.box2d.Fixture; +import com.csse3200.game.components.npc.DeflectingComponent; import com.csse3200.game.entities.Entity; import com.csse3200.game.entities.Weapon; import com.csse3200.game.physics.BodyUserData; @@ -11,12 +12,17 @@ import com.csse3200.game.physics.components.PhysicsComponent; /** - * When this entity touches a valid enemy's hitbox, deal damage to them and apply a knockback. - * Has an optional disposeOnHit property that disposes projectile upon collision. + * When this entity touches a valid enemy's hitbox, deal damage to them and + * apply a knockback. + * Has an optional disposeOnHit property that disposes projectile upon + * collision. * - *

Requires CombatStatsComponent, HitboxComponent on this entity. + *

+ * Requires CombatStatsComponent, HitboxComponent on this entity. * - *

Damage is only applied if target entity has a CombatStatsComponent. Knockback is only applied + *

+ * Damage is only applied if target entity has a CombatStatsComponent. Knockback + * is only applied * if target entity has a PhysicsComponent. */ public class TouchAttackComponent extends Component { @@ -29,6 +35,7 @@ public class TouchAttackComponent extends Component { /** * Create a component which attacks entities on collision, without knockback. + * * @param targetLayer The physics layer of the target's collider. */ public TouchAttackComponent(short targetLayer) { @@ -37,8 +44,9 @@ public TouchAttackComponent(short targetLayer) { /** * Create a component which attacks entities on collision, with knockback. + * * @param targetLayer The physics layer of the target's collider. - * @param knockback The magnitude of the knockback applied to the entity. + * @param knockback The magnitude of the knockback applied to the entity. */ public TouchAttackComponent(short targetLayer, float knockback) { this.targetLayer = targetLayer; @@ -46,9 +54,11 @@ public TouchAttackComponent(short targetLayer, float knockback) { } /** - * Create a component which attacks entities on collision, with knockback and self-dispose. - * @param targetLayer The physics layer of the target's collider. - * @param knockback The magnitude of the knockback applied to the entity. + * Create a component which attacks entities on collision, with knockback and + * self-dispose. + * + * @param targetLayer The physics layer of the target's collider. + * @param knockback The magnitude of the knockback applied to the entity. * @param disposeOnHit Whether this entity should be disposed on hit. */ public TouchAttackComponent(short targetLayer, float knockback, boolean disposeOnHit) { @@ -78,14 +88,21 @@ public void onCollisionStart(Fixture me, Fixture other) { // Try to attack target. Entity target = ((BodyUserData) other.getBody().getUserData()).entity; + + // If enemy has deflecting component, don't delete it. + Component deflectComponent = target.getComponent(DeflectingComponent.class); + if (deflectComponent != null && deflectComponent.enabled) + return; + CombatStatsComponent targetStats = target.getComponent(CombatStatsComponent.class); if (targetStats != null) { - // If entity has abilities, pick one at random and apply it else use baseAttack damage - if (combatStats.getWeapon(target) != null) { - targetStats.hit(combatStats.getWeapon(target).getDamage()); - } else { - targetStats.hit(combatStats.getBaseAttack()); - } + // If entity has abilities, pick one at random and apply it else use baseAttack + // damage + if (combatStats.getWeapon(target) != null) { + targetStats.hit(combatStats.getWeapon(target).getDamage()); + } else { + targetStats.hit(combatStats.getBaseAttack()); + } } // Apply knockback PhysicsComponent physicsComponent = target.getComponent(PhysicsComponent.class); @@ -106,7 +123,6 @@ public void setDisposeOnHit(boolean disposeOnHit) { this.disposeOnHit = disposeOnHit; } - public void setKnockBack(float knockback) { this.knockbackForce = knockback; } @@ -123,6 +139,12 @@ private void onCollisionEnd(Fixture me, Fixture other) { return; } + Entity otherEntity = ((BodyUserData) other.getBody().getUserData()).entity; + + // If enemy has enabled deflection component, don't dispose it. + if (otherEntity.getComponent(DeflectingComponent.class) != null) + return; + if (disposeOnHit) { Entity projectile = ((BodyUserData) me.getBody().getUserData()).entity; projectile.setFlagForDelete(true); @@ -138,5 +160,13 @@ public Weapon chooseWeapon(Fixture other) { return weapon; } + /** + * Sets the target layer of this component, changing which entity to "attack" + * and/or apply knockback to. + * + * @param targetLayer + */ + public void setTargetLayer(short targetLayer) { + this.targetLayer = targetLayer; + } } - diff --git a/source/core/src/main/com/csse3200/game/components/gamearea/CurrencyDisplay.java b/source/core/src/main/com/csse3200/game/components/gamearea/CurrencyDisplay.java index 0b9703a39..5f3a12996 100644 --- a/source/core/src/main/com/csse3200/game/components/gamearea/CurrencyDisplay.java +++ b/source/core/src/main/com/csse3200/game/components/gamearea/CurrencyDisplay.java @@ -1,16 +1,13 @@ package com.csse3200.game.components.gamearea; -import com.badlogic.gdx.Gdx; import com.badlogic.gdx.audio.Sound; import com.badlogic.gdx.graphics.Camera; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.TextureRegion; -import com.badlogic.gdx.math.Interpolation; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector3; -import com.badlogic.gdx.scenes.scene2d.Action; import com.badlogic.gdx.scenes.scene2d.actions.SequenceAction; import com.badlogic.gdx.scenes.scene2d.ui.Label; import com.badlogic.gdx.scenes.scene2d.ui.Table; @@ -18,7 +15,6 @@ import com.badlogic.gdx.scenes.scene2d.utils.Drawable; import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; import com.badlogic.gdx.utils.Align; -import com.csse3200.game.entities.Entity; import com.csse3200.game.services.ServiceLocator; import com.csse3200.game.ui.UIComponent; import com.badlogic.gdx.scenes.scene2d.actions.Actions; diff --git a/source/core/src/main/com/csse3200/game/components/gamearea/GameAreaDisplay.java b/source/core/src/main/com/csse3200/game/components/gamearea/GameAreaDisplay.java index 27ace6b42..83582470b 100644 --- a/source/core/src/main/com/csse3200/game/components/gamearea/GameAreaDisplay.java +++ b/source/core/src/main/com/csse3200/game/components/gamearea/GameAreaDisplay.java @@ -6,24 +6,13 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.math.Vector2; -import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.InputListener; -import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.ui.*; -import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; -import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop; -import com.badlogic.gdx.scenes.scene2d.utils.Drawable; -import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; -import com.badlogic.gdx.utils.Null; -import com.csse3200.game.components.maingame.MainGameExitDisplay; import com.csse3200.game.ui.UIComponent; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.badlogic.gdx.scenes.scene2d.ui.Dialog; -import com.badlogic.gdx.scenes.scene2d.ui.Table; - -import java.util.concurrent.TimeUnit; /** * Displays the name of the current game area. diff --git a/source/core/src/main/com/csse3200/game/components/mainmenu/MainMenuDisplay.java b/source/core/src/main/com/csse3200/game/components/mainmenu/MainMenuDisplay.java index 1a39b08c2..ab941a70a 100644 --- a/source/core/src/main/com/csse3200/game/components/mainmenu/MainMenuDisplay.java +++ b/source/core/src/main/com/csse3200/game/components/mainmenu/MainMenuDisplay.java @@ -8,7 +8,6 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table; import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; -import com.csse3200.game.GdxGame; import com.csse3200.game.services.ServiceLocator; import com.csse3200.game.ui.UIComponent; import org.slf4j.Logger; diff --git a/source/core/src/main/com/csse3200/game/components/npc/DeflectingComponent.java b/source/core/src/main/com/csse3200/game/components/npc/DeflectingComponent.java new file mode 100644 index 000000000..8ebd3c50a --- /dev/null +++ b/source/core/src/main/com/csse3200/game/components/npc/DeflectingComponent.java @@ -0,0 +1,123 @@ +package com.csse3200.game.components.npc; + +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.CombatStatsComponent; +import com.csse3200.game.components.Component; +import com.csse3200.game.components.TouchAttackComponent; +import com.csse3200.game.components.tasks.TrajectTask; +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; + +/** + * A component that deflects incoming projectiles a set amount of projectile + * collision events. + * + * The target layer to be deflected is flexible, meaning it can deflect other + * entities as well, including but not limited to it's own target layer. + *

+ * This class assumes the projectile has only a TrajectTask. If there are + * multiple tasks, the other tasks will be disposed. + *

+ */ +public class DeflectingComponent extends Component { + private short targetLayer; + private short dmgLayer; + private HitboxComponent hitboxComponent; + private int deflectLimitAmount; + private int maxHealth; + + /** + * Initialise a Deflecting component that deflects projectile, reversing the + * incoming direcition of the entity. Any effects, such as damage, will be + * negated when deflected. + * + * The projectile's damage target layer will also be changed. + * + * @param targetLayer Target layer to deflect on + * @param dmgLayer Target layer for the projectile to hit. + * @param deflectLimitAmount Amount of deflections to occur for the disabling of + * this component. + */ + public DeflectingComponent(short targetLayer, short dmgLayer, + int deflectLimitAmount) { + this.targetLayer = targetLayer; + this.dmgLayer = dmgLayer; + this.deflectLimitAmount = deflectLimitAmount; // Assumes deflect amount > 0. + } + + @Override + public void create() { + entity.getEvents().addListener("collisionStart", this::deflectProj); + System.out.println("CREATED"); + hitboxComponent = entity.getComponent(HitboxComponent.class); + maxHealth = entity.getComponent(CombatStatsComponent.class) + .getMaxHealth(); + } + + @Override + public void update() { + resetHealth(); + } + + /** + * Deflects projectile to the opposite direction + * @param me Self entity fixture + * @param other Colliding projectile fixture. + */ + private void deflectProj(Fixture me, Fixture other) { + // If self fixture does not match or the colliding target + if (hitboxComponent.getFixture() != me + || !PhysicsLayer.contains(targetLayer, other.getFilterData().categoryBits)) + return; + + if (deflectLimitAmount-- <= 0) { + entity.getComponent(this.getClass()).setEnabled(false); + // reset health + resetHealth(); + return; + } + + // Obtain projectile entity. + Entity projectile = ((BodyUserData) other.getBody().getUserData()).entity; + + // projectile.getComponent(TouchAttackComponent.class).setEnabled(false); + + // Disposes all tasks for the curr projectile. At this curr time, it assumes + // projectile only has one significant task, and that is the TrajectTask. + projectile.getComponent(AITaskComponent.class).disposeAll(); + + // Obtain current direction of projectile + Vector2 direction = projectile.getComponent( + PhysicsMovementComponent.class).getTarget(); + + // Add new traject task with the target in the opposite x-direction. + projectile.getComponent(AITaskComponent.class) + .addTask(new TrajectTask(new Vector2(-direction.x, direction.y))); + + // Reverse visual image of projectile + Vector2 scale = projectile.getScale(); + projectile.setScale(-scale.x, scale.y); + + // Change target layer of projectile. + projectile.getComponent(TouchAttackComponent.class) + .setTargetLayer(dmgLayer); + + // Make sure projectile is not deleted in the next frame. + projectile.setFlagForDelete(false); + + // Reset health + resetHealth(); + } + + /** + * Reverses the entity's health ater each subsequent collisions. + */ + private void resetHealth() { + entity.getComponent(CombatStatsComponent.class).setHealth(maxHealth); + } +} diff --git a/source/core/src/main/com/csse3200/game/components/npc/DodgingComponent.java b/source/core/src/main/com/csse3200/game/components/npc/DodgingComponent.java new file mode 100644 index 000000000..bada67e3c --- /dev/null +++ b/source/core/src/main/com/csse3200/game/components/npc/DodgingComponent.java @@ -0,0 +1,146 @@ +package com.csse3200.game.components.npc; + +import com.badlogic.gdx.math.Vector2; +import com.csse3200.game.components.Component; +import com.csse3200.game.physics.PhysicsEngine; +import com.csse3200.game.physics.components.PhysicsMovementComponent; +import com.csse3200.game.physics.raycast.RaycastHit; +import com.csse3200.game.services.ServiceLocator; + +/** + * A component that adds a dodging event listener to the current attached + * entity. The entity will dodge another entity that is presumably coming at its + * current position. It will dodge at a certain angle in the vertical direction + * with an altered speed. + *

+ * This component handles the detection of a certain mob layer within a certain + * horizontal range using a raycast. It also handles the vertical speed doding + * configuration. + *

+ * + *

+ * Created for the mob entity to dodge incoming projectiles but can be used for + * other entities and functionalities if needed. + *

+ */ +public class DodgingComponent extends Component { + private final RaycastHit hit = new RaycastHit(); + private short targetLayer; + private float rangeDetection; + private float dodgeSpeed = 1.75f; + // Original entity y's speed + private float originalSpeed; + private PhysicsEngine physics; + + // Sometimes the raycast mechanic doesn't detect the other entity because of the + // target's (or self) collider size does not match. This value makes sure the + // top and bottom detection is also taken care of, ensuring the entity will + // dodge. + private static final float Y_OFFSET_MOB_DETECTION = 0.35f; + + /** + * Initialises a component that dodges an incoming entity based on its target + * layer. The range detection is defaultto 0.25f. + * + * @param targetLayer The target layer to be detected horizontally. + */ + public DodgingComponent(short targetLayer) { + this.targetLayer = targetLayer; + this.rangeDetection = 0.25f; + } + + /** + * Initialises a component that dodges an incoming entity based on its target + * layer. This initialisation also sets the range detection whereby the dodge + * event is triggered. + * + * @param targetLayer The target layer to be detected horizontally. + * @param rangeDetection The range where the entity of the target layer is + * detected, activating the dodge event. + */ + public DodgingComponent(short targetLayer, float rangeDetection) { + this.targetLayer = targetLayer; + this.rangeDetection = rangeDetection; + } + + public DodgingComponent(short targetLayer, float rangeDetection, float dodgeSpeed) { + this.targetLayer = targetLayer; + this.rangeDetection = rangeDetection; + this.dodgeSpeed = dodgeSpeed; + } + + /** + * Called when the entity is created and registered. + * + * Entity created will have the dodge entity event. Also registers the original + * speed of the current entity. + */ + @Override + public void create() { + physics = ServiceLocator.getPhysicsService().getPhysics(); + entity.getEvents().addListener("dodgeIncomingEntity", this::changeTraverseDirection); + originalSpeed = entity.getComponent(PhysicsMovementComponent.class).getSpeed().y; + } + + /** + * Changes the moving direction of the attached entity with this component. + *

+ * Relies heavily on the isTargetVisible() method, and setting the vertical + * angle direction and speed helper methods found in this component class. + *

+ * + * @param mobPos The current Vector2 mob position in the map. + */ + public void changeTraverseDirection(Vector2 mobPos) { + if (isTargetVisible(mobPos)) { + // If mob is in the top half quadrant of the map grid, make the entity dodge + // downwards. + setVerticalAngleDirection(mobPos.y > 3.5 ? mobPos.y - 15 : mobPos.y + 15); + setVerticalSpeed(dodgeSpeed); + } else { + setVerticalAngleDirection(mobPos.y); + setVerticalSpeed(originalSpeed); + } + } + + /** + * Detects if the a target is visible based on the range detection, current + * Vector2 position of the mob and the target layer initialised with this class. + * + * @param mobPos The current Vector2 position of the mob + * @return True if a target is visible, false otherwise. + */ + private boolean isTargetVisible(Vector2 mobPos) { + Vector2 maxRange = new Vector2(mobPos.x - rangeDetection, mobPos.y); + // check also the upper and lower boundaries of the mob with the offset y mob + // detection. + Vector2 upperYMaxRangePos = new Vector2(mobPos.x - 3, mobPos.y - Y_OFFSET_MOB_DETECTION); + Vector2 lowerYMaxRangePos = new Vector2(mobPos.x - 3, mobPos.y + Y_OFFSET_MOB_DETECTION); + + // Raycast the upper, middle and lower detection range. + return physics.raycast(mobPos, maxRange, targetLayer, hit) + || physics.raycast(mobPos, upperYMaxRangePos, targetLayer, hit) + || physics.raycast(mobPos, lowerYMaxRangePos, targetLayer, hit); + } + + /** + * Sets vertical direction of the moving entity based on a float value. This + * method alters the setaTarget method in the PhysicsMovementComponent of the + * entity. + * + * @param y A float value that alters the moving direction of the entity. + */ + private void setVerticalAngleDirection(float y) { + entity.getComponent(PhysicsMovementComponent.class).setTarget(new Vector2(0, y)); + } + + /** + * Sets the vertical speed of the entity based on a float value. This method + * alters the setSpeed method in the PhysicsMovementComponent of the entity. + * + * @param y Float value that alters the entity's vertical movement speed. + */ + private void setVerticalSpeed(float y) { + entity.getComponent(PhysicsMovementComponent.class).setSpeed(new Vector2(1f, y)); + } +} 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 16b54161a..4a34b95ee 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 @@ -7,7 +7,7 @@ /** * A component that splits the target mob entity into multiple entities after - * after the mob dies. This class adds a method to the exisiting event listener + * after the mob dies. This class adds a method to the existing event listener * "dieStart". *

* Amount of moblings spawned must be provided in the construcor. @@ -119,7 +119,7 @@ private void onDeath() { */ public void spawnAdditionalMob(float positionX, float positionY, float initialScaleX, float initialScaleY) { // ? ENTITY PARAM KINDA USELESS? - Entity xenoGrunt = NPCFactory.createXenoGrunt(new Entity()); + Entity xenoGrunt = NPCFactory.createXenoGrunt(); xenoGrunt.setPosition(positionX, positionY); xenoGrunt.setScale(initialScaleX * scaleX, initialScaleY * scaleY); diff --git a/source/core/src/main/com/csse3200/game/components/projectile/OnCollisionAnimationController.java b/source/core/src/main/com/csse3200/game/components/projectile/OnCollisionAnimationController.java index 7efbfa55d..33a9bc183 100644 --- a/source/core/src/main/com/csse3200/game/components/projectile/OnCollisionAnimationController.java +++ b/source/core/src/main/com/csse3200/game/components/projectile/OnCollisionAnimationController.java @@ -1,7 +1,6 @@ package com.csse3200.game.components.projectile; import com.csse3200.game.components.Component; -import com.csse3200.game.rendering.AnimationRenderComponent; import com.csse3200.game.services.ServiceLocator; import com.badlogic.gdx.audio.Sound; diff --git a/source/core/src/main/com/csse3200/game/components/tasks/CurrencyTask.java b/source/core/src/main/com/csse3200/game/components/tasks/CurrencyTask.java index f2c8ede84..c9e21d846 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/CurrencyTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/CurrencyTask.java @@ -9,8 +9,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.concurrent.TimeUnit; - /** * The CurrencyTask updates the in-game currency based on time intervals. */ diff --git a/source/core/src/main/com/csse3200/game/components/tasks/MobAttackTask.java b/source/core/src/main/com/csse3200/game/components/tasks/MobAttackTask.java index ba6d09c4b..894e98c7c 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/MobAttackTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/MobAttackTask.java @@ -14,7 +14,6 @@ import com.csse3200.game.physics.components.HitboxComponent; import com.csse3200.game.physics.components.PhysicsMovementComponent; import com.csse3200.game.physics.raycast.RaycastHit; -import com.csse3200.game.rendering.AnimationRenderComponent; import com.csse3200.game.services.GameTime; import com.csse3200.game.services.ServiceLocator; @@ -132,10 +131,10 @@ public void updateMobState() { attackComp.onCollisionStart(hitboxComp.getFixture(), target); this.owner.getEntity().getEvents().trigger("meleeStart"); } else { - Entity newProjectile = ProjectileFactory.createMobBall(PhysicsLayer.HUMANS, new Vector2(0, owner.getEntity().getPosition().y), new Vector2(2f,2f)); - newProjectile.setPosition((float) (owner.getEntity().getPosition().x), (float) (owner.getEntity().getPosition().y)); - newProjectile.setScale(-1f, 1f); - ServiceLocator.getEntityService().register(newProjectile); + // Entity newProjectile = ProjectileFactory.createMobBall(PhysicsLayer.HUMANS, new Vector2(0, owner.getEntity().getPosition().y), new Vector2(2f,2f)); + // newProjectile.setPosition((float) (owner.getEntity().getPosition().x), (float) (owner.getEntity().getPosition().y)); + // newProjectile.setScale(-1f, 1f); + // ServiceLocator.getEntityService().register(newProjectile); // System.out.printf("ANIMATION: " + owner.getEntity().getComponent(AnimationRenderComponent.class).getCurrentAnimation() + "\n"); this.owner.getEntity().getEvents().trigger(FIRING); diff --git a/source/core/src/main/com/csse3200/game/components/tasks/MobDeathTask.java b/source/core/src/main/com/csse3200/game/components/tasks/MobDeathTask.java index 124151714..615f0e1ff 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/MobDeathTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/MobDeathTask.java @@ -4,10 +4,8 @@ import com.csse3200.game.ai.tasks.PriorityTask; import com.csse3200.game.components.CombatStatsComponent; import com.badlogic.gdx.math.Vector2; -import com.csse3200.game.currency.Currency; import com.csse3200.game.entities.Entity; import com.csse3200.game.entities.factories.DropFactory; -import com.csse3200.game.entities.factories.ProjectileFactory; import com.csse3200.game.physics.PhysicsEngine; import com.csse3200.game.physics.raycast.RaycastHit; import com.csse3200.game.services.ServiceLocator; diff --git a/source/core/src/main/com/csse3200/game/components/tasks/MobDodgeTask.java b/source/core/src/main/com/csse3200/game/components/tasks/MobDodgeTask.java new file mode 100644 index 000000000..d7c1f546f --- /dev/null +++ b/source/core/src/main/com/csse3200/game/components/tasks/MobDodgeTask.java @@ -0,0 +1,76 @@ +package com.csse3200.game.components.tasks; + +import com.badlogic.gdx.math.Vector2; +import com.csse3200.game.services.GameTime; +import com.csse3200.game.services.ServiceLocator; + +/** + * This task runs the AI that adds a dodge mechanic/functionality for the mobs + * in the MobsFactory. Inherits from the MobWanderTask that handles the death + * and movement mechanics of the entity. + *

+ * Relies heavily on the attached DodgingComponent + * that adds the + * "dodgeIncomingEntity" event to the attached entity. + *

+ */ +public class MobDodgeTask extends MobWanderTask { + + private final int priority; // active priority + + private GameTime timeSource; + private long endTime; + + // Helps task wait between each interval. + private final int DELAY_INTERVAL = 500; + + /** + * Initialises a mob dodge task with a specified wander range, wait time, and + * priority level. + * + * @param wanderRange Distance in X and Y the entity can move from its position + * when start() is + * called. + * @param waitTime How long in seconds to wait between wandering. + * @param priority Priority level compared to other added tasks. + */ + public MobDodgeTask(Vector2 wanderRange, float waitTime, int priority) { + super(wanderRange, waitTime); + this.priority = priority; + + timeSource = ServiceLocator.getTimeSource(); + } + + /** + * Start running the task. Usually called by the AI controller. + */ + @Override + public void start() { + super.start(); + owner.getEntity().getEvents().trigger("wanderStart"); + + endTime = timeSource.getTime() + (1 * DELAY_INTERVAL); + } + + /** + * Run a frame of the task. In this extension of the update(), the + * "dodgeIncomingEntity" event will be detected and triggered on set intervals. + */ + @Override + public void update() { + super.update(); + if (timeSource.getTime() >= endTime) { + owner.getEntity().getEvents().trigger("dodgeIncomingEntity", owner.getEntity().getCenterPosition()); + endTime = timeSource.getTime() + (1 * DELAY_INTERVAL); + } + + } + + /** + * Returns the priority level of this dodge task initialised in the constructor. + */ + @Override + public int getPriority() { + return priority; + } +} diff --git a/source/core/src/main/com/csse3200/game/components/tasks/TowerCombatTask.java b/source/core/src/main/com/csse3200/game/components/tasks/TowerCombatTask.java index f986f9667..9d1f74538 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/TowerCombatTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/TowerCombatTask.java @@ -3,7 +3,6 @@ import com.badlogic.gdx.math.Vector2; import com.csse3200.game.ai.tasks.DefaultTask; import com.csse3200.game.ai.tasks.PriorityTask; -import com.csse3200.game.components.ProjectileEffects; import com.csse3200.game.entities.Entity; import com.csse3200.game.entities.factories.ProjectileFactory; import com.csse3200.game.physics.PhysicsEngine; diff --git a/source/core/src/main/com/csse3200/game/components/tasks/bosstask/DemonBossTask.java b/source/core/src/main/com/csse3200/game/components/tasks/bosstask/DemonBossTask.java index 0445b912d..a57b1f3c8 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/bosstask/DemonBossTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/bosstask/DemonBossTask.java @@ -24,7 +24,7 @@ /** * The AI Task for the demon boss entity. The demon boss will first play its transform animation * before beginning its sequence. Its sequence is based on its state and the different game - * scenarios that happen in game dictate its states. + * scenarios that happen in game dictate its state. */ public class DemonBossTask extends DefaultTask implements PriorityTask { @@ -72,7 +72,7 @@ public class DemonBossTask extends DefaultTask implements PriorityTask { private int deathCounter = 0; /** - * The different demon states + * The different demon states. */ private enum DemonState { TRANSFORM, IDLE, CAST, CLEAVE, DEATH, BREATH, SMASH, TAKE_HIT, @@ -81,7 +81,7 @@ private enum DemonState { } /** - * The demon boss task constructor + * The demon boss task constructor. Initialises the physics and time. */ public DemonBossTask() { physics = ServiceLocator.getPhysicsService().getPhysics(); @@ -89,8 +89,8 @@ public DemonBossTask() { } /** - * Starts transform animation, triggers idle animation which starts sequence, and dynamically - * shifts the demons boundary to the left + * Starts transform animation, triggers idle animation which starts + * sequence, and dynamically shifts the demons boundary to the left. */ @Override public void start() { @@ -121,8 +121,8 @@ public void run() { } /** - * Is called every frame and is responsible for updating the animation and position and - * detecting and updating the state scenarios + * This function is called every frame and is responsible for updating the + * animation, the position and the state scenarios. */ @Override public void update() { @@ -157,7 +157,7 @@ public void update() { halfHealthFlag = true; } - // detect sequence changes and run accordingly + // detect sequence changes and runs the relevant state accordingly switch (state) { case IDLE -> jump(getJumpPos()); case SMASH -> { @@ -213,7 +213,8 @@ public void update() { } /** - * Changes the state of the demon + * Changes the state of the demon. + * * @param state state to be changed to */ private void changeState(DemonState state) { @@ -222,7 +223,7 @@ private void changeState(DemonState state) { } /** - * Changes the animation of the demon if a state change occurs + * Changes the animation of the demon if a state change occurs. */ private void animate() { // Check if same animation is being called @@ -252,6 +253,8 @@ private void animate() { } /** + * Returns the priority of this task. + * * @return priority of task */ @Override @@ -260,6 +263,8 @@ public int getPriority() { } /** + * Returns a list of nearby entities with PhysicsLayer.HUMAN. + * * @return nearby entities with the PhysicsLayer of HUMAN */ private Array getNearbyHumans(int radius) { @@ -275,7 +280,7 @@ private Array getNearbyHumans(int radius) { break; } - // target layer check + // check target layer if (!PhysicsLayer.contains(PhysicsLayer.HUMANS, targetHitbox. getLayer())) { break; @@ -287,7 +292,8 @@ private Array getNearbyHumans(int radius) { } /** - * Changes state of demon and moves it to the desired position + * Changes state of demon and moves it to the desired position. + * * @param finalPos position for demon to jump to */ private void jump(Vector2 finalPos) { @@ -302,6 +308,8 @@ private void jump(Vector2 finalPos) { } /** + * Returns a a random position 3 units away for the demon to jump to. + * * @return a position 3 units away from the demon to jump to */ private Vector2 getJumpPos() { @@ -331,6 +339,8 @@ private Vector2 getJumpPos() { } /** + * Returns a boolean to confirm whether the demon has completed a jump or not. + * * @return if demon has completed jump or not */ private boolean jumpComplete() { @@ -344,7 +354,8 @@ private boolean jumpComplete() { } /** - * Changes current breath attack with the given parameters + * Changes current breath attack with the given parameters. + * * @param numBalls numbers of projectiles to be fired * @param effect effect the projectile will apply * @param aoe whether the effect will be applied in a radius or not @@ -356,7 +367,7 @@ public void changeBreathAttack(int numBalls, ProjectileEffects effect, boolean a } /** - * Fire breath attack that launches an amount of projectiles with a given effect at the humans + * Fire breath attack that launches an amount of projectiles with a given effect at the humans. */ private void fireBreath() { changeState(DemonState.BREATH); @@ -390,7 +401,8 @@ public void run() { } /** - * Applies aoe damage to nearby human entities + * Applies aoe damage to nearby human entities. + * * @param targets array of human entities to deal damage to */ private void applyAoeDamage(Array targets, int damage) { @@ -406,7 +418,8 @@ private void applyAoeDamage(Array targets, int damage) { } /** - * Return closest entity given an array of human entities + * Returns the closest human entity from a given array. + * * @param targets array of human entities * @return closest human entity */ @@ -428,7 +441,7 @@ private Entity getClosestHuman(Array targets) { } /** - * Change state to cleave and deal damage to target + * Change state to cleave and deals damage to target. */ private void cleave() { changeState(DemonState.CLEAVE); @@ -444,7 +457,7 @@ public void run() { } /** - * Find the closest human entity and start moving towards them + * Find the closest human entity and start moving towards them. */ private void seekAndDestroy() { Entity targetEntity = getClosestHuman(getNearbyHumans(20)); @@ -461,6 +474,9 @@ private void seekAndDestroy() { } /** + * Returns a boolean that indicates whether the demon entity has reached the + * target. + * * @return if target has been reached or not */ private boolean targetFound() { @@ -468,7 +484,8 @@ private boolean targetFound() { } /** - * When at half health demon starts healing by a certain amount every second + * When at half health, demon starts healing by a certain amount every 10 + * seconds. */ private void halfHealth() { changeState(DemonState.CAST); diff --git a/source/core/src/main/com/csse3200/game/components/tasks/bosstask/FinalBossMovementTask.java b/source/core/src/main/com/csse3200/game/components/tasks/bosstask/FinalBossMovementTask.java index 213cdbc9a..3cdf87858 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/bosstask/FinalBossMovementTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/bosstask/FinalBossMovementTask.java @@ -120,7 +120,7 @@ private void startSwappingLane() { currentTask.stop(); - float laneHeight = viewportHeight / 8; + float laneHeight = (float) (viewportHeight / 8); if (currLane == 0) { // Move up 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 337218153..a6894551f 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 @@ -3,7 +3,6 @@ import com.badlogic.gdx.math.Vector2; import com.csse3200.game.ai.tasks.DefaultTask; import com.csse3200.game.ai.tasks.PriorityTask; -import com.csse3200.game.components.CombatStatsComponent; import com.csse3200.game.entities.Entity; import com.csse3200.game.entities.factories.ProjectileFactory; import com.csse3200.game.physics.PhysicsEngine; diff --git a/source/core/src/main/com/csse3200/game/components/tower/EconTowerAnimationController.java b/source/core/src/main/com/csse3200/game/components/tower/EconTowerAnimationController.java index 8d9f9c03c..3fcd566f5 100644 --- a/source/core/src/main/com/csse3200/game/components/tower/EconTowerAnimationController.java +++ b/source/core/src/main/com/csse3200/game/components/tower/EconTowerAnimationController.java @@ -1,9 +1,7 @@ package com.csse3200.game.components.tower; -import com.badlogic.gdx.audio.Sound; import com.csse3200.game.components.Component; import com.csse3200.game.rendering.AnimationRenderComponent; -import com.csse3200.game.services.ServiceLocator; /** * Listens for events relevant to a weapon tower state. diff --git a/source/core/src/main/com/csse3200/game/components/tower/FireTowerAnimationController.java b/source/core/src/main/com/csse3200/game/components/tower/FireTowerAnimationController.java index 6753b6ba1..0bfe1fe11 100644 --- a/source/core/src/main/com/csse3200/game/components/tower/FireTowerAnimationController.java +++ b/source/core/src/main/com/csse3200/game/components/tower/FireTowerAnimationController.java @@ -39,21 +39,21 @@ public void create() { } /** - * Starts the idle animation + * Starts the idle animation. */ void animateIdle() { animator.startAnimation(IDLE_ANIM); } /** - * starts the prep_attack animation + * Starts the prep_attack animation. */ void animatePrepAttack() { animator.startAnimation(PREP_ATTACK_ANIM); } /** - * starts the attack animation + * Starts the attack animation. */ void animateAttack() { animator.startAnimation(ATTACK_ANIM); diff --git a/source/core/src/main/com/csse3200/game/components/tower/TNTDamageComponent.java b/source/core/src/main/com/csse3200/game/components/tower/TNTDamageComponent.java index ece920971..775653651 100644 --- a/source/core/src/main/com/csse3200/game/components/tower/TNTDamageComponent.java +++ b/source/core/src/main/com/csse3200/game/components/tower/TNTDamageComponent.java @@ -4,11 +4,8 @@ import com.badlogic.gdx.physics.box2d.Body; import com.badlogic.gdx.physics.box2d.Fixture; import com.badlogic.gdx.utils.Array; -import com.csse3200.game.ai.tasks.AITaskComponent; import com.csse3200.game.components.CombatStatsComponent; import com.csse3200.game.components.Component; -import com.csse3200.game.components.maingame.MainGameActions; -import com.csse3200.game.components.tasks.WaitTask; import com.csse3200.game.entities.Entity; import com.csse3200.game.physics.BodyUserData; import com.csse3200.game.physics.PhysicsLayer; @@ -16,8 +13,6 @@ import com.csse3200.game.physics.components.PhysicsComponent; import com.csse3200.game.physics.components.PhysicsMovementComponent; import com.csse3200.game.services.ServiceLocator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * Class responsible for applying damage and knock-back to nearby entities when triggered. diff --git a/source/core/src/main/com/csse3200/game/components/tower/TowerUpgraderComponent.java b/source/core/src/main/com/csse3200/game/components/tower/TowerUpgraderComponent.java index 07ead7edc..bc04c1d1d 100644 --- a/source/core/src/main/com/csse3200/game/components/tower/TowerUpgraderComponent.java +++ b/source/core/src/main/com/csse3200/game/components/tower/TowerUpgraderComponent.java @@ -2,7 +2,6 @@ import com.csse3200.game.components.CombatStatsComponent; import com.csse3200.game.components.Component; -import static java.lang.Math.round; /** * Listens for an event from the popup menu to upgrade diff --git a/source/core/src/main/com/csse3200/game/currency/Currency.java b/source/core/src/main/com/csse3200/game/currency/Currency.java index e1d5b3438..81820ad5f 100644 --- a/source/core/src/main/com/csse3200/game/currency/Currency.java +++ b/source/core/src/main/com/csse3200/game/currency/Currency.java @@ -1,6 +1,5 @@ package com.csse3200.game.currency; -import com.csse3200.game.entities.Entity; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/source/core/src/main/com/csse3200/game/entities/EntityService.java b/source/core/src/main/com/csse3200/game/entities/EntityService.java index bafc5bfde..8dc3bb6a0 100644 --- a/source/core/src/main/com/csse3200/game/entities/EntityService.java +++ b/source/core/src/main/com/csse3200/game/entities/EntityService.java @@ -2,17 +2,9 @@ import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.Array; -import com.badlogic.gdx.graphics.Camera; -import com.badlogic.gdx.math.Vector3; -import com.badlogic.gdx.utils.Array; -import com.csse3200.game.components.npc.DropComponent; -import com.csse3200.game.input.DropInputComponent; -import com.csse3200.game.rendering.RenderService; import com.csse3200.game.services.ServiceLocator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - -import java.security.Provider; import java.util.Comparator; /** diff --git a/source/core/src/main/com/csse3200/game/entities/Melee.java b/source/core/src/main/com/csse3200/game/entities/Melee.java index cae030e08..520aebf09 100644 --- a/source/core/src/main/com/csse3200/game/entities/Melee.java +++ b/source/core/src/main/com/csse3200/game/entities/Melee.java @@ -1,7 +1,5 @@ package com.csse3200.game.entities; -import java.util.ArrayList; - /** * Melee is a Weapon which has a minimum range to be used at * diff --git a/source/core/src/main/com/csse3200/game/entities/PredefinedWeapons.java b/source/core/src/main/com/csse3200/game/entities/PredefinedWeapons.java index 5955f34f6..78dfffdd2 100644 --- a/source/core/src/main/com/csse3200/game/entities/PredefinedWeapons.java +++ b/source/core/src/main/com/csse3200/game/entities/PredefinedWeapons.java @@ -1,6 +1,5 @@ package com.csse3200.game.entities; -import com.csse3200.game.entities.configs.NPCConfigs; import com.csse3200.game.entities.configs.ProjectileConfig; public class PredefinedWeapons { diff --git a/source/core/src/main/com/csse3200/game/entities/configs/NPCConfigs.java b/source/core/src/main/com/csse3200/game/entities/configs/NPCConfigs.java index fe4b6e8cf..8faed4421 100644 --- a/source/core/src/main/com/csse3200/game/entities/configs/NPCConfigs.java +++ b/source/core/src/main/com/csse3200/game/entities/configs/NPCConfigs.java @@ -23,6 +23,6 @@ public class NPCConfigs { new ArrayList(), 10); - public MobBossConfigs MobBoss = new MobBossConfigs(); + public MobBossConfigs mobBoss = new MobBossConfigs(); } diff --git a/source/core/src/main/com/csse3200/game/entities/factories/DropFactory.java b/source/core/src/main/com/csse3200/game/entities/factories/DropFactory.java index b8144b52e..d18942372 100644 --- a/source/core/src/main/com/csse3200/game/entities/factories/DropFactory.java +++ b/source/core/src/main/com/csse3200/game/entities/factories/DropFactory.java @@ -2,10 +2,8 @@ import com.csse3200.game.components.npc.DropComponent; import com.csse3200.game.currency.Crystal; -import com.csse3200.game.currency.Currency; import com.csse3200.game.currency.Scrap; import com.csse3200.game.entities.Entity; -import com.csse3200.game.input.DropInputComponent; import com.csse3200.game.rendering.TextureRenderComponent; public class DropFactory { diff --git a/source/core/src/main/com/csse3200/game/entities/factories/MobBossFactory.java b/source/core/src/main/com/csse3200/game/entities/factories/MobBossFactory.java index 049b12e02..252408258 100644 --- a/source/core/src/main/com/csse3200/game/entities/factories/MobBossFactory.java +++ b/source/core/src/main/com/csse3200/game/entities/factories/MobBossFactory.java @@ -31,12 +31,12 @@ public class MobBossFactory { // Create Demon Boss public static Entity createDemonBoss() { - MobBossConfigs config = configs.MobBoss; Entity demon = createBaseBoss(); // Animation addition AnimationRenderComponent animator = new AnimationRenderComponent( - ServiceLocator.getResourceService().getAsset("images/mobboss/demon.atlas", TextureAtlas.class)); + ServiceLocator.getResourceService() + .getAsset("images/mobboss/demon.atlas", TextureAtlas.class)); animator.addAnimation("demon_cast_spell", 0.2f, Animation.PlayMode.LOOP); animator.addAnimation("demon_cleave", 0.2f, Animation.PlayMode.NORMAL); animator.addAnimation("demon_death", 0.2f, Animation.PlayMode.NORMAL); @@ -73,7 +73,7 @@ public static Entity createDemonBoss() { // Create Boss King 1 public static Entity createMobBoss1(int numLane) { - MobBossConfigs config = configs.MobBoss; + MobBossConfigs config = configs.mobBoss; Entity mobBoss1 = createBaseBoss(); AITaskComponent aiTaskComponent1 = new AITaskComponent() @@ -98,7 +98,7 @@ public static Entity createMobBoss1(int numLane) { // Create Boss King 2 public static Entity createMobBoss2() { - MobBossConfigs config = configs.MobBoss; + MobBossConfigs config = configs.mobBoss; Entity mobBoss2 = createBaseBoss(); AITaskComponent aiTaskComponent2 = new AITaskComponent() 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 f5948ca77..e0483883c 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 @@ -6,6 +6,8 @@ import com.csse3200.game.ai.tasks.AITaskComponent; import com.csse3200.game.components.CombatStatsComponent; import com.csse3200.game.components.TouchAttackComponent; +import com.csse3200.game.components.npc.DeflectingComponent; +import com.csse3200.game.components.npc.DodgingComponent; import com.csse3200.game.components.npc.DragonKnightAnimationController; import com.csse3200.game.components.npc.FireWormAnimationController; import com.csse3200.game.components.npc.GhostAnimationController; @@ -16,6 +18,7 @@ import com.csse3200.game.components.npc.WizardAnimationController; import com.csse3200.game.components.npc.XenoAnimationController; import com.csse3200.game.components.tasks.MobAttackTask; +import com.csse3200.game.components.tasks.MobDodgeTask; import com.csse3200.game.components.tasks.MobShootTask; import com.csse3200.game.components.tasks.MobWanderTask; import com.csse3200.game.components.tasks.NewMobWanderTask; @@ -55,11 +58,10 @@ public class NPCFactory { /** * Creates a ghost entity. * - * @param target entity to chase * @return entity */ - public static Entity createGhost(Entity target) { - Entity ghost = createBaseNPC(target); + public static Entity createGhost() { + Entity ghost = createBaseNPC(); BaseEntityConfig config = configs.ghost; /** AnimationRenderComponent animator = @@ -80,13 +82,12 @@ public static Entity createGhost(Entity target) { } /** - - Creates a ghost king entity.* - @param target entity to chase - @return entity + * Creates a ghost king entity. + * + * @return entity */ - public static Entity createGhostKing(Entity target) { - Entity ghostKing = createBaseNPC(target); + public static Entity createGhostKing() { + Entity ghostKing = createBaseNPC(); GhostKingConfig config = configs.ghostKing; AnimationRenderComponent animator = @@ -111,8 +112,8 @@ public static Entity createGhostKing(Entity target) { * @param target entity to chase * @return entity */ - public static Entity createSkeleton(Entity target) { - Entity skeleton = createBaseNPC(target); + public static Entity createSkeleton() { + Entity skeleton = createBaseNPC(); BaseEnemyConfig config = configs.xenoGrunt; ArrayList melee = new ArrayList<>(Arrays.asList(PredefinedWeapons.sword, PredefinedWeapons.kick)); // tester projectiles @@ -142,8 +143,8 @@ public static Entity createSkeleton(Entity target) { * @param target entity to chase * @return entity */ - public static Entity createWizard(Entity target) { - Entity wizard = createBaseNPC(target); + public static Entity createWizard() { + Entity wizard = createBaseNPC(); BaseEnemyConfig config = configs.xenoGrunt; ArrayList melee = new ArrayList<>(Arrays.asList(PredefinedWeapons.sword, PredefinedWeapons.kick)); // tester projectiles @@ -172,8 +173,8 @@ public static Entity createWizard(Entity target) { * @param target entity to chase * @return entity */ - public static Entity createWaterQueen(Entity target) { - Entity wizard = createBaseNPC(target); + public static Entity createWaterQueen() { + Entity wizard = createBaseNPC(); BaseEnemyConfig config = configs.xenoGrunt; ArrayList melee = new ArrayList<>(Arrays.asList(PredefinedWeapons.sword, PredefinedWeapons.kick)); // tester projectiles @@ -202,8 +203,8 @@ public static Entity createWaterQueen(Entity target) { * @param target entity to chase * @return entity */ - public static Entity createWaterSlime(Entity target) { - Entity waterSlime = createBaseNPC(target); + public static Entity createWaterSlime() { + Entity waterSlime = createBaseNPC(); BaseEnemyConfig config = configs.xenoGrunt; ArrayList melee = new ArrayList<>(Arrays.asList(PredefinedWeapons.sword, PredefinedWeapons.kick)); // tester projectiles @@ -229,11 +230,10 @@ public static Entity createWaterSlime(Entity target) { /** * Creates a fire worm entity. * - * @param target entity to chase * @return entity */ - public static Entity createFireWorm(Entity target) { - Entity fireWorm = createBaseNPC(target); + public static Entity createFireWorm() { + Entity fireWorm = createBaseNPC(); BaseEnemyConfig config = configs.xenoGrunt; ArrayList melee = new ArrayList<>(Arrays.asList(PredefinedWeapons.sword, PredefinedWeapons.kick)); // tester projectiles @@ -259,11 +259,10 @@ public static Entity createFireWorm(Entity target) { /** * Creates a dragon Knight entity * - * @param target entity to chase * @return entity */ - public static Entity createDragonKnight(Entity target) { - Entity dragonKnight = createBaseNPC(target); + public static Entity createDragonKnight() { + Entity dragonKnight = createBaseNPC(); BaseEnemyConfig config = configs.xenoGrunt; ArrayList melee = new ArrayList<>(Arrays.asList(PredefinedWeapons.sword, PredefinedWeapons.kick)); // tester projectiles @@ -291,11 +290,10 @@ public static Entity createDragonKnight(Entity target) { /** * Creates a xeno grunt entity. * - * @param target entity to chase * @return entity */ - public static Entity createXenoGrunt(Entity target) { - Entity xenoGrunt = createBaseNPC(target); + public static Entity createXenoGrunt() { + Entity xenoGrunt = createBaseNPC(); BaseEnemyConfig config = configs.xenoGrunt; ArrayList melee = new ArrayList<>(Arrays.asList(PredefinedWeapons.sword, PredefinedWeapons.kick)); // tester projectiles @@ -329,7 +327,7 @@ public static Entity createXenoGrunt(Entity target) { * * @return entity */ - public static Entity createBaseNPC(Entity target) { + public static Entity createBaseNPC() { AITaskComponent aiComponent = new AITaskComponent() .addTask(new MobWanderTask(new Vector2(2f, 2f), 2f)) @@ -344,7 +342,6 @@ public static Entity createBaseNPC(Entity target) { .addComponent(new HitboxComponent().setLayer(PhysicsLayer.XENO)) .addComponent(new TouchAttackComponent(PhysicsLayer.HUMANS)) .addComponent(aiComponent); - PhysicsUtils.setScaledCollider(npc, 0.3f, 0.5f); return npc; } @@ -353,14 +350,37 @@ private NPCFactory() { throw new IllegalStateException("Instantiating static util class"); } + // * COW'S TESTING ARENA DONT TOUCH public static Entity createSplittingXenoGrunt() { - Entity splitXenoGrunt = createXenoGrunt(new Entity()) + Entity splitXenoGrunt = createXenoGrunt() // add the scaling yourself. can also scale the X and Y component, // leading to some very interesting mob designs. - .addComponent(new SplitMoblings(7, 2.25f)); - + .addComponent(new SplitMoblings(7, 0.5f)) + .addComponent(new DodgingComponent(PhysicsLayer.PROJECTILE, 0.25f)); + + // * TEMPORARY TESTING FOR PROJECTILE DODGING + splitXenoGrunt.getComponent(AITaskComponent.class).addTask(new MobDodgeTask(new Vector2(2f, 2f), 2f, 5)); return splitXenoGrunt; } + + public static Entity createDodgingDragonKnight() { + Entity fireWorm = createDragonKnight(); + + fireWorm.addComponent(new DodgingComponent(PhysicsLayer.PROJECTILE, 0.25f)); + + fireWorm.getComponent(AITaskComponent.class).addTask(new MobDodgeTask(new Vector2(2f, 2f), 2f, 5)); + + return fireWorm; + } + + public static Entity createDeflectXenoGrunt() { + Entity deflectXenoGrunt = createXenoGrunt(); + deflectXenoGrunt.addComponent(new DeflectingComponent( + PhysicsLayer.PROJECTILE, PhysicsLayer.TOWER, 10)); + + return deflectXenoGrunt; + } + } diff --git a/source/core/src/main/com/csse3200/game/entities/factories/ProjectileFactory.java b/source/core/src/main/com/csse3200/game/entities/factories/ProjectileFactory.java index 8d7f2ec56..ce160b65b 100644 --- a/source/core/src/main/com/csse3200/game/entities/factories/ProjectileFactory.java +++ b/source/core/src/main/com/csse3200/game/entities/factories/ProjectileFactory.java @@ -7,8 +7,6 @@ import com.csse3200.game.components.tasks.TrajectTask; import com.csse3200.game.ai.tasks.AITaskComponent; import com.csse3200.game.components.projectile.*; -import com.csse3200.game.components.tasks.TrajectTask; -import com.csse3200.game.ai.tasks.AITaskComponent; import com.csse3200.game.entities.configs.BaseEntityConfig; import com.csse3200.game.entities.configs.NPCConfigs; import com.csse3200.game.files.FileLoader; diff --git a/source/core/src/main/com/csse3200/game/input/DropInputComponent.java b/source/core/src/main/com/csse3200/game/input/DropInputComponent.java index b923585e3..df9ed2146 100644 --- a/source/core/src/main/com/csse3200/game/input/DropInputComponent.java +++ b/source/core/src/main/com/csse3200/game/input/DropInputComponent.java @@ -1,26 +1,15 @@ package com.csse3200.game.input; - -import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Camera; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector3; import com.csse3200.game.areas.ForestGameArea; -import com.csse3200.game.areas.terrain.TerrainComponent; -import com.csse3200.game.components.CameraComponent; import com.csse3200.game.components.npc.DropComponent; -import com.csse3200.game.currency.Scrap; import com.csse3200.game.entities.Entity; import com.csse3200.game.entities.EntityService; -import com.badlogic.gdx.graphics.OrthographicCamera; -import com.csse3200.game.entities.factories.DropFactory; -import com.csse3200.game.entities.factories.RenderFactory; -import com.csse3200.game.rendering.Renderer; import com.csse3200.game.services.ServiceLocator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - -import java.security.Provider; import java.util.Objects; public class DropInputComponent extends InputComponent { diff --git a/source/core/src/main/com/csse3200/game/physics/PhysicsEngine.java b/source/core/src/main/com/csse3200/game/physics/PhysicsEngine.java index 017b18278..b3d19f499 100644 --- a/source/core/src/main/com/csse3200/game/physics/PhysicsEngine.java +++ b/source/core/src/main/com/csse3200/game/physics/PhysicsEngine.java @@ -10,7 +10,6 @@ import com.csse3200.game.physics.raycast.SingleHitCallback; import com.csse3200.game.services.GameTime; import com.csse3200.game.services.ServiceLocator; -import com.csse3200.game.entities.destructors.ProjectileDestructors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/source/core/src/main/com/csse3200/game/rendering/RenderService.java b/source/core/src/main/com/csse3200/game/rendering/RenderService.java index 2ab46b453..fd2f65097 100644 --- a/source/core/src/main/com/csse3200/game/rendering/RenderService.java +++ b/source/core/src/main/com/csse3200/game/rendering/RenderService.java @@ -1,6 +1,5 @@ package com.csse3200.game.rendering; -import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.utils.Array; diff --git a/source/core/src/main/com/csse3200/game/screens/DesertGameScreen.java b/source/core/src/main/com/csse3200/game/screens/DesertGameScreen.java index 003cd6529..649190860 100644 --- a/source/core/src/main/com/csse3200/game/screens/DesertGameScreen.java +++ b/source/core/src/main/com/csse3200/game/screens/DesertGameScreen.java @@ -1,19 +1,12 @@ package com.csse3200.game.screens; -import com.badlogic.gdx.graphics.Pixmap; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.ScreenAdapter; -import com.badlogic.gdx.graphics.Color; -import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.Texture; -import com.badlogic.gdx.graphics.g2d.BitmapFont; -import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.scenes.scene2d.Stage; -import com.badlogic.gdx.scenes.scene2d.ui.TextButton; -import com.badlogic.gdx.utils.viewport.FitViewport; import com.badlogic.gdx.utils.viewport.ScreenViewport; import com.badlogic.gdx.utils.viewport.Viewport; import com.csse3200.game.GdxGame; @@ -21,26 +14,21 @@ import com.csse3200.game.areas.terrain.TerrainFactory; import com.csse3200.game.components.gamearea.PerformanceDisplay; import com.csse3200.game.components.maingame.MainGameActions; -import com.csse3200.game.components.maingame.MainGameLoseDisplay; import com.csse3200.game.entities.Entity; import com.csse3200.game.entities.EntityService; -import com.csse3200.game.entities.factories.PlayerFactory; import com.csse3200.game.entities.factories.RenderFactory; import com.csse3200.game.input.DropInputComponent; import com.csse3200.game.input.InputComponent; import com.csse3200.game.input.InputDecorator; import com.csse3200.game.input.InputService; -import com.csse3200.game.input.InputService; import com.csse3200.game.physics.PhysicsEngine; import com.csse3200.game.physics.PhysicsService; import com.csse3200.game.rendering.RenderService; import com.csse3200.game.rendering.Renderer; import com.csse3200.game.services.*; -import com.csse3200.game.ui.UIComponent; import com.csse3200.game.ui.terminal.Terminal; import com.csse3200.game.ui.terminal.TerminalDisplay; import com.csse3200.game.components.maingame.MainGameExitDisplay; -import com.csse3200.game.components.gamearea.PerformanceDisplay; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -74,7 +62,7 @@ public DesertGameScreen(GdxGame game) { this.game = game; camera = new OrthographicCamera(); camera.setToOrtho(false, viewportWidth, viewportHeight); - camera.position.set(viewportWidth / 2, viewportHeight / 2, 0); + camera.position.set((float) (viewportWidth / 2), (float) (viewportHeight / 2), 0); batch = new SpriteBatch(); diff --git a/source/core/src/main/com/csse3200/game/screens/IceGameScreen.java b/source/core/src/main/com/csse3200/game/screens/IceGameScreen.java index 1c74fff70..e35c88b85 100644 --- a/source/core/src/main/com/csse3200/game/screens/IceGameScreen.java +++ b/source/core/src/main/com/csse3200/game/screens/IceGameScreen.java @@ -1,19 +1,12 @@ package com.csse3200.game.screens; -import com.badlogic.gdx.graphics.Pixmap; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.ScreenAdapter; -import com.badlogic.gdx.graphics.Color; -import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.Texture; -import com.badlogic.gdx.graphics.g2d.BitmapFont; -import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.scenes.scene2d.Stage; -import com.badlogic.gdx.scenes.scene2d.ui.TextButton; -import com.badlogic.gdx.utils.viewport.FitViewport; import com.badlogic.gdx.utils.viewport.ScreenViewport; import com.badlogic.gdx.utils.viewport.Viewport; import com.csse3200.game.GdxGame; @@ -21,10 +14,8 @@ import com.csse3200.game.areas.terrain.TerrainFactory; import com.csse3200.game.components.gamearea.PerformanceDisplay; import com.csse3200.game.components.maingame.MainGameActions; -import com.csse3200.game.components.maingame.MainGameLoseDisplay; import com.csse3200.game.entities.Entity; import com.csse3200.game.entities.EntityService; -import com.csse3200.game.entities.factories.PlayerFactory; import com.csse3200.game.entities.factories.RenderFactory; import com.csse3200.game.input.DropInputComponent; import com.csse3200.game.input.InputComponent; @@ -35,11 +26,9 @@ import com.csse3200.game.rendering.RenderService; import com.csse3200.game.rendering.Renderer; import com.csse3200.game.services.*; -import com.csse3200.game.ui.UIComponent; import com.csse3200.game.ui.terminal.Terminal; import com.csse3200.game.ui.terminal.TerminalDisplay; import com.csse3200.game.components.maingame.MainGameExitDisplay; -import com.csse3200.game.components.gamearea.PerformanceDisplay; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -73,7 +62,7 @@ public IceGameScreen(GdxGame game) { this.game = game; camera = new OrthographicCamera(); camera.setToOrtho(false, viewportWidth, viewportHeight); - camera.position.set(viewportWidth / 2, viewportHeight / 2, 0); + camera.position.set((float) (viewportWidth / 2), (float) (viewportHeight / 2), 0); batch = new SpriteBatch(); diff --git a/source/core/src/main/com/csse3200/game/screens/LavaGameScreen.java b/source/core/src/main/com/csse3200/game/screens/LavaGameScreen.java index 71aab443b..a0ec8d06f 100644 --- a/source/core/src/main/com/csse3200/game/screens/LavaGameScreen.java +++ b/source/core/src/main/com/csse3200/game/screens/LavaGameScreen.java @@ -1,19 +1,12 @@ package com.csse3200.game.screens; -import com.badlogic.gdx.graphics.Pixmap; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.ScreenAdapter; -import com.badlogic.gdx.graphics.Color; -import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.Texture; -import com.badlogic.gdx.graphics.g2d.BitmapFont; -import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.scenes.scene2d.Stage; -import com.badlogic.gdx.scenes.scene2d.ui.TextButton; -import com.badlogic.gdx.utils.viewport.FitViewport; import com.badlogic.gdx.utils.viewport.ScreenViewport; import com.badlogic.gdx.utils.viewport.Viewport; import com.csse3200.game.GdxGame; @@ -21,26 +14,21 @@ import com.csse3200.game.areas.terrain.TerrainFactory; import com.csse3200.game.components.gamearea.PerformanceDisplay; import com.csse3200.game.components.maingame.MainGameActions; -import com.csse3200.game.components.maingame.MainGameLoseDisplay; import com.csse3200.game.entities.Entity; import com.csse3200.game.entities.EntityService; -import com.csse3200.game.entities.factories.PlayerFactory; import com.csse3200.game.entities.factories.RenderFactory; import com.csse3200.game.input.DropInputComponent; import com.csse3200.game.input.InputComponent; import com.csse3200.game.input.InputDecorator; import com.csse3200.game.input.InputService; -import com.csse3200.game.input.InputService; import com.csse3200.game.physics.PhysicsEngine; import com.csse3200.game.physics.PhysicsService; import com.csse3200.game.rendering.RenderService; import com.csse3200.game.rendering.Renderer; import com.csse3200.game.services.*; -import com.csse3200.game.ui.UIComponent; import com.csse3200.game.ui.terminal.Terminal; import com.csse3200.game.ui.terminal.TerminalDisplay; import com.csse3200.game.components.maingame.MainGameExitDisplay; -import com.csse3200.game.components.gamearea.PerformanceDisplay; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -74,7 +62,7 @@ public LavaGameScreen(GdxGame game) { this.game = game; camera = new OrthographicCamera(); camera.setToOrtho(false, viewportWidth, viewportHeight); - camera.position.set(viewportWidth / 2, viewportHeight / 2, 0); + camera.position.set((float) (viewportWidth / 2), (float) (viewportHeight / 2), 0); batch = new SpriteBatch(); diff --git a/source/core/src/main/com/csse3200/game/screens/LevelSelectScreen.java b/source/core/src/main/com/csse3200/game/screens/LevelSelectScreen.java index 00e7cf234..c92579e5f 100644 --- a/source/core/src/main/com/csse3200/game/screens/LevelSelectScreen.java +++ b/source/core/src/main/com/csse3200/game/screens/LevelSelectScreen.java @@ -9,17 +9,12 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.math.Vector3; -import com.badlogic.gdx.utils.TimeUtils; import com.csse3200.game.GdxGame; -import com.csse3200.game.entities.factories.RenderFactory; -import com.csse3200.game.rendering.Renderer; import com.csse3200.game.screens.text.AnimatedText; -import com.csse3200.game.screens.Planets; import com.csse3200.game.services.GameEndService; import com.csse3200.game.services.ServiceLocator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.w3c.dom.Text; /** * The game screen where you can choose a planet to play on. diff --git a/source/core/src/main/com/csse3200/game/screens/LosingScreen.java b/source/core/src/main/com/csse3200/game/screens/LosingScreen.java index 354046edc..b52e4642b 100644 --- a/source/core/src/main/com/csse3200/game/screens/LosingScreen.java +++ b/source/core/src/main/com/csse3200/game/screens/LosingScreen.java @@ -16,9 +16,6 @@ import com.badlogic.gdx.utils.viewport.ScreenViewport; import com.csse3200.game.GdxGame; import com.csse3200.game.screens.text.AnimatedText; -import com.csse3200.game.services.ServiceLocator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class LosingScreen extends ScreenAdapter { private final GdxGame game; diff --git a/source/core/src/main/com/csse3200/game/screens/MainGameScreen.java b/source/core/src/main/com/csse3200/game/screens/MainGameScreen.java index ab475797f..88b2150e1 100644 --- a/source/core/src/main/com/csse3200/game/screens/MainGameScreen.java +++ b/source/core/src/main/com/csse3200/game/screens/MainGameScreen.java @@ -1,19 +1,12 @@ package com.csse3200.game.screens; -import com.badlogic.gdx.graphics.Pixmap; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.ScreenAdapter; -import com.badlogic.gdx.graphics.Color; -import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.Texture; -import com.badlogic.gdx.graphics.g2d.BitmapFont; -import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.scenes.scene2d.Stage; -import com.badlogic.gdx.scenes.scene2d.ui.TextButton; -import com.badlogic.gdx.utils.viewport.FitViewport; import com.badlogic.gdx.utils.viewport.ScreenViewport; import com.badlogic.gdx.utils.viewport.Viewport; import com.csse3200.game.GdxGame; @@ -24,7 +17,6 @@ import com.csse3200.game.components.maingame.MainGameLoseDisplay; import com.csse3200.game.entities.Entity; import com.csse3200.game.entities.EntityService; -import com.csse3200.game.entities.factories.PlayerFactory; import com.csse3200.game.entities.factories.RenderFactory; import com.csse3200.game.input.DropInputComponent; import com.csse3200.game.input.InputComponent; @@ -35,11 +27,9 @@ import com.csse3200.game.rendering.RenderService; import com.csse3200.game.rendering.Renderer; import com.csse3200.game.services.*; -import com.csse3200.game.ui.UIComponent; import com.csse3200.game.ui.terminal.Terminal; import com.csse3200.game.ui.terminal.TerminalDisplay; import com.csse3200.game.components.maingame.MainGameExitDisplay; -import com.csse3200.game.components.gamearea.PerformanceDisplay; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -77,7 +67,7 @@ public MainGameScreen(GdxGame game) { this.game = game; camera = new OrthographicCamera(); camera.setToOrtho(false, viewportWidth, viewportHeight); - camera.position.set(viewportWidth / 2, viewportHeight / 2, 0); + camera.position.set((float) (viewportWidth / 2), (float) (viewportHeight / 2), 0); batch = new SpriteBatch(); diff --git a/source/core/src/main/com/csse3200/game/screens/StoryScreen.java b/source/core/src/main/com/csse3200/game/screens/StoryScreen.java index 7f81669f9..838401cdd 100644 --- a/source/core/src/main/com/csse3200/game/screens/StoryScreen.java +++ b/source/core/src/main/com/csse3200/game/screens/StoryScreen.java @@ -8,7 +8,6 @@ import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.scenes.scene2d.InputEvent; -import com.badlogic.gdx.utils.TimeUtils; import com.badlogic.gdx.utils.viewport.ScreenViewport; import com.csse3200.game.GdxGame; import com.csse3200.game.screens.text.AnimatedText; diff --git a/source/core/src/main/com/csse3200/game/screens/TurretSelectionScreen.java b/source/core/src/main/com/csse3200/game/screens/TurretSelectionScreen.java index bb2a8a88a..d120d8854 100644 --- a/source/core/src/main/com/csse3200/game/screens/TurretSelectionScreen.java +++ b/source/core/src/main/com/csse3200/game/screens/TurretSelectionScreen.java @@ -13,14 +13,8 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table; import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; -import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.viewport.ScreenViewport; import com.csse3200.game.GdxGame; -import com.csse3200.game.entities.Entity; -import com.csse3200.game.entities.factories.TowerFactory; -import com.csse3200.game.physics.PhysicsService; -import com.csse3200.game.services.ResourceService; -import com.csse3200.game.services.ServiceLocator; import com.badlogic.gdx.scenes.scene2d.ui.Image; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/source/core/src/test/com/csse3200/game/areas/GameAreaTest.java b/source/core/src/test/com/csse3200/game/areas/GameAreaTest.java index 1f3f47b60..3be7a409b 100644 --- a/source/core/src/test/com/csse3200/game/areas/GameAreaTest.java +++ b/source/core/src/test/com/csse3200/game/areas/GameAreaTest.java @@ -3,7 +3,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import com.csse3200.game.areas.terrain.TerrainComponent; import com.csse3200.game.areas.terrain.TerrainFactory; import com.csse3200.game.entities.Entity; import com.csse3200.game.entities.EntityService; diff --git a/source/core/src/test/com/csse3200/game/components/ComponentTest.java b/source/core/src/test/com/csse3200/game/components/ComponentTest.java index 71e9510ad..f92d49c53 100644 --- a/source/core/src/test/com/csse3200/game/components/ComponentTest.java +++ b/source/core/src/test/com/csse3200/game/components/ComponentTest.java @@ -4,7 +4,6 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -import com.csse3200.game.components.Component; import com.csse3200.game.extensions.GameExtension; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/source/core/src/test/com/csse3200/game/components/ComponentTypeTest.java b/source/core/src/test/com/csse3200/game/components/ComponentTypeTest.java index 5e5e35eec..6ed914b71 100644 --- a/source/core/src/test/com/csse3200/game/components/ComponentTypeTest.java +++ b/source/core/src/test/com/csse3200/game/components/ComponentTypeTest.java @@ -2,8 +2,6 @@ import static org.junit.jupiter.api.Assertions.*; -import com.csse3200.game.components.Component; -import com.csse3200.game.components.ComponentType; import com.csse3200.game.extensions.GameExtension; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/source/core/src/test/com/csse3200/game/components/RicochetComponentTest.java b/source/core/src/test/com/csse3200/game/components/RicochetComponentTest.java index dc3aef725..00a16daa3 100644 --- a/source/core/src/test/com/csse3200/game/components/RicochetComponentTest.java +++ b/source/core/src/test/com/csse3200/game/components/RicochetComponentTest.java @@ -19,7 +19,6 @@ import com.csse3200.game.physics.PhysicsService; import com.csse3200.game.physics.components.HitboxComponent; import com.csse3200.game.physics.components.PhysicsComponent; -import com.csse3200.game.physics.components.PhysicsMovementComponent; import com.csse3200.game.rendering.DebugRenderer; import com.csse3200.game.rendering.RenderService; import com.csse3200.game.services.GameTime; diff --git a/source/core/src/test/com/csse3200/game/components/TouchAttackComponentTest.java b/source/core/src/test/com/csse3200/game/components/TouchAttackComponentTest.java index 789fd2434..a584fa211 100644 --- a/source/core/src/test/com/csse3200/game/components/TouchAttackComponentTest.java +++ b/source/core/src/test/com/csse3200/game/components/TouchAttackComponentTest.java @@ -2,21 +2,15 @@ import com.badlogic.gdx.physics.box2d.Fixture; import com.csse3200.game.entities.Entity; -import com.csse3200.game.entities.EntityService; import com.csse3200.game.extensions.GameExtension; import com.csse3200.game.physics.PhysicsService; import com.csse3200.game.physics.components.HitboxComponent; import com.csse3200.game.physics.components.PhysicsComponent; -import com.csse3200.game.services.GameTime; import com.csse3200.game.services.ServiceLocator; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import static org.junit.jupiter.api.Assertions.assertNull; - -import org.junit.Ignore; - import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/source/core/src/test/com/csse3200/game/components/popupmenu/PopupMenuInputComponentTest.java b/source/core/src/test/com/csse3200/game/components/popupmenu/PopupMenuInputComponentTest.java index 9acd1bf7f..556690092 100644 --- a/source/core/src/test/com/csse3200/game/components/popupmenu/PopupMenuInputComponentTest.java +++ b/source/core/src/test/com/csse3200/game/components/popupmenu/PopupMenuInputComponentTest.java @@ -3,7 +3,6 @@ import com.csse3200.game.input.InputService; import com.csse3200.game.services.ServiceLocator; import com.csse3200.game.entities.Entity; -import com.csse3200.game.events.EventHandler; import com.csse3200.game.events.listeners.EventListener0; import com.csse3200.game.extensions.GameExtension; import org.junit.jupiter.api.Test; diff --git a/source/core/src/test/com/csse3200/game/components/tasks/DroidCombatTaskTest.java b/source/core/src/test/com/csse3200/game/components/tasks/DroidCombatTaskTest.java index f03282584..5878ea061 100644 --- a/source/core/src/test/com/csse3200/game/components/tasks/DroidCombatTaskTest.java +++ b/source/core/src/test/com/csse3200/game/components/tasks/DroidCombatTaskTest.java @@ -15,7 +15,6 @@ import com.csse3200.game.physics.components.PhysicsComponent; import com.csse3200.game.services.GameTime; import com.csse3200.game.services.ServiceLocator; -import com.csse3200.game.entities.factories.ProjectileFactory; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; 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 375d7767a..bf638a663 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,13 +1,8 @@ package com.csse3200.game.components.tasks; -import com.badlogic.gdx.audio.Sound; -import com.badlogic.gdx.graphics.Texture; -import com.badlogic.gdx.graphics.g2d.TextureAtlas; import com.csse3200.game.ai.tasks.AITaskComponent; import com.csse3200.game.components.CombatStatsComponent; import com.csse3200.game.components.TouchAttackComponent; -import com.csse3200.game.components.player.HumanAnimationController; -import com.csse3200.game.components.tasks.bosstask.FinalBossMovementTask; import com.csse3200.game.components.tasks.human.EngineerCombatTask; import com.csse3200.game.entities.Entity; import com.csse3200.game.entities.EntityService; @@ -16,27 +11,16 @@ import com.csse3200.game.extensions.GameExtension; import com.csse3200.game.physics.PhysicsLayer; import com.csse3200.game.physics.PhysicsService; -import com.csse3200.game.physics.components.ColliderComponent; import com.csse3200.game.physics.components.HitboxComponent; import com.csse3200.game.physics.components.PhysicsComponent; -import com.csse3200.game.physics.components.PhysicsMovementComponent; -import com.csse3200.game.rendering.AnimationRenderComponent; import com.csse3200.game.rendering.DebugRenderer; import com.csse3200.game.rendering.RenderService; import com.csse3200.game.services.GameTime; import com.csse3200.game.services.ResourceService; import com.csse3200.game.services.ServiceLocator; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - - -import java.util.ArrayList; -import java.util.Objects; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.*; diff --git a/source/core/src/test/com/csse3200/game/components/tasks/FireTowerCombatTaskTest.java b/source/core/src/test/com/csse3200/game/components/tasks/FireTowerCombatTaskTest.java index dc7394399..a2b92d857 100644 --- a/source/core/src/test/com/csse3200/game/components/tasks/FireTowerCombatTaskTest.java +++ b/source/core/src/test/com/csse3200/game/components/tasks/FireTowerCombatTaskTest.java @@ -15,9 +15,7 @@ import com.csse3200.game.physics.components.PhysicsComponent; import com.csse3200.game.services.GameTime; import com.csse3200.game.services.ServiceLocator; -import com.csse3200.game.entities.factories.ProjectileFactory; -import jdk.jfr.Event; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/source/core/src/test/com/csse3200/game/components/tasks/MobAttackTaskTest.java b/source/core/src/test/com/csse3200/game/components/tasks/MobAttackTaskTest.java index 1e45d2c0a..e30c0e30d 100644 --- a/source/core/src/test/com/csse3200/game/components/tasks/MobAttackTaskTest.java +++ b/source/core/src/test/com/csse3200/game/components/tasks/MobAttackTaskTest.java @@ -1,18 +1,7 @@ package com.csse3200.game.components.tasks; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - -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.utils.math.Vector2Utils; -import com.csse3200.game.physics.components.PhysicsMovementComponent; import com.csse3200.game.services.GameTime; -import com.csse3200.game.services.ServiceLocator; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; diff --git a/source/core/src/test/com/csse3200/game/components/tasks/MobWanderTaskTest.java b/source/core/src/test/com/csse3200/game/components/tasks/MobWanderTaskTest.java index 46b2a2ab9..56a4d8bed 100644 --- a/source/core/src/test/com/csse3200/game/components/tasks/MobWanderTaskTest.java +++ b/source/core/src/test/com/csse3200/game/components/tasks/MobWanderTaskTest.java @@ -1,18 +1,9 @@ package com.csse3200.game.components.tasks; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - -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.utils.math.Vector2Utils; -import com.csse3200.game.physics.components.PhysicsMovementComponent; import com.csse3200.game.services.GameTime; import com.csse3200.game.services.ServiceLocator; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; 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 index 55a00537d..58fb2ae9b 100644 --- a/source/core/src/test/com/csse3200/game/components/tasks/SpawnWaveTaskTest.java +++ b/source/core/src/test/com/csse3200/game/components/tasks/SpawnWaveTaskTest.java @@ -4,14 +4,11 @@ import com.csse3200.game.entities.Entity; import com.csse3200.game.events.listeners.EventListener0; import com.csse3200.game.extensions.GameExtension; -import com.csse3200.game.utils.math.Vector2Utils; import com.csse3200.game.physics.components.PhysicsMovementComponent; import com.csse3200.game.services.GameTime; import com.csse3200.game.services.ServiceLocator; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import static org.mockito.Mockito.*; diff --git a/source/core/src/test/com/csse3200/game/components/tasks/StunTowerCombatTaskTest.java b/source/core/src/test/com/csse3200/game/components/tasks/StunTowerCombatTaskTest.java index 37c87158c..dcd668fc0 100644 --- a/source/core/src/test/com/csse3200/game/components/tasks/StunTowerCombatTaskTest.java +++ b/source/core/src/test/com/csse3200/game/components/tasks/StunTowerCombatTaskTest.java @@ -15,9 +15,7 @@ import com.csse3200.game.physics.components.PhysicsComponent; import com.csse3200.game.services.GameTime; import com.csse3200.game.services.ServiceLocator; -import com.csse3200.game.entities.factories.ProjectileFactory; -import jdk.jfr.Event; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/source/core/src/test/com/csse3200/game/components/tasks/WaitTaskTest.java b/source/core/src/test/com/csse3200/game/components/tasks/WaitTaskTest.java index 59e7ea7c8..e758f96ab 100644 --- a/source/core/src/test/com/csse3200/game/components/tasks/WaitTaskTest.java +++ b/source/core/src/test/com/csse3200/game/components/tasks/WaitTaskTest.java @@ -8,7 +8,6 @@ import com.csse3200.game.extensions.GameExtension; import com.csse3200.game.services.GameTime; import com.csse3200.game.services.ServiceLocator; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/source/core/src/test/com/csse3200/game/components/tasks/human/HumanWanderTaskTest.java b/source/core/src/test/com/csse3200/game/components/tasks/human/HumanWanderTaskTest.java index 6e7c9eaeb..a44eb69e1 100644 --- a/source/core/src/test/com/csse3200/game/components/tasks/human/HumanWanderTaskTest.java +++ b/source/core/src/test/com/csse3200/game/components/tasks/human/HumanWanderTaskTest.java @@ -19,7 +19,6 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.junit.jupiter.MockitoExtension; -import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.mock; @ExtendWith(GameExtension.class) diff --git a/source/core/src/test/com/csse3200/game/components/tower/DroidAnimationControllerTest.java b/source/core/src/test/com/csse3200/game/components/tower/DroidAnimationControllerTest.java index 666c9767a..bbae63278 100644 --- a/source/core/src/test/com/csse3200/game/components/tower/DroidAnimationControllerTest.java +++ b/source/core/src/test/com/csse3200/game/components/tower/DroidAnimationControllerTest.java @@ -10,7 +10,6 @@ import com.csse3200.game.rendering.AnimationRenderComponent; import com.csse3200.game.rendering.DebugRenderer; import com.csse3200.game.rendering.RenderService; -import com.csse3200.game.services.GameTime; import com.csse3200.game.services.ResourceService; import com.csse3200.game.services.ServiceLocator; import org.junit.jupiter.api.BeforeEach; diff --git a/source/core/src/test/com/csse3200/game/components/tower/FireTowerAnimationControllerTest.java b/source/core/src/test/com/csse3200/game/components/tower/FireTowerAnimationControllerTest.java index 6f62eb3be..f6d91ddd3 100644 --- a/source/core/src/test/com/csse3200/game/components/tower/FireTowerAnimationControllerTest.java +++ b/source/core/src/test/com/csse3200/game/components/tower/FireTowerAnimationControllerTest.java @@ -10,7 +10,6 @@ import com.csse3200.game.rendering.AnimationRenderComponent; import com.csse3200.game.rendering.DebugRenderer; import com.csse3200.game.rendering.RenderService; -import com.csse3200.game.services.GameTime; import com.csse3200.game.services.ResourceService; import com.csse3200.game.services.ServiceLocator; import org.junit.jupiter.api.BeforeEach; diff --git a/source/core/src/test/com/csse3200/game/components/tower/StunTowerAnimationControllerTest.java b/source/core/src/test/com/csse3200/game/components/tower/StunTowerAnimationControllerTest.java index dbb7df351..478fd7314 100644 --- a/source/core/src/test/com/csse3200/game/components/tower/StunTowerAnimationControllerTest.java +++ b/source/core/src/test/com/csse3200/game/components/tower/StunTowerAnimationControllerTest.java @@ -10,7 +10,6 @@ import com.csse3200.game.rendering.AnimationRenderComponent; import com.csse3200.game.rendering.DebugRenderer; import com.csse3200.game.rendering.RenderService; -import com.csse3200.game.services.GameTime; import com.csse3200.game.services.ResourceService; import com.csse3200.game.services.ServiceLocator; import org.junit.jupiter.api.BeforeEach; diff --git a/source/core/src/test/com/csse3200/game/components/tower/TNTAnimationControllerTest.java b/source/core/src/test/com/csse3200/game/components/tower/TNTAnimationControllerTest.java index bdaa14041..d72dd437e 100644 --- a/source/core/src/test/com/csse3200/game/components/tower/TNTAnimationControllerTest.java +++ b/source/core/src/test/com/csse3200/game/components/tower/TNTAnimationControllerTest.java @@ -3,8 +3,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.*; -import com.badlogic.gdx.graphics.g2d.Animation; -import com.badlogic.gdx.graphics.g2d.TextureAtlas; import com.csse3200.game.entities.Entity; import com.csse3200.game.entities.factories.TowerFactory; import com.csse3200.game.extensions.GameExtension; @@ -12,7 +10,6 @@ import com.csse3200.game.rendering.AnimationRenderComponent; import com.csse3200.game.rendering.DebugRenderer; import com.csse3200.game.rendering.RenderService; -import com.csse3200.game.services.GameTime; import com.csse3200.game.services.ResourceService; import com.csse3200.game.services.ServiceLocator; import org.junit.jupiter.api.BeforeEach; diff --git a/source/core/src/test/com/csse3200/game/components/xenos/XenoAnimationControllerTest.java b/source/core/src/test/com/csse3200/game/components/xenos/XenoAnimationControllerTest.java index b8317ff2f..1a5d50a20 100644 --- a/source/core/src/test/com/csse3200/game/components/xenos/XenoAnimationControllerTest.java +++ b/source/core/src/test/com/csse3200/game/components/xenos/XenoAnimationControllerTest.java @@ -24,7 +24,6 @@ public class XenoAnimationControllerTest { private Entity xenoGrunt; - private Entity target; private final String[] atlas = {"images/mobs/xenoGrunt.atlas"}; @BeforeEach @@ -38,7 +37,7 @@ public void setUp() { resourceService.loadTextureAtlases(atlas); resourceService.loadAll(); - xenoGrunt = NPCFactory.createXenoGrunt(target); // Replace with actual Droid Tower creation logic + xenoGrunt = NPCFactory.createXenoGrunt(); // Replace with actual Droid Tower creation logic xenoGrunt.create(); } diff --git a/source/core/src/test/com/csse3200/game/currency/CurrencyTest.java b/source/core/src/test/com/csse3200/game/currency/CurrencyTest.java index 7ed8a22de..5cb196ff2 100644 --- a/source/core/src/test/com/csse3200/game/currency/CurrencyTest.java +++ b/source/core/src/test/com/csse3200/game/currency/CurrencyTest.java @@ -10,7 +10,6 @@ import com.csse3200.game.services.GameTime; import com.csse3200.game.services.ResourceService; import com.csse3200.game.services.ServiceLocator; -import org.junit.Before; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/source/core/src/test/com/csse3200/game/entities/EntityTest.java b/source/core/src/test/com/csse3200/game/entities/EntityTest.java index 7d4f3bfa9..17b4abcf7 100644 --- a/source/core/src/test/com/csse3200/game/entities/EntityTest.java +++ b/source/core/src/test/com/csse3200/game/entities/EntityTest.java @@ -3,8 +3,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; diff --git a/source/core/src/test/com/csse3200/game/entities/factories/EngineerFactoryTest.java b/source/core/src/test/com/csse3200/game/entities/factories/EngineerFactoryTest.java index d130ae5c7..1a54a0685 100644 --- a/source/core/src/test/com/csse3200/game/entities/factories/EngineerFactoryTest.java +++ b/source/core/src/test/com/csse3200/game/entities/factories/EngineerFactoryTest.java @@ -1,8 +1,5 @@ package com.csse3200.game.entities.factories; -import com.badlogic.gdx.audio.Sound; -import com.badlogic.gdx.graphics.Texture; -import com.badlogic.gdx.graphics.g2d.TextureAtlas; import com.csse3200.game.ai.tasks.AITaskComponent; import com.csse3200.game.components.CombatStatsComponent; import com.csse3200.game.components.TouchAttackComponent; @@ -20,16 +17,9 @@ import com.csse3200.game.services.GameTime; import com.csse3200.game.services.ResourceService; import com.csse3200.game.services.ServiceLocator; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - - -import java.util.ArrayList; import java.util.Objects; import static org.junit.jupiter.api.Assertions.*; diff --git a/source/core/src/test/com/csse3200/game/entities/factories/NPCFactoryTest.java b/source/core/src/test/com/csse3200/game/entities/factories/NPCFactoryTest.java index 9673617c1..906a1a640 100644 --- a/source/core/src/test/com/csse3200/game/entities/factories/NPCFactoryTest.java +++ b/source/core/src/test/com/csse3200/game/entities/factories/NPCFactoryTest.java @@ -65,7 +65,7 @@ public void setUp() { //playerTarget = PlayerFactory.createPlayer(); //towerTarget = TowerFactory.createBaseTower(); //engineerTarget = EngineerFactory.createEngineer(); - xenoGrunt = NPCFactory.createXenoGrunt(playerTarget); + xenoGrunt = NPCFactory.createXenoGrunt(); } @Test diff --git a/source/core/src/test/com/csse3200/game/entities/factories/ProjectileFactoryTest.java b/source/core/src/test/com/csse3200/game/entities/factories/ProjectileFactoryTest.java index 83a6cd08b..74d0c4836 100644 --- a/source/core/src/test/com/csse3200/game/entities/factories/ProjectileFactoryTest.java +++ b/source/core/src/test/com/csse3200/game/entities/factories/ProjectileFactoryTest.java @@ -4,14 +4,8 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import com.badlogic.gdx.assets.AssetManager; -import com.badlogic.gdx.graphics.Texture; -import com.badlogic.gdx.graphics.g2d.Animation; -import com.badlogic.gdx.graphics.g2d.TextureAtlas; import com.badlogic.gdx.math.Vector2; -import com.badlogic.gdx.physics.box2d.BodyDef.BodyType; import com.csse3200.game.components.*; -import com.csse3200.game.components.MobProjectileAnimationController; import com.csse3200.game.components.projectile.*; import com.csse3200.game.entities.Entity; import com.csse3200.game.extensions.GameExtension; @@ -27,14 +21,9 @@ import com.csse3200.game.services.GameTime; import com.csse3200.game.services.ResourceService; import com.csse3200.game.services.ServiceLocator; -import org.junit.Ignore; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mock; - -import java.security.Provider; -import java.util.Arrays; @ExtendWith(GameExtension.class) class ProjectileFactoryTest { diff --git a/source/core/src/test/com/csse3200/game/entities/factories/TowerFactoryTest.java b/source/core/src/test/com/csse3200/game/entities/factories/TowerFactoryTest.java index 1ab5d51cc..4d6188c88 100644 --- a/source/core/src/test/com/csse3200/game/entities/factories/TowerFactoryTest.java +++ b/source/core/src/test/com/csse3200/game/entities/factories/TowerFactoryTest.java @@ -4,9 +4,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import com.badlogic.gdx.assets.AssetManager; -import com.badlogic.gdx.graphics.Texture; -import com.badlogic.gdx.graphics.g2d.Animation; import com.badlogic.gdx.graphics.g2d.TextureAtlas; import com.badlogic.gdx.physics.box2d.BodyDef.BodyType; import com.csse3200.game.components.CombatStatsComponent; @@ -24,14 +21,9 @@ import com.csse3200.game.services.GameTime; import com.csse3200.game.services.ResourceService; import com.csse3200.game.services.ServiceLocator; -import org.junit.Ignore; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mock; - -import java.security.Provider; -import java.util.Arrays; @ExtendWith(GameExtension.class) public class TowerFactoryTest { diff --git a/source/core/src/test/com/csse3200/game/extensions/GameExtension.java b/source/core/src/test/com/csse3200/game/extensions/GameExtension.java index d80e081d9..c544e301e 100644 --- a/source/core/src/test/com/csse3200/game/extensions/GameExtension.java +++ b/source/core/src/test/com/csse3200/game/extensions/GameExtension.java @@ -5,7 +5,6 @@ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.backends.headless.HeadlessApplication; import com.badlogic.gdx.graphics.GL20; -import com.badlogic.gdx.graphics.GL30; import com.csse3200.game.services.ServiceLocator; import org.junit.jupiter.api.extension.AfterEachCallback; import org.junit.jupiter.api.extension.BeforeAllCallback; diff --git a/source/core/src/test/com/csse3200/game/input/InputComponentTest.java b/source/core/src/test/com/csse3200/game/input/InputComponentTest.java index 1bb048f4b..00be977e1 100644 --- a/source/core/src/test/com/csse3200/game/input/InputComponentTest.java +++ b/source/core/src/test/com/csse3200/game/input/InputComponentTest.java @@ -6,9 +6,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; diff --git a/source/core/src/test/com/csse3200/game/physics/PhysicsUtilsTest.java b/source/core/src/test/com/csse3200/game/physics/PhysicsUtilsTest.java index 145960134..2d212d674 100644 --- a/source/core/src/test/com/csse3200/game/physics/PhysicsUtilsTest.java +++ b/source/core/src/test/com/csse3200/game/physics/PhysicsUtilsTest.java @@ -12,8 +12,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import static org.junit.jupiter.api.Assertions.assertTrue; - @ExtendWith(GameExtension.class) class PhysicsUtilsTest { Entity entity; diff --git a/source/core/src/test/com/csse3200/game/rendering/RenderServiceTest.java b/source/core/src/test/com/csse3200/game/rendering/RenderServiceTest.java index e40c279f3..af10de683 100644 --- a/source/core/src/test/com/csse3200/game/rendering/RenderServiceTest.java +++ b/source/core/src/test/com/csse3200/game/rendering/RenderServiceTest.java @@ -2,7 +2,6 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; diff --git a/source/core/src/test/com/csse3200/game/services/ResourceServiceTest.java b/source/core/src/test/com/csse3200/game/services/ResourceServiceTest.java index f2ad009f6..9ad90cbb5 100644 --- a/source/core/src/test/com/csse3200/game/services/ResourceServiceTest.java +++ b/source/core/src/test/com/csse3200/game/services/ResourceServiceTest.java @@ -9,9 +9,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify;