Skip to content

Commit

Permalink
removed unnecessary target arg in EngineerFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
The-AhmadAA committed Sep 7, 2023
1 parent fb36e25 commit 120dd79
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public void create() {
// Spawn Entities
player = spawnPlayer();
spawnWeaponTower();
spawnEngineer(player);
spawnEngineer();
bossKing1 = spawnBossKing1();
bossKing2 = spawnBossKing2();
}
Expand Down Expand Up @@ -445,12 +445,12 @@ private void spawnIncome() {
}
}

private void spawnEngineer(Entity target) {
private void spawnEngineer() {
GridPoint2 minPos = new GridPoint2(0, 0);
GridPoint2 maxPos = terrain.getMapBounds(0).sub(2, 2);
GridPoint2 maxPos = new GridPoint2(5, terrain.getMapBounds(0).sub(2, 2).y);
GridPoint2 randomPos = RandomUtils.random(minPos, maxPos);

Entity engineer = EngineerFactory.createEngineer(target);
Entity engineer = EngineerFactory.createEngineer();
spawnEntityAt(engineer, randomPos, true, true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.csse3200.game.ai.tasks.AITaskComponent;
import com.csse3200.game.components.tasks.EngineerCombatTask;
import com.csse3200.game.components.CombatStatsComponent;
import com.csse3200.game.components.TouchAttackComponent;
import com.csse3200.game.components.player.HumanAnimationController;
Expand Down Expand Up @@ -47,16 +46,16 @@ public class EngineerFactory {
*
* @return entity
*/
public static Entity createEngineer(Entity target) {
Entity engineer = createBaseHumanNPC(target);
public static Entity createEngineer() {
Entity engineer = createBaseHumanNPC();
BaseEntityConfig config = configs.engineer;

AnimationRenderComponent animator = new AnimationRenderComponent(
new TextureAtlas("images/engineers/engineer.atlas"));
animator.addAnimation("walk_left", 0.2f, Animation.PlayMode.LOOP);
animator.addAnimation("walk_right", 0.2f, Animation.PlayMode.LOOP);
animator.addAnimation("idle_right", 0.2f, Animation.PlayMode.LOOP);
animator.addAnimation("firing", 0.01f, Animation.PlayMode.NORMAL);
animator.addAnimation("firing", 0.05f, Animation.PlayMode.NORMAL);
animator.addAnimation("hit", 0.01f, Animation.PlayMode.NORMAL);
animator.addAnimation("death", 0.1f, Animation.PlayMode.NORMAL);

Expand All @@ -79,10 +78,8 @@ public static Entity createEngineer(Entity target) {
*
* @return entity
*/
public static Entity createBaseHumanNPC(Entity target) {
// AITaskComponent aiComponent =
// new AITaskComponent()
// .addTask(new HumanWanderTask(target, 1f));
public static Entity createBaseHumanNPC() {


Entity human =
new Entity()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.csse3200.game.ai.tasks.AITaskComponent;
import com.csse3200.game.entities.Entity;
import com.csse3200.game.extensions.GameExtension;
import com.csse3200.game.physics.PhysicsService;
Expand Down Expand Up @@ -56,13 +57,16 @@ void tearDown() {

@Test
void createEngineer() {
Entity engineer = EngineerFactory.createEngineer(target);
Entity engineer = EngineerFactory.createEngineer();
engineer.setPosition(10f, 10f);
assertNotNull(engineer);
assert(!engineer.getFlagForDelete());
assert engineer.getPosition().x == 10f && engineer.getPosition().y == 10f;
}

@Test
void createBaseHumanNPC() {
Entity human = EngineerFactory.createBaseHumanNPC(target);
Entity human = EngineerFactory.createBaseHumanNPC();
assertNotNull(human);
}
}

0 comments on commit 120dd79

Please sign in to comment.