Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Team 1 Mobs & Projectile Bug fixes #300

Merged
merged 11 commits into from
Oct 17, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void create() {

@Override
public void update() {
resetHealth();
super.update();
}

/**
Expand All @@ -77,8 +77,6 @@ private void deflectProj(Fixture me, Fixture other) {

if (deflectLimitAmount-- <= 0) { // Reached deflect limit amt, return.
entity.getComponent(this.getClass()).setEnabled(false);
// reset health
resetHealth();
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class DodgingComponent extends Component {
private final RaycastHit hit = new RaycastHit();
private short targetLayer;
private float rangeDetection;
private float dodgeSpeed = 1.75f;
private float dodgeSpeed = 1.75f;
private float originalSpeed; // Original entity vertical speed
private PhysicsEngine physics;
private Random random = new Random();
Expand Down Expand Up @@ -96,13 +96,14 @@ public void create() {
*/
public void changeTraverseDirection(Vector2 mobPos) {
int randDirection = random.nextInt(2) == 1 ? -1 : 1;

if (isTargetVisible(mobPos)) {
// If mob is in the top half quadrant of the map grid, make the entity dodge
// downwards.
// setVerticalAngleDirection(mobPos.y > 3.5 ? mobPos.y - 15 : mobPos.y + 15);
// Random direction
setVerticalAngleDirection(mobPos.y + (15 * randDirection));
setVerticalSpeed(dodgeSpeed);
setVerticalSpeed(dodgeSpeed);
} else {
setVerticalAngleDirection(mobPos.y);
setVerticalSpeed(originalSpeed);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ public void create() {
entity.getEvents().addListener("mob_walk", this::animateWalk);
entity.getEvents().addListener("mob_attack", this::animateAttack);
entity.getEvents().addListener("mob_death", this::animateDeath);


}

void animateWalk() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class MobTask extends DefaultTask implements PriorityTask {
private static final int MELEE_DAMAGE = 10;
private static final long MELEE_ATTACK_SPEED = 2000;
private static final long RANGE_ATTACK_SPEED = 5000;
private static final float MELEE_ATTACK_RANGE = 0.2f;
private static final float MELEE_ATTACK_RANGE = 0f;

private static final float CRYSTAL_DROP_RATE = 0.1f;
private static final float SCRAP_DROP_RATE = 0.6f;
Expand Down Expand Up @@ -102,7 +102,6 @@ public void start() {
super.start();
mob = owner.getEntity();
animation = mob.getComponent(AnimationRenderComponent.class);
mob.getComponent(PhysicsMovementComponent.class).setSpeed(MELEE_MOB_SPEED);
melee = mobType.isMelee();

movementTask = new MovementTask(new Vector2(0f, mob.getPosition().y));
Expand All @@ -115,8 +114,10 @@ public void start() {

if (melee) {
mob.getComponent(PhysicsMovementComponent.class).setSpeed(MELEE_MOB_SPEED);
mob.getComponent(PhysicsMovementComponent.class).setNormalSpeed(MELEE_MOB_SPEED);
} else {
mob.getComponent(PhysicsMovementComponent.class).setSpeed(MELEE_RANGE_SPEED);
mob.getComponent(PhysicsMovementComponent.class).setNormalSpeed(MELEE_RANGE_SPEED);
}
}

Expand Down Expand Up @@ -168,6 +169,9 @@ public void update() {
animate();
runFlag = false;
}
if (!enemyDetected() && melee) {
runFlag = true;
}
if (melee && enemyDetected() && gameTime.getTime() - lastTimeAttacked >= MELEE_ATTACK_SPEED) {
changeState(State.ATTACK);
meleeAttackFlag = true;
Expand All @@ -191,7 +195,9 @@ public void update() {
if (animation.isFinished()) {
movementTask.start();
changeState(State.RUN);
runFlag = true;
if (!melee) {
runFlag = true;
}
}
}
case DODGE -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public void start() {
animation = iceBaby.getComponent(AnimationRenderComponent.class);
currentPos = iceBaby.getPosition();
iceBaby.getComponent(PhysicsMovementComponent.class).setSpeed(ICEBABY_SPEED);
iceBaby.getComponent(PhysicsMovementComponent.class).setNormalSpeed(ICEBABY_SPEED);
Timer.schedule(new Timer.Task() {
@Override
public void run() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public void start() {
patrick = owner.getEntity();
animation = owner.getEntity().getComponent(AnimationRenderComponent.class); // get animation
patrick.getComponent(PhysicsMovementComponent.class).setSpeed(PATRICK_SPEED); // set speed
patrick.getComponent(PhysicsMovementComponent.class).setNormalSpeed(PATRICK_SPEED);

// give game time to load
Timer.schedule(new Timer.Task() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -624,8 +624,8 @@ public static Entity createDodgingDragonKnight(int health) {

dodgeKnight.addComponent(new DodgingComponent(PhysicsLayer.PROJECTILE, 0.25f, 5f));
dodgeKnight.getComponent(AITaskComponent.class).getTask(MobTask.class).setDodge(true);
PhysicsUtils.setScaledCollider(dodgeKnight, 0.3f, 1f);
dodgeKnight.setScale(0.3f, 1f);
// PhysicsUtils.setScaledCollider(dodgeKnight, 0.3f, 1f);
dodgeKnight.setScale(0.5f, 1.2f);

return dodgeKnight;
}
Expand Down
Loading