Skip to content

Commit

Permalink
Fixed merge conflicts, moved my work to correct branch :)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hasakev committed Oct 17, 2023
1 parent c5d50b1 commit a4b53da
Show file tree
Hide file tree
Showing 15 changed files with 97 additions and 103 deletions.
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 @@ -30,7 +30,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;

Expand Down Expand Up @@ -96,13 +96,14 @@ public void create() {
*/
public void changeTraverseDirection(Vector2 mobPos) {
int randDirection = MathUtils.random(0,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 @@ -97,7 +97,7 @@ private void onDeath() {
// left.
if (amount == 1) {
float newXPosition = (float) (entity.getPosition().x - OFFSET_DISTANCE);
float newYPosition = (float) (entity.getPosition().y);
float newYPosition = (entity.getPosition().y);

if (withinBounds(newXPosition, newYPosition)) {
spawnAdditionalMob(newXPosition, newYPosition, initialScaleX, initialScaleY);
Expand Down Expand Up @@ -133,37 +133,31 @@ private void onDeath() {
*/
public void spawnAdditionalMob(float positionX, float positionY,
float initialScaleX, float initialScaleY) {
// Entity waterSlime = NPCFactory.createBaseWaterSlime(60);
Entity entityType;
switch (mobType) {
case WATER_SLIME -> {
case WATER_SLIME ->
entityType = NPCFactory.createBaseWaterSlime(baseMoblingHealth);
}

case NIGHT_BORNE -> {
case NIGHT_BORNE ->
entityType = NPCFactory.createNightBorne(baseMoblingHealth);
}

case ROCKY -> {
case ROCKY ->
entityType = NPCFactory.createRocky(baseMoblingHealth);
}

default -> {
default ->
entityType = NPCFactory.createBaseWaterSlime(baseMoblingHealth);
}
}

entityType.setPosition(positionX, positionY);

switch (mobType) {
case NIGHT_BORNE -> {
case NIGHT_BORNE ->
entityType.setScale(initialScaleX, initialScaleY);
}
default -> {

default ->
entityType.setScale(initialScaleX * scaleX, initialScaleY * scaleY);
}
}

}

ServiceLocator.getEntityService().register(entityType);

Expand All @@ -180,12 +174,9 @@ public void spawnAdditionalMob(float positionX, float positionY,
* False otherwise.
*/
private boolean withinBounds(float currX, float currY) {
if (currX >= MIN_X_BOUNDS
return currX >= MIN_X_BOUNDS
&& currX <= MAX_X_BOUNDS
&& currY >= MIN_Y_BOUNDS
&& currY <= MAX_Y_BOUNDS) {
return true;
}
return false;
&& currY <= MAX_Y_BOUNDS;
}
}
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 @@ -169,6 +170,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 @@ -192,7 +196,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 @@ -17,10 +17,10 @@ public class EconTowerAnimationController extends Component {
private static final String ECO_MOVE = "move1";
private static final String ECO_IDLE = "idle";

private static final String PING = "sounds/towers/eco_tower_ping.mp3";
private static final String PING_PATH = "sounds/towers/eco_tower_ping.mp3";

private final Sound ping = ServiceLocator.getResourceService().getAsset(
PING, Sound.class);
PING_PATH, Sound.class);

AnimationRenderComponent animator;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
*/
public class TNTAnimationController extends Component {
private AnimationRenderComponent animator;
private static final String EXPLOSION = "sounds/towers/explosion.mp3";
private static final String EXPLOSION_PATH = "sounds/towers/explosion.mp3";

private final Sound explosion = ServiceLocator.getResourceService().getAsset(
EXPLOSION, Sound.class);
EXPLOSION_PATH, Sound.class);

/**
* Creation call for a TNTAnimationController, fetches the animationRenderComponent that this controller will
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.csse3200.game.entities.configs;
/** Defines the basic set of properties for an Engineer entity to be loaded by EngineerFactory */
public class EngineerConfig extends BaseEntityConfig {
public class EngineerConfig {
public int health = 1;
public int baseAttack = 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* Defines the properties stored in Engineer config files to be loaded by the Engineer Factory.
*/
public class EngineerConfigs extends BaseEntityConfig {
public class EngineerConfigs {
public BaseEntityConfig engineer = new BaseEntityConfig();
public int health = 10;
public int baseAttack = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
* Defines the properties stored in mob boss config files to be loaded by the Mob Boss Factory.
*/
public class MobBossConfigs extends BaseEntityConfig {
public int baseAttack = 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* Configuration for projectiles.
*/
public class ProjectileConfig extends BaseEntityConfig implements Weapon {
public int health = 1;
public int baseAttack = 0;

public int getDamage() {
return baseAttack;
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

0 comments on commit a4b53da

Please sign in to comment.