Skip to content

Commit

Permalink
Added a new waitTask to be executed as a projectile is spawned
Browse files Browse the repository at this point in the history
  • Loading branch information
ThivanW committed Sep 6, 2023
1 parent 0ee7cb1 commit 7dd841e
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class RangeBossMovementTask extends DefaultTask implements PriorityTask {
private Vector2 currentPos;
private MovementTask movementTask;
private WaitTask waitTask;
private WaitTask rangeAttackTask;
private Task currentTask;

private enum STATE {
Expand Down Expand Up @@ -57,6 +58,10 @@ public void start() {

waitTask = new WaitTask(waitTime);
waitTask.create(owner);

rangeAttackTask = new WaitTask(waitTime);
rangeAttackTask.create(owner);

movementTask = new MovementTask(currentPos.sub(2,0));
movementTask.create(owner);

Expand All @@ -73,7 +78,7 @@ public void update() {
if (currentTask.getStatus() != Status.ACTIVE) {
if (currentTask == movementTask) {
if (towerAhead()) {
// fire projectile
startRangeAttack();
} else {
startWaiting();
}
Expand All @@ -95,7 +100,12 @@ private void startMoving() {
swapTask(movementTask);
}


private void startRangeAttack() {
logger.debug("Starting range attack");
// fire a projectile
Entity newProjectile;
swapTask(rangeAttackTask);
}

private void swapTask(Task newTask) {
if (currentTask != null) {
Expand Down

0 comments on commit 7dd841e

Please sign in to comment.