Skip to content

Commit

Permalink
Changed the tower costs and their method to scan so be able to scan e…
Browse files Browse the repository at this point in the history
…verything
  • Loading branch information
ThivanW committed Oct 17, 2023
1 parent 783f687 commit 3199c6e
Show file tree
Hide file tree
Showing 14 changed files with 58 additions and 43 deletions.
20 changes: 10 additions & 10 deletions source/core/assets/configs/tower.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ public class IncomeTowerConfig {
public int cost = 1;

public float attackRate = 0;
public float incomeRate = 10;
public float incomeRate = 3;

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 10 additions & 10 deletions source/core/src/main/com/csse3200/game/screens/TowerType.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3199c6e

Please sign in to comment.