Skip to content

Commit

Permalink
commiting last changes to the rangebosstask and boss scaling and atta…
Browse files Browse the repository at this point in the history
…ck scaling
  • Loading branch information
karthikeya-v committed Sep 11, 2023
1 parent 5c4a693 commit 4b8fe4d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public class ForestGameArea extends GameArea {
private static final int NUM_GHOSTS = 0;
private static final int NUM_GRUNTS = 5;

private static final int NUM_BOSSKING2=2;
private static final int NUM_BOSSKING1=2;
private static final int NUM_BOSSKING2=3;
private static final int NUM_BOSSKING1=1;

private Timer bossSpawnTimer;
private int bossSpawnInterval = 10000; // 1 minute in milliseconds
Expand Down Expand Up @@ -171,7 +171,7 @@ public void create() {
spawnGhosts();
spawnWeaponTower();
spawnEngineer();
bossKing1 = spawnBossKing1();
//bossKing1 = spawnBossKing1();
bossKing2 = spawnBossKing2();
spawnTNTTower();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
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.components.ProjectileEffects;
import com.csse3200.game.entities.Entity;
import com.csse3200.game.entities.factories.ProjectileFactory;
import com.csse3200.game.physics.PhysicsEngine;
import com.csse3200.game.physics.raycast.RaycastHit;
import com.csse3200.game.services.ServiceLocator;
import com.csse3200.game.physics.PhysicsLayer;
import org.slf4j.Logger;
Expand All @@ -26,17 +23,20 @@ public class RangeBossTask extends DefaultTask implements PriorityTask {
private MovementTask movementTask;
private WaitTask waitTask;
private Task currentTask;
private PhysicsEngine physics;
private static final short TARGET = PhysicsLayer.TOWER;
private final RaycastHit hit = new RaycastHit();
/** Animation event names */
private static final String START = "startMobKing";
private static final String FINAL = "startMobKingFinal";
private enum STATE {
START, FINAL
}
private STATE bossBallState = STATE.START;

/**
* @param waitTime How long in seconds to wait between wandering.
*/
public RangeBossTask(float waitTime) {

this.waitTime = waitTime;
physics = ServiceLocator.getPhysicsService().getPhysics();
}

@Override
Expand All @@ -55,41 +55,47 @@ public void start() {
movementTask.create(owner);

movementTask.start();
owner.getEntity().getEvents().trigger("walkStart");
currentTask = movementTask;

this.owner.getEntity().getEvents().trigger("rangeBossMovementStart");
}

public void switchMobKingBallState() {
switch (bossBallState) {
case START:
owner.getEntity().getEvents().trigger(FINAL);
bossBallState = STATE.FINAL;
}
}

@Override
public void update() {
if (currentTask.getStatus() != Status.ACTIVE) {
if (currentTask == movementTask) {
if (towerAhead() || engineerAhead()) {
owner.getEntity().getEvents().trigger("chargingStart");
Entity newProjectile = ProjectileFactory.createBossBall(PhysicsLayer.TOWER, new Vector2(0,currentPos.y + 0.75f), new Vector2(2f,2f));
newProjectile.setPosition((float) (currentPos.x), (float) (currentPos.y));
ServiceLocator.getEntityService().register(newProjectile);
this.owner.getEntity().getEvents().trigger("attack1Start");
}
Entity newProjectile = ProjectileFactory.createBossBall(
PhysicsLayer.HUMANS, new Vector2(0, currentPos.y + 0.75f), new Vector2(2f,2f));
owner.getEntity().getEvents().trigger(START);
switchMobKingBallState();
// newProjectile.scaleHeight(-1f);
newProjectile.setScale(2f, 2f);
newProjectile.setPosition((float) (currentPos.x), (float) (currentPos.y + 0.55f));
ServiceLocator.getEntityService().register(newProjectile);
startWaiting();
} else {
startMoving();

}
}
currentTask.update();
}

private void startWaiting() {
logger.debug("Starting waiting");
owner.getEntity().getEvents().trigger("idleStart");
swapTask(waitTask);
}

private void startMoving() {
logger.debug("Starting moving");
owner.getEntity().getEvents().trigger("walkStart");
owner.getEntity().getEvents().trigger("attack1Start");
movementTask.setTarget(currentPos.sub(2,0));
swapTask(movementTask);
}
Expand All @@ -102,11 +108,4 @@ private void swapTask(Task newTask) {
currentTask.start();
}

private boolean towerAhead() {
return physics.raycast(currentPos, new Vector2(0, currentPos.y), TARGET, hit);
}
private boolean engineerAhead() {
return physics.raycast(currentPos, new Vector2(0, currentPos.y), PhysicsLayer.ENGINEER, hit);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static Entity createBossKing1(Entity target, int numLane) {

AITaskComponent aiTaskComponent1 = new AITaskComponent()
.addTask(new FinalBossTask(1f, numLane))
.addTask(new bossDeathTask(1));
.addTask(new bossDeathTask(1));;

// Animation section
AnimationRenderComponent animator1 = new AnimationRenderComponent(
Expand All @@ -57,7 +57,7 @@ public static Entity createBossKing2(Entity target) {

AITaskComponent aiTaskComponent2 = new AITaskComponent()
.addTask(new RangeBossTask(2f))
.addTask(new bossDeathTask(1));
.addTask(new bossDeathTask(1));

// Animation section
AnimationRenderComponent animator2 = new AnimationRenderComponent(
Expand All @@ -76,8 +76,8 @@ public static Entity createBossKing2(Entity target) {
.addComponent(new Boss2AnimationController());

bossKing2.getComponent(AnimationRenderComponent.class).scaleEntity();
bossKing2.scaleHeight(2f);
bossKing2.scaleWidth(2f);
bossKing2.scaleHeight(3f);
bossKing2.scaleWidth(3f);

return bossKing2;
}
Expand Down

0 comments on commit 4b8fe4d

Please sign in to comment.