Skip to content

Commit

Permalink
Fixed projectile positions for all towers
Browse files Browse the repository at this point in the history
  • Loading branch information
ThivanW committed Oct 11, 2023
1 parent 6a21853 commit ca6d3bb
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public CurrencyTask(int priority, int interval) {
public void start() {
super.start();
owner.getEntity().getEvents().addListener("addIncome",this::changeInterval);
// TODO: GOT RID OF THE 30 TIMES MULTIPLIER
endTime = timeSource.getTime() + (1000L);
// TODO: changed 30 TIMES MULTIPLIER to 5 times
endTime = timeSource.getTime() + (interval * 1500L);
owner.getEntity().getEvents().trigger(IDLE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void start() {
// Default to idle mode
owner.getEntity().getEvents().trigger(WALK);
owner.getEntity().getEvents().addListener("addFireRate",this::changeFireRateInterval);
endTime = timeSource.getTime() + (INTERVAL * 500);
endTime = timeSource.getTime() + (INTERVAL * 1000);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void updateTowerState() {
Entity newProjectile = ProjectileFactory.createEffectProjectile(PhysicsLayer.NPC,
new Vector2(100, owner.getEntity().getPosition().y), new Vector2(2f, 2f), ProjectileEffects.BURN, false);
newProjectile.setPosition((float) (owner.getEntity().getPosition().x + 0.25),
(float) (owner.getEntity().getPosition().y + 0.25));
(float) (owner.getEntity().getPosition().y));
ServiceLocator.getEntityService().register(newProjectile);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class FireworksTowerCombatTask extends DefaultTask implements PriorityTask {
// constants
// Time interval (in seconds) to scan for enemies
private static final int INTERVAL = 2;
private static final int INTERVAL = 1;
// The type of targets this tower will detect
private static final short TARGET = PhysicsLayer.NPC;
//Following constants are names of events that will be triggered in the state machine
Expand Down Expand Up @@ -103,6 +103,7 @@ public void updateTowerState() {
}
}
case ATTACK -> {
// check if fired last time if not fire if so hold
if (isTargetVisible()) {
owner.getEntity().getEvents().trigger(ATTACK);
Entity newProjectile = ProjectileFactory.createSplitFireWorksFireball(PhysicsLayer.NPC,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public void updateTowerState() {
new Vector2(100, owner.getEntity().getPosition().y), new Vector2(2f, 2f),
ProjectileEffects.STUN, false);
newProjectile.setPosition((float) (owner.getEntity().getPosition().x + 0.25),
(float) (owner.getEntity().getPosition().y + 0.25));
(float) (owner.getEntity().getPosition().y));
ServiceLocator.getEntityService().register(newProjectile);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void start() {
// Set the default state to IDLE state
owner.getEntity().getEvents().trigger(IDLE);

endTime = timeSource.getTime() + (INTERVAL * 5000);
endTime = timeSource.getTime() + (INTERVAL * 1000);
}

/**
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 = 30;
public float incomeRate = 10;

}
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,6 @@ public static Entity createStunTower() {
.addComponent(new StunTowerAnimationController());

stunTower.setScale(1.5f, 1.5f);
PhysicsUtils.setScaledCollider(stunTower, 0.5f, 0.5f);
return stunTower;
}

Expand Down Expand Up @@ -438,25 +437,6 @@ public static Entity createRicochetTower() {
ricochetTower.setScale(1.5f, 1.5f);
return ricochetTower;
}
public static Entity createHealTower() {
Entity ricochetTower = createBaseTower();
HealTowerConfig config = configs.HealTower;

AITaskComponent aiTaskComponent = new AITaskComponent()
.addTask(new RicochetTowerCombatTask(COMBAT_TASK_PRIORITY, WEAPON_TOWER_MAX_RANGE));

// ADD AnimationRenderComponent

ricochetTower
.addComponent(new CombatStatsComponent(config.health, config.baseAttack))
.addComponent((new CostComponent(config.cost)))
.addComponent(aiTaskComponent);
// ADD ANIMATION COMPONENTS

ricochetTower.setScale(1.5f, 1.5f);
PhysicsUtils.setScaledCollider(ricochetTower, 0.5f, 0.5f);
return ricochetTower;
}

/**
* Creates a generic tower entity to be used as a base entity by more specific tower creation methods.
Expand Down

0 comments on commit ca6d3bb

Please sign in to comment.