Skip to content

Commit

Permalink
Testing Engineer Entity
Browse files Browse the repository at this point in the history
  • Loading branch information
praneetdhoolia committed Sep 5, 2023
1 parent 81f1d2f commit 443c67a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
10 changes: 10 additions & 0 deletions source/core/src/main/com/csse3200/game/areas/ForestGameArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ public void create() {
spawnIncome();
spawnScrap();

spawnEngineer();
bossKing1 = spawnBossKing1();
bossKing2 = spawnBossKing2();

Expand Down Expand Up @@ -457,6 +458,15 @@ private void spawnIncome() {
spawnEntityAt(towerfactory, randomPos, true, true);
}
}

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

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


}
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public class HumanAnimationController extends Component {
AnimationRenderComponent animator;
// Sound runSound = ServiceLocator.getResourceService().getAsset(
// RUN_SFX, Sound.class);
Sound fireAutoSound = ServiceLocator.getResourceService().getAsset(
FIRE_AUTO_SFX, Sound.class);
// Sound fireAutoSound = ServiceLocator.getResourceService().getAsset(
// FIRE_AUTO_SFX, Sound.class);
// Sound fireSingleSound = ServiceLocator.getResourceService().getAsset(
// FIRE_SINGLE_SFX, Sound.class);
// Sound hitSound = ServiceLocator.getResourceService().getAsset(
Expand Down Expand Up @@ -77,7 +77,7 @@ void animateRightWalk() {

void animateFiring() {
animator.startAnimation(FIRE_ANIM);
fireAutoSound.play();
// fireAutoSound.play();
}

void animateHit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
* similar characteristics.
*/
public class EngineerFactory {

private static final int COMBAT_TASK_PRIORITY = 2;
private static final int ENGINEER_RANGE = 40;
private static final EngineerConfigs configs =
FileLoader.readClass(EngineerConfigs.class, "configs/Engineers.json");

Expand All @@ -54,6 +57,9 @@ public class EngineerFactory {
public static Entity createEngineer() {
Entity engineer = createBaseHumanNPC();
BaseEntityConfig config = configs.engineer;
AITaskComponent combatComponent =
new AITaskComponent()
.addTask(new EngineerCombatTask(COMBAT_TASK_PRIORITY, ENGINEER_RANGE));

AnimationRenderComponent animator = new AnimationRenderComponent(
new TextureAtlas("images/engineers/engineer.atlas"));
Expand All @@ -66,9 +72,10 @@ public static Entity createEngineer() {


engineer
.addComponent(new CombatStatsComponent(config.health, config.baseAttack))
.addComponent(animator)
.addComponent(new HumanAnimationController());
.addComponent(new CombatStatsComponent(config.health, config.baseAttack))
.addComponent(animator)
.addComponent(new HumanAnimationController());
//.addComponent(combatComponent);

engineer.getComponent(AnimationRenderComponent.class).scaleEntity();
engineer.setScale(1.5f, 1.2f);
Expand All @@ -83,7 +90,8 @@ public static Entity createEngineer() {
public static Entity createBaseHumanNPC() {
AITaskComponent aiComponent =
new AITaskComponent()
.addTask(new HumanWanderTask(new Vector2(0, 10f), 2f));
.addTask(new HumanWanderTask(new Vector2(0, 10f), 2f));


Entity human =
new Entity()
Expand Down

0 comments on commit 443c67a

Please sign in to comment.