Skip to content

Commit

Permalink
removed createAoeProjectile and instead replaced it with createEffect…
Browse files Browse the repository at this point in the history
…Projectile which has parameters that accepts different effects and whether it is an aoe projectile or not
  • Loading branch information
gregchan550 committed Sep 6, 2023
1 parent fd49550 commit 7e44262
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,27 @@

import com.badlogic.gdx.physics.box2d.Fixture;
import com.csse3200.game.entities.Entity;
import com.csse3200.game.physics.BodyUserData;
import com.csse3200.game.entities.factories.ProjectileFactory;
import com.csse3200.game.physics.components.HitboxComponent;
import com.csse3200.game.services.ServiceLocator;

import com.badlogic.gdx.utils.Array;

public class AoeComponent extends Component {
public class EffectsComponent extends Component {
private final float radius;
private final ProjectileFactory.ProjectileEffects effect;
private final boolean aoe;
private HitboxComponent hitboxComponent;

/**
* Constructor for the AoEComponent.
*
* @param radius The radius of the area-of-effect.
*/
public AoeComponent(float radius) {
public EffectsComponent(float radius, ProjectileFactory.ProjectileEffects effect, boolean aoe) {
this.radius = radius;
this.effect = effect;
this.aoe = aoe;
}

@Override
Expand All @@ -37,7 +41,14 @@ private void onCollisionEnd(Fixture me, Fixture other) {
// Not triggered by hitbox, ignore
return;
}
applyAoeDamage();
switch (effect) {
case FIREBALL -> {
applyAoeDamage();
}
case BURN -> {}
case SLOW -> {}
case STUN -> {}
}
}
/**
* Apply damage to all entities within the area of effect (radius).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.csse3200.game.entities.factories;

import com.csse3200.game.components.AoeComponent;
import com.csse3200.game.components.EffectsComponent;
import com.csse3200.game.components.TouchAttackComponent;
import com.csse3200.game.components.tasks.TrajectTask;
import com.csse3200.game.ai.tasks.AITaskComponent;
Expand All @@ -23,9 +23,47 @@
*/
public class ProjectileFactory {

public enum ProjectileEffects {
FIREBALL, //fireball projectile - deals damage based on baseAttack
BURN, //burn projectile - does 5 extra ticks of damage over 5 seconds
SLOW, //slow projectile - slows entity by half for 5 seconds
STUN //stun projectile - stuns entity for 5 seconds
}

private static final NPCConfigs configs =
FileLoader.readClass(NPCConfigs.class, "configs/NPCs.json");

/**
* Creates a single-targeting projectile with specified effect
*
* @param target The enemy entities that the projectile collides with.
* @param destination The destination the projectile heads towards.
* @param speed The speed of the projectile.
* @param effect Specified effect from the ProjectileEffects enums
* @return Returns a new single-target projectile entity
*/
public static Entity createEffectProjectile(Entity target, Vector2 destination, Vector2 speed,
ProjectileEffects effect, boolean aoe) {
BaseEntityConfig config = configs.fireBall;
Entity projectile = createFireBall(target, destination, speed);

switch(effect) {
case FIREBALL -> {
projectile.addComponent(new EffectsComponent(3, ProjectileEffects.FIREBALL, aoe));
}
case BURN -> {
projectile.addComponent(new EffectsComponent(3, ProjectileEffects.BURN, aoe));
}
case SLOW -> {
projectile.addComponent(new EffectsComponent(3, ProjectileEffects.SLOW, aoe));
}
case STUN -> {
projectile.addComponent(new EffectsComponent(3, ProjectileEffects.STUN, aoe));
}
}
return projectile;
}

/**
* Creates a fireball Entity.
*
Expand Down Expand Up @@ -56,24 +94,24 @@ public static Entity createFireBall(Entity target, Vector2 destination, Vector2
return projectile;
}

/**
* Creates an AOE fireball Entity.
*
* @param target The enemy entities that the projectile collides with.
* @param destination The destination the projectile heads towards.
* @param speed The speed of the projectile.
* @param aoeSize The size of the AOE.
* @return Returns the new aoe projectile entity.
*/
public static Entity createAOEFireBall(Entity target, Vector2 destination, Vector2 speed, int aoeSize) {
BaseEntityConfig config = configs.fireBall;
Entity projectile = createFireBall(target, destination, speed);
projectile
// This is the component that allows the projectile to damage a specified target.
.addComponent(new AoeComponent(aoeSize));

return projectile;
}
// /**
// * Creates an AOE fireball Entity.
// *
// * @param target The enemy entities that the projectile collides with.
// * @param destination The destination the projectile heads towards.
// * @param speed The speed of the projectile.
// * @param aoeSize The size of the AOE.
// * @return Returns the new aoe projectile entity.
// */
// public static Entity createAOEFireBall(Entity target, Vector2 destination, Vector2 speed, int aoeSize) {
// BaseEntityConfig config = configs.fireBall;
// Entity projectile = createFireBall(target, destination, speed);
// projectile
// // This is the component that allows the projectile to damage a specified target.
// .addComponent(new EffectsComponent(aoeSize, ProjectileEffects.FIREBALL, true));
//
// return projectile;
// }

/**
* Creates a generic projectile entity that can be used for multiple types of * projectiles.
Expand Down

0 comments on commit 7e44262

Please sign in to comment.