Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
samsully committed Sep 15, 2023
1 parent 97b7b59 commit 3b8cafe
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class CombatStatsComponent extends Component {
private String state;
private ArrayList<Currency> drops;
private ArrayList<Melee> closeRangeAbilities;
private ArrayList<ProjectileConfig> longRangeAbilities; //TODO change String to Projectiles
private ArrayList<ProjectileConfig> longRangeAbilities;

public CombatStatsComponent(int health, int baseAttack) {
setHealth(health);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void updateMobState() {
case IDLE -> {
if (isTargetVisible()) {
// targets detected in idle mode - start deployment
// owner.getEntity().getEvents().trigger(DEPLOY);
owner.getEntity().getEvents().trigger(DEPLOY);
mobState = STATE.DEPLOY;
}
}
Expand All @@ -124,20 +124,20 @@ public void updateMobState() {
if (!isTargetVisible() || this.meleeOrProjectile() == null) {
this.owner.getEntity().getEvents().trigger(STOW);
mobState = STATE.STOW;

} else {
// produce a projectile or melee attack based on chosen weapon
if (this.meleeOrProjectile() instanceof Melee) {
System.out.println("Melee attack");
TouchAttackComponent attackComp = owner.getEntity().getComponent(TouchAttackComponent.class);
HitboxComponent hitboxComp = owner.getEntity().getComponent(HitboxComponent.class);
attackComp.onCollisionStart(hitboxComp.getFixture(), target);
this.owner.getEntity().getEvents().trigger("meleeStart");

} else {
Entity newProjectile = ProjectileFactory.createMobBall(PhysicsLayer.HUMANS, new Vector2(0, owner.getEntity().getPosition().y), new Vector2(2f,2f));
newProjectile.setPosition((float) (owner.getEntity().getPosition().x), (float) (owner.getEntity().getPosition().y));
// newProjectile.setScale(-1f, 0.5f);
ServiceLocator.getEntityService().register(newProjectile);

// System.out.printf("ANIMATION: " + owner.getEntity().getComponent(AnimationRenderComponent.class).getCurrentAnimation() + "\n");
this.owner.getEntity().getEvents().trigger(FIRING);
mobState = STATE.STOW;
}
Expand All @@ -149,7 +149,7 @@ public void updateMobState() {
case STOW -> {
// currently stowing
if (isTargetVisible()) {
// owner.getEntity().getEvents().trigger(DEPLOY);
owner.getEntity().getEvents().trigger(DEPLOY);
mobState = STATE.DEPLOY;
} else {
owner.getEntity().getEvents().trigger(IDLE);
Expand Down Expand Up @@ -226,8 +226,6 @@ private boolean isTargetVisible() {
* returns the Weapon (Melee or Projectile) the mob will use to attack the target. null if immune target or no target
* */
private Weapon meleeOrProjectile() {
// Vector2 newVector = new Vector2(owner.getEntity().getPosition().x - 10f, owner.getEntity().getPosition().y - 2f);
// Fixture hitraycast = physics.raycastGetHit(owner.getEntity().getPosition(), newVector, TARGET);
setTarget();
TouchAttackComponent comp = owner.getEntity().getComponent(TouchAttackComponent.class);
Weapon chosenWeapon = null;
Expand All @@ -238,6 +236,9 @@ private Weapon meleeOrProjectile() {
return chosenWeapon;
}

/**
* set the target of this attack taskto the closest HUMAN target to the mob
* */
private void setTarget() {
Vector2 newVector = new Vector2(owner.getEntity().getPosition().x - 10f, owner.getEntity().getPosition().y - 2f);
target = physics.raycastGetHit(owner.getEntity().getPosition(), newVector, TARGET);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.csse3200.game.entities.configs.NPCConfigs;
import com.csse3200.game.entities.configs.ProjectileConfig;
import com.csse3200.game.files.FileLoader;

public class PredefinedWeapons {
// Melee attacks
Expand All @@ -10,11 +11,8 @@ public class PredefinedWeapons {
public static Melee axe = new Melee(9, 3, "fire", 1, 1);
public static Melee kick = new Melee(2, 1, "earth", 1, 1);

//TODO import defined projectiles for mobs
public static ProjectileConfig fireBall = new ProjectileConfig();
public static ProjectileConfig frostBall = new ProjectileConfig();

// Projectile attacks TODO: change Weapon and Melee to Projectile class
// public static Weapon fireBall = new Melee(9, 20, "fire", 1, 1);
// public static Weapon frostBall = new Melee(6, 20, "ice", 1, 1);
// public static Weapon hurricane = new Melee(7, 20, "air", 1, 1);
}

0 comments on commit 3b8cafe

Please sign in to comment.