From 3199c6e7983d30f0cc63b3d26a45355f079f3bc1 Mon Sep 17 00:00:00 2001 From: Thivan W Date: Tue, 17 Oct 2023 13:10:13 +1000 Subject: [PATCH 1/2] Changed the tower costs and their method to scan so be able to scan everything --- source/core/assets/configs/tower.json | 20 ++++++++-------- .../game/components/tasks/CurrencyTask.java | 2 +- .../components/tasks/DroidCombatTask.java | 4 +++- .../components/tasks/FireTowerCombatTask.java | 4 +++- .../tasks/FireworksTowerCombatTask.java | 4 +++- .../tasks/PierceTowerCombatTask.java | 4 +++- .../tasks/RicochetTowerCombatTask.java | 4 +++- .../components/tasks/StunTowerCombatTask.java | 4 +++- .../components/tasks/TNTTowerCombatTask.java | 4 +++- .../components/tasks/TowerCombatTask.java | 4 +++- .../entities/configs/IncomeTowerConfig.java | 2 +- .../game/entities/factories/TowerFactory.java | 1 - .../com/csse3200/game/screens/TowerType.java | 20 ++++++++-------- .../entities/factories/TowerFactoryTest.java | 24 +++++++++---------- 14 files changed, 58 insertions(+), 43 deletions(-) diff --git a/source/core/assets/configs/tower.json b/source/core/assets/configs/tower.json index 4d1daa23c..907105301 100644 --- a/source/core/assets/configs/tower.json +++ b/source/core/assets/configs/tower.json @@ -2,51 +2,51 @@ "income": { "health": 10, "baseAttack": 0, - "cost": 10 + "cost": 100 }, "wall": { "health": 300, "baseAttack": 0, - "cost": 45 + "cost": 200 }, "TNTTower": { "health": 10, "baseAttack": 5, - "cost": 30 + "cost": 50 }, "weapon": { "health": 75, "baseAttack": 15, - "cost": 15 + "cost": 50 }, "DroidTower": { "health": 100, "baseAttack": 25, - "cost": 45 + "cost": 300 }, "fireTower": { "health": 100, "baseAttack": 25, - "cost": 45 + "cost": 300 }, "stunTower": { "health": 100, "baseAttack": 25, - "cost": 45 + "cost": 500 }, "fireworksTower": { "health": 125, "baseAttack": 45, - "cost": 70 + "cost": 500 }, "pierceTower": { "health": 125, "baseAttack": 45, - "cost": 70 + "cost": 500 }, "ricochetTower": { "health": 125, "baseAttack": 45, - "cost": 70 + "cost": 500 } } \ No newline at end of file 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 a20c7464f..19f7fa624 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 @@ -21,7 +21,7 @@ public class CurrencyTask extends DefaultTask implements PriorityTask { private long endTime; private int interval; private final Scrap scrap = new Scrap(); // currency to update - private final int currencyAmount = 30; // amount of currency to update + private final int currencyAmount = 10; // amount of currency to update private static final String IDLE = "idleStartEco"; private static final String MOVE = "moveStartEco"; private static final String DEATH = "deathStartEco"; diff --git a/source/core/src/main/com/csse3200/game/components/tasks/DroidCombatTask.java b/source/core/src/main/com/csse3200/game/components/tasks/DroidCombatTask.java index b3c15e9c2..3c79de39a 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/DroidCombatTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/DroidCombatTask.java @@ -157,7 +157,9 @@ public int getPriority() { */ public boolean isTargetVisible() { // If there is an obstacle in the path to the max range point, mobs visible. - return physics.raycast(towerPosition, maxRangePosition, TARGET, hit); + boolean top = physics.raycast(towerPosition.add(0f,0.4f), maxRangePosition.add(0f,0.4f), TARGET, hit); + boolean bottom = physics.raycast(towerPosition.sub(0f,0.4f), maxRangePosition.sub(0f,0.4f), TARGET, hit); + return top || bottom; } private void changeFireRateInterval(int newInterval) { diff --git a/source/core/src/main/com/csse3200/game/components/tasks/FireTowerCombatTask.java b/source/core/src/main/com/csse3200/game/components/tasks/FireTowerCombatTask.java index 60714c560..0c434b674 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/FireTowerCombatTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/FireTowerCombatTask.java @@ -161,7 +161,9 @@ public int getInactivePriority() { * @return true if mobs are present and false otherwise. */ public boolean isTargetVisible() { - return physics.raycast(towerPosition, maxRangePosition, TARGET, hit); + boolean top = physics.raycast(towerPosition.add(0f,0.4f), maxRangePosition.add(0f,0.4f), TARGET, hit); + boolean bottom = physics.raycast(towerPosition.sub(0f,0.4f), maxRangePosition.sub(0f,0.4f), TARGET, hit); + return top || bottom; } private void changeFireRateInterval(int newInterval) { diff --git a/source/core/src/main/com/csse3200/game/components/tasks/FireworksTowerCombatTask.java b/source/core/src/main/com/csse3200/game/components/tasks/FireworksTowerCombatTask.java index b40cfa0db..9d29a1738 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/FireworksTowerCombatTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/FireworksTowerCombatTask.java @@ -159,7 +159,9 @@ public int getPriority() { * @return true if targets are detected, false otherwise */ public boolean isTargetVisible() { - return physics.raycast(towerPosition, maxRangePosition, TARGET, hit); + boolean top = physics.raycast(towerPosition.add(0f,0.4f), maxRangePosition.add(0f,0.4f), TARGET, hit); + boolean bottom = physics.raycast(towerPosition.sub(0f,0.4f), maxRangePosition.sub(0f,0.4f), TARGET, hit); + return top || bottom; } /** diff --git a/source/core/src/main/com/csse3200/game/components/tasks/PierceTowerCombatTask.java b/source/core/src/main/com/csse3200/game/components/tasks/PierceTowerCombatTask.java index 75268d9b6..96e412d5c 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/PierceTowerCombatTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/PierceTowerCombatTask.java @@ -159,7 +159,9 @@ public int getPriority() { * @return true if targets are detected, false otherwise */ public boolean isTargetVisible() { - return physics.raycast(towerPosition, maxRangePosition, TARGET, hit); + boolean top = physics.raycast(towerPosition.add(0f,0.4f), maxRangePosition.add(0f,0.4f), TARGET, hit); + boolean bottom = physics.raycast(towerPosition.sub(0f,0.4f), maxRangePosition.sub(0f,0.4f), TARGET, hit); + return top || bottom; } /** diff --git a/source/core/src/main/com/csse3200/game/components/tasks/RicochetTowerCombatTask.java b/source/core/src/main/com/csse3200/game/components/tasks/RicochetTowerCombatTask.java index 6e60bf01d..4aa8b94ca 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/RicochetTowerCombatTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/RicochetTowerCombatTask.java @@ -167,6 +167,8 @@ public int getPriority() { * @return true if targets are detected, false otherwise */ public boolean isTargetVisible() { - return physics.raycast(towerPosition, maxRangePosition, TARGET, hit); + boolean top = physics.raycast(towerPosition.add(0f,0.4f), maxRangePosition.add(0f,0.4f), TARGET, hit); + boolean bottom = physics.raycast(towerPosition.sub(0f,0.4f), maxRangePosition.sub(0f,0.4f), TARGET, hit); + return top || bottom; } } diff --git a/source/core/src/main/com/csse3200/game/components/tasks/StunTowerCombatTask.java b/source/core/src/main/com/csse3200/game/components/tasks/StunTowerCombatTask.java index 03abc3552..b8c0cf5f8 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/StunTowerCombatTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/StunTowerCombatTask.java @@ -188,7 +188,9 @@ public int getInactivePriority() { * @return true if targets are detected, false otherwise */ public boolean isTargetVisible() { - return physics.raycast(towerPosition, maxRangePosition, TARGET, hit); + boolean top = physics.raycast(towerPosition.add(0f,0.4f), maxRangePosition.add(0f,0.4f), TARGET, hit); + boolean bottom = physics.raycast(towerPosition.sub(0f,0.4f), maxRangePosition.sub(0f,0.4f), TARGET, hit); + return top || bottom; } private void changeFireRateInterval(int newInterval) { diff --git a/source/core/src/main/com/csse3200/game/components/tasks/TNTTowerCombatTask.java b/source/core/src/main/com/csse3200/game/components/tasks/TNTTowerCombatTask.java index 4c8016d24..db7f6a06a 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/TNTTowerCombatTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/TNTTowerCombatTask.java @@ -133,7 +133,9 @@ public STATE getState() { */ public boolean isTargetVisible() { // If there is an obstacle in the path to the max range point, mobs visible. - return physics.raycast(towerPosition, maxRangePosition, TARGET, hit); + boolean top = physics.raycast(towerPosition.add(0f,0.4f), maxRangePosition.add(0f,0.4f), TARGET, hit); + boolean bottom = physics.raycast(towerPosition.sub(0f,0.4f), maxRangePosition.sub(0f,0.4f), TARGET, hit); + return top || bottom; } public boolean isReadyToDelete() { 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 b5dd8f45c..21a8ab5a6 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 @@ -173,7 +173,9 @@ private int getInactivePriority() { */ private boolean isTargetVisible() { // If there is an obstacle in the path to the max range point, mobs visible. - return physics.raycast(towerPosition, maxRangePosition, TARGET, hit); + boolean top = physics.raycast(towerPosition.add(0f,0.4f), maxRangePosition.add(0f,0.4f), TARGET, hit); + boolean bottom = physics.raycast(towerPosition.sub(0f,0.4f), maxRangePosition.sub(0f,0.4f), TARGET, hit); + return top || bottom; } /** diff --git a/source/core/src/main/com/csse3200/game/entities/configs/IncomeTowerConfig.java b/source/core/src/main/com/csse3200/game/entities/configs/IncomeTowerConfig.java index bdcf77c06..ac68c04fb 100644 --- a/source/core/src/main/com/csse3200/game/entities/configs/IncomeTowerConfig.java +++ b/source/core/src/main/com/csse3200/game/entities/configs/IncomeTowerConfig.java @@ -9,6 +9,6 @@ public class IncomeTowerConfig { public int cost = 1; public float attackRate = 0; - public float incomeRate = 10; + public float incomeRate = 3; } diff --git a/source/core/src/main/com/csse3200/game/entities/factories/TowerFactory.java b/source/core/src/main/com/csse3200/game/entities/factories/TowerFactory.java index b98c5bde0..a6180b451 100644 --- a/source/core/src/main/com/csse3200/game/entities/factories/TowerFactory.java +++ b/source/core/src/main/com/csse3200/game/entities/factories/TowerFactory.java @@ -438,7 +438,6 @@ public static Entity createRicochetTower() { .addComponent(new CombatStatsComponent(config.health, config.baseAttack)) .addComponent((new CostComponent(config.cost))) .addComponent(aiTaskComponent); - // ADD ANIMATION COMPONENTS ricochetTower.setScale(1.5f, 1.5f); return ricochetTower; diff --git a/source/core/src/main/com/csse3200/game/screens/TowerType.java b/source/core/src/main/com/csse3200/game/screens/TowerType.java index 602409bcf..a5b265d2d 100644 --- a/source/core/src/main/com/csse3200/game/screens/TowerType.java +++ b/source/core/src/main/com/csse3200/game/screens/TowerType.java @@ -2,25 +2,25 @@ public enum TowerType { WEAPON("Weapon Tower", "weapon_tower", "The Weapon Tower is a simple and basic turret that fires rapid shots at enemies dealing damage over time.", - 0, "15", "images/turret-select/Weapon-Tower-Default.png", "images/turret-select/weapon-tower-selected.png"), + 0, "50", "images/turret-select/Weapon-Tower-Default.png", "images/turret-select/weapon-tower-selected.png"), TNT("TNT Tower", "tnt_tower", "The TNT Tower launches explosive projectiles, dealing area damage to groups of enemies.", - 1, "30", "images/turret-select/tnt-tower-default.png", "images/turret-select/tnt-tower-selected.png"), + 1, "50", "images/turret-select/tnt-tower-default.png", "images/turret-select/tnt-tower-selected.png"), DROID("Droid Tower", "droid_tower", "Droid Towers deploy robotic helpers that assist in combat and provide support to nearby turrets.", - 2, "45", "images/turret-select/droid-tower-default.png", "images/turret-select/droid-tower-selected.png"), + 2, "300", "images/turret-select/droid-tower-default.png", "images/turret-select/droid-tower-selected.png"), WALL("Wall Tower", "wall", "The Wall Tower creates barriers to block enemy paths, slowing down their progress.", - 3, "45", "images/turret-select/wall-tower-default.png", "images/turret-select/wall-tower-selected.png"), + 3, "200", "images/turret-select/wall-tower-default.png", "images/turret-select/wall-tower-selected.png"), FIRE("Fire Tower", "fire_tower", "The Fire Tower emits flames, causing damage over time to enemies caught in its fiery radius.", - 4, "45", "images/turret-select/fire-tower-default.png", "images/turret-select/fire-tower-selected.png"), + 4, "300", "images/turret-select/fire-tower-default.png", "images/turret-select/fire-tower-selected.png"), STUN("Stun Tower", "stun_tower", "The Stun Tower releases electric shocks that temporarily immobilize and damage enemies.", - 5, "45", "images/turret-select/stun-tower-default.png", "images/turret-select/stun-tower-selected.png"), + 5, "500", "images/turret-select/stun-tower-default.png", "images/turret-select/stun-tower-selected.png"), INCOME("Income Tower", "income_tower", "The Income Tower generates additional in-game currency over time.", - 6, "10", "images/turret-select/mine-tower-default.png", "images/turret-select/mine-tower-selected.png"), + 6, "100", "images/turret-select/mine-tower-default.png", "images/turret-select/mine-tower-selected.png"), PIERCE("Pierce Tower", "pierce_tower", "The Pierce Tower fires a projectile that pierces through targets and does not dissipate upon contact.", - 6, "0", "images/turret-select/pierce-tower-default.png", "images/turret-select/pierce-tower-selected.png"), + 6, "400", "images/turret-select/pierce-tower-default.png", "images/turret-select/pierce-tower-selected.png"), RICOCHET("Ricochet Tower", "ricochet_tower", "The Ricochet Tower fires a projectile that upon contact does damage and changes direction", - 7, "0", "images/turret-select/ricochet-tower-default.png", "images/turret-select/ricochet-tower-selected.png"), + 7, "400", "images/turret-select/ricochet-tower-default.png", "images/turret-select/ricochet-tower-selected.png"), FIREWORK("Firework Tower", "fireworks_tower", "The Firework Tower fires a projectile that splits on contact with its target", - 8, "0", "images/turret-select/firework-tower-default.png", "images/turret-select/firework-tower-selected.png"); + 8, "400", "images/turret-select/firework-tower-default.png", "images/turret-select/firework-tower-selected.png"); private final String towerName; private final String skinName; 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 01462c0f1..647853ebf 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 @@ -85,7 +85,7 @@ public void setUp() { weaponTower = TowerFactory.createWeaponTower(); wallTower = TowerFactory.createWallTower(); fireTower = TowerFactory.createFireTower(); - stunTower = TowerFactory.createFireTower(); + stunTower = TowerFactory.createStunTower(); tntTower = TowerFactory.createTNTTower(); droidTower = TowerFactory.createDroidTower(); } @@ -182,39 +182,39 @@ public void testWeaponTowerCombatStatsComponentAndCostComponent() { "Health should be 75"); assertEquals(15, weaponTower.getComponent(CombatStatsComponent.class).getBaseAttack(), "BaseAttack should be 15"); - assertEquals(15, weaponTower.getComponent(CostComponent.class).getCost(), - "Cost should be 15"); + assertEquals(50, weaponTower.getComponent(CostComponent.class).getCost(), + "Cost should be 50"); assertEquals(100, fireTower.getComponent(CombatStatsComponent.class).getHealth(), "Fire Tower health must be 100"); assertEquals(25, fireTower.getComponent(CombatStatsComponent.class).getBaseAttack(), "Fire Tower base attack must be 25"); - assertEquals(45, fireTower.getComponent(CostComponent.class).getCost(), - "Fire Tower cost must 45"); + assertEquals(300, fireTower.getComponent(CostComponent.class).getCost(), + "Fire Tower cost must 300"); assertEquals(100, stunTower.getComponent(CombatStatsComponent.class).getHealth(), "Stun Tower health must be 100"); assertEquals(25, stunTower.getComponent(CombatStatsComponent.class).getBaseAttack(), "Stun Tower base attack must be 25"); - assertEquals(45, stunTower.getComponent(CostComponent.class).getCost(), - "Stun Tower cost must 45"); + assertEquals(500, stunTower.getComponent(CostComponent.class).getCost(), + "Stun Tower cost must 500"); assertEquals(10, tntTower.getComponent(CombatStatsComponent.class).getHealth(), "TNT Tower health must be 10"); assertEquals(5, tntTower.getComponent(CombatStatsComponent.class).getBaseAttack(), "TNT Tower base attack must be 5"); - assertEquals(30, tntTower.getComponent(CostComponent.class).getCost(), - "TNT Tower cost must 30"); + assertEquals(50, tntTower.getComponent(CostComponent.class).getCost(), + "TNT Tower cost must 50"); assertEquals(100, droidTower.getComponent(CombatStatsComponent.class).getHealth(), "Droid Tower health must be 100"); assertEquals(25, droidTower.getComponent(CombatStatsComponent.class).getBaseAttack(), "Droid Tower base attack must be 25"); - assertEquals(45, droidTower.getComponent(CostComponent.class).getCost(), - "Droid Tower cost must 45"); + assertEquals(300, droidTower.getComponent(CostComponent.class).getCost(), + "Droid Tower cost must 300"); } @Test public void testWallTowerCombatStatsComponentAndCostComponent() { assertEquals(300, wallTower.getComponent(CombatStatsComponent.class).getHealth(), "Health should be 300"); assertEquals(0, wallTower.getComponent(CombatStatsComponent.class).getBaseAttack(), "BaseAttack should be 0"); - assertEquals(45, wallTower.getComponent(CostComponent.class).getCost(), "Cost should be 45"); + assertEquals(200, wallTower.getComponent(CostComponent.class).getCost(), "Cost should be 200"); } @Test From 3fa62d19f42ea783243a88dd0da6b018c1affa05 Mon Sep 17 00:00:00 2001 From: MiniSoda17 Date: Tue, 17 Oct 2023 14:16:52 +1000 Subject: [PATCH 2/2] greg fixed animation bug NOT ISAAC, greg, g r e g --- .../csse3200/game/components/tasks/MobTask/MobTask.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/source/core/src/main/com/csse3200/game/components/tasks/MobTask/MobTask.java b/source/core/src/main/com/csse3200/game/components/tasks/MobTask/MobTask.java index f4bd50af0..bd150803f 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/MobTask/MobTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/MobTask/MobTask.java @@ -169,9 +169,6 @@ public void update() { animate(); runFlag = false; } - if (!enemyDetected() && melee) { - runFlag = true; - } if (melee && enemyDetected() && gameTime.getTime() - lastTimeAttacked >= MELEE_ATTACK_SPEED) { changeState(State.ATTACK); meleeAttackFlag = true; @@ -193,11 +190,8 @@ public void update() { rangeAttackFlag = false; } if (animation.isFinished()) { - movementTask.start(); changeState(State.RUN); - if (!melee) { - runFlag = true; - } + runFlag = true; } } case DODGE -> {