Skip to content

Commit

Permalink
Merge pull request #124 from UQcsse3200/Team_7_s2
Browse files Browse the repository at this point in the history
Added a ranged attack to the boss during its pause
  • Loading branch information
The-AhmadAA authored Sep 9, 2023
2 parents 7835e08 + a673006 commit 9c39e7b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
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 com.csse3200.game.physics.PhysicsLayer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -15,7 +19,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 +40,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 +58,11 @@ public void start() {
public void update() {
if (currentTask.getStatus() != Status.ACTIVE) {
if (currentTask == movementTask) {
Entity newProjectile = ProjectileFactory.createFireBall(PhysicsLayer.OBSTACLE, 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 +78,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 All @@ -81,4 +90,4 @@ private void swapTask(Task newTask) {
currentTask.start();
}

}
}
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 9c39e7b

Please sign in to comment.