Skip to content

Commit

Permalink
added range boss's ranged attack during pause
Browse files Browse the repository at this point in the history
  • Loading branch information
ThivanW committed Sep 6, 2023
1 parent 2b4130f commit 7c9e95f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import com.csse3200.game.ai.tasks.DefaultTask;
import com.csse3200.game.ai.tasks.PriorityTask;
import com.csse3200.game.ai.tasks.Task;
import com.csse3200.game.entities.Entity;
import com.csse3200.game.entities.factories.ProjectileFactory;
import com.csse3200.game.services.ServiceLocator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -15,7 +18,7 @@ public class RangeBossMovementTask extends DefaultTask implements PriorityTask {
private static final Logger logger = LoggerFactory.getLogger(RangeBossMovementTask.class);

private final float waitTime;
private Vector2 startPos;
private Vector2 currentPos;
private MovementTask movementTask;
private WaitTask waitTask;
private Task currentTask;
Expand All @@ -36,11 +39,11 @@ public int getPriority() {
@Override
public void start() {
super.start();
startPos = owner.getEntity().getPosition();
currentPos = owner.getEntity().getPosition();

waitTask = new WaitTask(waitTime);
waitTask.create(owner);
movementTask = new MovementTask(startPos.sub(2,0));
movementTask = new MovementTask(currentPos.sub(2,0));
movementTask.create(owner);

movementTask.start();
Expand All @@ -54,6 +57,10 @@ public void start() {
public void update() {
if (currentTask.getStatus() != Status.ACTIVE) {
if (currentTask == movementTask) {
Entity newProjectile = ProjectileFactory.createFireBall(owner.getEntity(), new Vector2(0, (currentPos.y + 0.75f)), new Vector2(2f,2f));
newProjectile.scaleHeight(-0.4f);
newProjectile.setPosition((float) (currentPos.x), (float) (currentPos.y+0.75f));
ServiceLocator.getEntityService().register(newProjectile);
startWaiting();
} else {
startMoving();
Expand All @@ -69,7 +76,7 @@ private void startWaiting() {

private void startMoving() {
logger.debug("Starting moving");
movementTask.setTarget(startPos.sub(2,0));
movementTask.setTarget(currentPos.sub(2,0));
swapTask(movementTask);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public static Entity createBossKing1(Entity target) {
.addComponent(new BossAnimationController());

bossKing1.getComponent(AnimationRenderComponent.class).scaleEntity();
bossKing1.scaleHeight(0.5f);
bossKing1.scaleWidth(0.5f);
bossKing1.setScale(-1f,1f);

return bossKing1;
}

Expand Down

0 comments on commit 7c9e95f

Please sign in to comment.