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 cc626a02e..3488d0892 100644 --- a/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java +++ b/source/core/src/main/com/csse3200/game/areas/ForestGameArea.java @@ -331,15 +331,14 @@ public void create() { // spawnWeaponTower(); // spawnGapScanners(); // spawnDroidTower(); -// spawnFireWorksTower(); // Commented these out until they are needed for Demonstration -// spawnPierceTower(); -// spawnRicochetTower(); + spawnFireWorksTower(); // Commented these out until they are needed for Demonstration + spawnPierceTower(); + spawnRicochetTower(); // spawnBombship(); } private void displayUI() { Entity ui = new Entity(); - ui.addComponent(new GameAreaDisplay("Box Forest")); ui.addComponent(ServiceLocator.getGameEndService().getDisplay()); ui.addComponent(ServiceLocator.getCurrencyService().getDisplay()); spawnEntity(ui); 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 a887ed896..844e5f7a5 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 @@ -47,7 +47,7 @@ private void addActors() { table = new Table(); table.top().left(); table.setFillParent(true); - table.padTop(140f).padLeft(20f); + table.padTop(60f).padLeft(5f); scrapsTb = createButton("images/economy/scrapBanner.png", ServiceLocator.getCurrencyService().getScrap().getAmount()); diff --git a/source/core/src/main/com/csse3200/game/components/gamearea/EngineerCountDisplay.java b/source/core/src/main/com/csse3200/game/components/gamearea/EngineerCountDisplay.java index 39e849574..ec1bc322e 100644 --- a/source/core/src/main/com/csse3200/game/components/gamearea/EngineerCountDisplay.java +++ b/source/core/src/main/com/csse3200/game/components/gamearea/EngineerCountDisplay.java @@ -30,7 +30,7 @@ private void addActors() { table = new Table(); table.top().left(); table.setFillParent(true); - table.padTop(80f).padLeft(20f); + table.padTop(0f).padLeft(5f); Drawable drawable = new TextureRegionDrawable(new TextureRegion( new Texture("images/engineers/engineerBanner.png"))); 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 ef7c74f89..7beb6796e 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 @@ -13,6 +13,8 @@ import com.csse3200.game.services.GameTime; import com.csse3200.game.services.ServiceLocator; +import static java.lang.Math.round; + /** * The FireworksTowerCombatTask runs the AI for the FireworksTower class. The tower scans for mobs and targets in a @@ -38,6 +40,7 @@ public class FireworksTowerCombatTask extends DefaultTask implements PriorityTas private final Vector2 maxRangePosition = new Vector2(); private PhysicsEngine physics; private GameTime timeSource; + private float fireRateInterval; private long endTime; private final RaycastHit hit = new RaycastHit(); @@ -53,6 +56,7 @@ public enum STATE { public FireworksTowerCombatTask(int priority, float maxRange) { this.priority = priority; this.maxRange = maxRange; + this.fireRateInterval = 1; physics = ServiceLocator.getPhysicsService().getPhysics(); timeSource = ServiceLocator.getTimeSource(); } @@ -79,7 +83,12 @@ public void start() { public void update() { if (timeSource.getTime() >= endTime) { updateTowerState(); - endTime = timeSource.getTime() + (INTERVAL * 1000); + if (towerState == STATE.ATTACK) { + endTime = timeSource.getTime() + round(fireRateInterval * 1000); + } else { + endTime = timeSource.getTime() + (INTERVAL * 1000); + } + } } 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 8d8723f65..0ea206192 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 @@ -14,6 +14,8 @@ import com.csse3200.game.services.GameTime; import com.csse3200.game.services.ServiceLocator; +import static java.lang.Math.round; + /** * The PierceTowerCombatTask runs the AI for the PierceTower class. The tower scans for mobs and targets in a straight * line from its centre coordinate and executes the trigger phrases for animations depeending on the current state of @@ -32,6 +34,7 @@ public class PierceTowerCombatTask extends DefaultTask implements PriorityTask { // Class attributes private final int priority; + private float fireRateInterval; private final float maxRange; private Vector2 towerPosition = new Vector2(10, 10); private final Vector2 maxRangePosition = new Vector2(); @@ -52,6 +55,7 @@ public enum STATE { public PierceTowerCombatTask(int priority, float maxRange) { this.priority = priority; this.maxRange = maxRange; + this.fireRateInterval = 1; physics = ServiceLocator.getPhysicsService().getPhysics(); timeSource = ServiceLocator.getTimeSource(); } @@ -78,6 +82,9 @@ public void start() { public void update() { if (timeSource.getTime() >= endTime) { updateTowerState(); + if (towerState == STATE.ATTACK) { + endTime = timeSource.getTime() + round(fireRateInterval * 1000); + } endTime = timeSource.getTime() + (INTERVAL * 1000); } } 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 d057c1ab0..a3cecb8aa 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 @@ -14,6 +14,8 @@ import com.csse3200.game.services.GameTime; import com.csse3200.game.services.ServiceLocator; +import static java.lang.Math.round; + /** * The RicochetTowerCombatTask runs the AI for the RicochetTower class. The tower scans for mobs and targets in a @@ -38,6 +40,7 @@ public class RicochetTowerCombatTask extends DefaultTask implements PriorityTask private final Vector2 maxRangePosition = new Vector2(); private PhysicsEngine physics; private GameTime timeSource; + private float fireRateInterval; private long endTime; private final RaycastHit hit = new RaycastHit(); @@ -54,6 +57,7 @@ public enum STATE { public RicochetTowerCombatTask(int priority, float maxRange) { this.priority = priority; this.maxRange = maxRange; + this.fireRateInterval = 1; physics = ServiceLocator.getPhysicsService().getPhysics(); timeSource = ServiceLocator.getTimeSource(); } @@ -80,7 +84,11 @@ public void start() { public void update() { if (timeSource.getTime() >= endTime) { updateTowerState(); - endTime = timeSource.getTime() + (INTERVAL * 1000); + if (towerState == STATE.ATTACK) { + endTime = timeSource.getTime() + round(fireRateInterval * 1000); + } else { + endTime = timeSource.getTime() + (INTERVAL * 1000); + } } } diff --git a/source/core/src/main/com/csse3200/game/entities/configs/FireworksTowerConfig.java b/source/core/src/main/com/csse3200/game/entities/configs/FireworksTowerConfig.java index c1bde5dd3..d01f0b5c8 100644 --- a/source/core/src/main/com/csse3200/game/entities/configs/FireworksTowerConfig.java +++ b/source/core/src/main/com/csse3200/game/entities/configs/FireworksTowerConfig.java @@ -2,8 +2,8 @@ public class FireworksTowerConfig { public int health = 1; - public int baseAttack = 0; + public int baseAttack = 1; public int cost = 1; - public int attackRate =0; + public int attackRate =1; public int incomeRate =0; } diff --git a/source/core/src/main/com/csse3200/game/entities/configs/PierceTowerConfig.java b/source/core/src/main/com/csse3200/game/entities/configs/PierceTowerConfig.java index 8baf1cb52..0a44bec79 100644 --- a/source/core/src/main/com/csse3200/game/entities/configs/PierceTowerConfig.java +++ b/source/core/src/main/com/csse3200/game/entities/configs/PierceTowerConfig.java @@ -2,6 +2,7 @@ public class PierceTowerConfig { public int health = 1; - public int baseAttack = 0; + public int baseAttack = 1; public int cost = 1; + public float attackRate = 1; } diff --git a/source/core/src/main/com/csse3200/game/entities/configs/RicochetTowerConfig.java b/source/core/src/main/com/csse3200/game/entities/configs/RicochetTowerConfig.java index 3a637c7e2..f86d48569 100644 --- a/source/core/src/main/com/csse3200/game/entities/configs/RicochetTowerConfig.java +++ b/source/core/src/main/com/csse3200/game/entities/configs/RicochetTowerConfig.java @@ -2,6 +2,7 @@ public class RicochetTowerConfig { public int health = 1; - public int baseAttack = 0; + public int baseAttack = 1; public int cost = 1; + public float attackRate = 1; } 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 a92dbb234..80c755655 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 @@ -196,7 +196,6 @@ public static Entity createTNTTower() { TNTTower .addComponent(new CombatStatsComponent(config.health, config.baseAttack)) - .addComponent(new UpgradableStatsComponent(config.attackRate)) .addComponent(new CostComponent(config.cost)) .addComponent(new TNTDamageComponent(PhysicsLayer.NPC,TNT_KNOCK_BACK_FORCE,TNT_TOWER_RANGE)) .addComponent(aiTaskComponent) @@ -204,6 +203,7 @@ public static Entity createTNTTower() { .addComponent(new TNTAnimationController()); TNTTower.getComponent(AnimationRenderComponent.class).scaleEntity(); + TNTTower.removeComponent(TowerUpgraderComponent.class); return TNTTower; } @@ -275,7 +275,6 @@ public static Entity createWeaponTower() { .addComponent(new CombatStatsComponent(config.health, config.baseAttack)) .addComponent(new UpgradableStatsComponent(config.attackRate)) .addComponent(new CostComponent(config.cost)) - .addComponent(new UpgradableStatsComponent(config.attackRate)) .addComponent(aiTaskComponent) .addComponent(animator) .addComponent(new TowerAnimationController()); @@ -370,6 +369,7 @@ public static Entity createFireworksTower() { fireworksTower .addComponent(new CombatStatsComponent(config.health, config.baseAttack)) + .addComponent(new UpgradableStatsComponent(config.attackRate)) .addComponent((new CostComponent(config.cost))) .addComponent(aiTaskComponent) .addComponent(animator) @@ -404,6 +404,7 @@ public static Entity createPierceTower() { pierceTower .addComponent(animator) .addComponent(new PierceTowerAnimationController()) + .addComponent(new UpgradableStatsComponent(config.attackRate)) .addComponent(new CombatStatsComponent(config.health, config.baseAttack)) .addComponent((new CostComponent(config.cost))) .addComponent(aiTaskComponent); @@ -432,6 +433,7 @@ public static Entity createRicochetTower() { ricochetTower .addComponent(animator) .addComponent(new RicochetTowerAnimationController()) + .addComponent(new UpgradableStatsComponent(config.attackRate)) .addComponent(new CombatStatsComponent(config.health, config.baseAttack)) .addComponent((new CostComponent(config.cost))) .addComponent(aiTaskComponent); diff --git a/source/core/src/main/com/csse3200/game/input/UpgradeUIComponent.java b/source/core/src/main/com/csse3200/game/input/UpgradeUIComponent.java index b06134cb6..6ac364938 100644 --- a/source/core/src/main/com/csse3200/game/input/UpgradeUIComponent.java +++ b/source/core/src/main/com/csse3200/game/input/UpgradeUIComponent.java @@ -1,5 +1,6 @@ package com.csse3200.game.input; +import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Camera; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Texture; @@ -33,6 +34,8 @@ import java.util.Iterator; import java.util.Map; +import static java.lang.Math.round; + public class UpgradeUIComponent extends InputComponent { private static final Logger logger = LoggerFactory.getLogger(ForestGameArea.class); private final EntityService entityService; @@ -85,21 +88,21 @@ public boolean touchDown(int screenX, int screenY, int pointer, int button) { Vector2 cursorPosition = new Vector2(worldCoordinates.x, worldCoordinates.y); Entity clickedEntity = entityService.getEntityAtPosition(cursorPosition.x, cursorPosition.y); - //temp fix to prevent upgrading of new towers - if (clickedEntity!= null && (clickedEntity.getComponent(RicochetTowerAnimationController.class) != null || - clickedEntity.getComponent(PierceTowerAnimationController.class) != null || - clickedEntity.getComponent(FireworksTowerAnimationController.class) != null)) { - return false; - } - // +// //temp fix to prevent upgrading of new towers +// if (clickedEntity!= null && (clickedEntity.getComponent(RicochetTowerAnimationController.class) != null || +// clickedEntity.getComponent(PierceTowerAnimationController.class) != null || +// clickedEntity.getComponent(FireworksTowerAnimationController.class) != null)) { +// return false; +// } +// // // If the clicked position contains a turret, and the turret is upgradable and not a TNT tower if (clickedEntity != null && clickedEntity.getComponent(TowerUpgraderComponent.class) != null - && clickedEntity.getComponent(TNTDamageComponent.class) == null) { + ) { // TNT TowerUpgraderComponent can be removed later, but possibly useful for future sprint. // Clear all existing upgrade tables - logger.info("clickedEntity: " + clickedEntity); - +// logger.info("clickedEntity: " + clickedEntity); +// clearUpgradeTables(); // Check if there is an existing upgrade table for this turret entity Table existingUpgradeTable = upgradeTables.get(clickedEntity); @@ -110,8 +113,6 @@ public boolean touchDown(int screenX, int screenY, int pointer, int button) { } else { // If no upgrade table exists, create and store a new one Table newUpgradeTable = createUpgradeTable(clickedEntity); - Vector2 UICoordinates = stage.screenToStageCoordinates(new Vector2(screenX, screenY)); - newUpgradeTable.setPosition(UICoordinates.x, UICoordinates.y); stage.addActor(newUpgradeTable); // Store the new upgrade table in the map @@ -149,9 +150,11 @@ private void clearUpgradeTables() { private Table createUpgradeTable(Entity turretEntity) { // This is the overarching table that contains the close button, the inner table, and the cost display Table upgradeTable = new Table(); - upgradeTable.top(); + upgradeTable.top().left(); upgradeTable.defaults().pad(0).space(0); upgradeTable.setSize(60, 60); + upgradeTable.padTop(5f).padLeft(5f); + upgradeTable.setPosition(0, round((float) Gdx.graphics.getHeight() / 1.3f)); // The inner table contains the upgrade buttons and the stats display Table innerUpgradeTable = new Table(); @@ -380,6 +383,7 @@ public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) } }); } + logger.info(String.valueOf(attack)); if (attack != 0) { innerUpgradeTable.add(attackIconImage).padRight(5).width(32).height(32); // Add attack icon innerUpgradeTable.add(attackLabel).expandX().left();