Skip to content

Commit

Permalink
refactor: Changed BossKing => MobBoss.
Browse files Browse the repository at this point in the history
  • Loading branch information
JSLLW committed Sep 16, 2023
1 parent 14d3f70 commit 01b5ed4
Show file tree
Hide file tree
Showing 7 changed files with 850 additions and 57 deletions.
801 changes: 801 additions & 0 deletions hs_err_pid27428.log

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion source/core/assets/configs/Boss.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"BossKing": {
"MobBoss": {
"health": 100,
"baseAttack": 25,
"spookyFactor": 7
Expand Down
2 changes: 1 addition & 1 deletion source/core/assets/replay_pid2865.log
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ instanceKlass @bci com/csse3200/game/components/npc/Boss1AnimationController cr
instanceKlass @bci com/csse3200/game/components/npc/Boss1AnimationController create ()V 66 <appendix> member <vmtarget> ; # com/csse3200/game/components/npc/Boss1AnimationController$$Lambda$104+0x0000000800ceca98
instanceKlass @bci com/csse3200/game/components/npc/Boss1AnimationController create ()V 48 <appendix> member <vmtarget> ; # com/csse3200/game/components/npc/Boss1AnimationController$$Lambda$103+0x0000000800cec888
instanceKlass @bci com/csse3200/game/components/npc/Boss1AnimationController create ()V 30 <appendix> member <vmtarget> ; # com/csse3200/game/components/npc/Boss1AnimationController$$Lambda$102+0x0000000800cec678
instanceKlass com/csse3200/game/entities/factories/BossKingFactory
instanceKlass com/csse3200/game/entities/factories/MobBossFactory
instanceKlass java/util/stream/AbstractSpinedBuffer
instanceKlass java/util/stream/Node$Builder$OfInt
instanceKlass java/util/stream/Node$Builder
Expand Down
62 changes: 27 additions & 35 deletions source/core/src/main/com/csse3200/game/areas/ForestGameArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,22 @@

import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.math.GridPoint2;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import com.csse3200.game.components.ProjectileEffects;
import com.csse3200.game.areas.terrain.TerrainFactory;
import com.csse3200.game.areas.terrain.TerrainFactory.TerrainType;
import com.csse3200.game.components.TouchAttackComponent;
import com.csse3200.game.components.player.PlayerStatsDisplay;
import com.csse3200.game.entities.Entity;
import com.csse3200.game.entities.factories.*;
import com.csse3200.game.physics.PhysicsLayer;
import com.csse3200.game.utils.math.RandomUtils;
import com.csse3200.game.services.ResourceService;
import com.csse3200.game.services.GameEndService;
import com.csse3200.game.services.ServiceLocator;
import com.csse3200.game.components.gamearea.GameAreaDisplay;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Random;
import java.util.Timer;


import static com.csse3200.game.entities.factories.NPCFactory.createGhost;

import java.util.ArrayList;
import java.util.TimerTask;

/** Forest area for the demo game with trees, a player, and some enemies. */
Expand All @@ -37,8 +29,8 @@ public class ForestGameArea extends GameArea {
private static final int NUM_BOSS = 4;


private static final int NUM_BOSSKING2=3;
private static final int NUM_BOSSKING1=1;
private static final int NUM_MOBBOSS2=3;
private static final int NUM_MOBBOSS1=1;

private int wave = 0;
private Timer waveTimer;
Expand Down Expand Up @@ -168,8 +160,8 @@ public class ForestGameArea extends GameArea {
// Variables to be used with spawn projectile methods. This is the variable
// that should occupy the direction param.
private static final int towardsMobs = 100;
private Entity bossKing2;
private Entity bossKing1;
private Entity mobBoss2;
private Entity mobBoss1;

/**
* Initialise this ForestGameArea to use the provided TerrainFactory.
Expand Down Expand Up @@ -209,10 +201,10 @@ private void spawnWave() {
spawnXenoGrunts();
break;
case 3:
bossKing2 = spawnBossKing2();
mobBoss2 = spawnMobBoss2();
break;
case 4:
bossKing2 = spawnBossKing2();
mobBoss2 = spawnMobBoss2();
break;
default:
// Handle other wave scenarios if needed
Expand Down Expand Up @@ -248,7 +240,7 @@ public void create() {
spawnEffectProjectile(new Vector2(2, 6), PhysicsLayer.NPC, towardsMobs, new Vector2(2f, 2f), ProjectileEffects.SLOW, false);
spawnXenoGrunts();
spawnWeaponTower();
//bossKing1 = spawnBossKing1();
//mobBoss1 = spawnMobBoss1();
startWaveTimer();
// spawnIncome();
spawnScrap();
Expand All @@ -257,7 +249,7 @@ public void create() {
spawnGapScanners();
spawnDroidTower();

bossKing2 = spawnBossKing2();
mobBoss2 = spawnMobBoss2();

}

Expand Down Expand Up @@ -382,7 +374,7 @@ private Entity spawnPlayer(GridPoint2 position) {
// }
// }

// private Entity spawnBossKing1() {
// private Entity spawnMobBoss1() {
// GridPoint2 minPos = new GridPoint2(0, 0);
// GridPoint2 maxPos = terrain.getMapBounds(0).sub(2, 2);
// GridPoint2 randomPos
Expand All @@ -393,18 +385,18 @@ private Entity spawnPlayer(GridPoint2 position) {
// }


private Entity spawnBossKing1() {
private Entity spawnMobBoss1() {
int[] pickedLanes = new Random().ints(0, 8)
.distinct().limit(5).toArray();
for (int i = 0; i < NUM_BOSSKING1; i++) {
for (int i = 0; i < NUM_MOBBOSS1; i++) {
GridPoint2 randomPos = new GridPoint2(19, pickedLanes[i]);
bossKing1 = BossKingFactory.createBossKing1(player, pickedLanes[i]);
spawnEntityAt(bossKing1,
mobBoss1 = MobBossFactory.createMobBoss1(player, pickedLanes[i]);
spawnEntityAt(mobBoss1,
randomPos,
true,
false);
}
return bossKing1;
return mobBoss1;
}


Expand Down Expand Up @@ -452,18 +444,18 @@ private void spawnProjectile(Vector2 position, short targetLayer, int space, int
}


// private Entity spawnBossKing() {
// private Entity spawnMobBoss() {
// for (int i = 0; i < NUM_BOSS; i++) {
// int fixedX = terrain.getMapBounds(0).x - 1; // Rightmost x-coordinate
// int randomY = MathUtils.random(0, maxPos.y);
// GridPoint2 randomPos = new GridPoint2(fixedX, randomY);
// bossKing1 = BossKingFactory.createBossKing1(player);
// spawnEntityAt(bossKing1,
// mobBoss1 = MobBossFactory.createMobBoss1(player);
// spawnEntityAt(mobBoss1,
// randomPos,
// true,
// false);
// }
// return bossKing1;
// return mobBoss1;
//
// }

Expand Down Expand Up @@ -492,35 +484,35 @@ private void spawnXenoGrunts() {
//
// }

// private Entity spawnBossKing2() {
// private Entity spawnMobBoss2() {
// GridPoint2 minPos = new GridPoint2(0, 0);
// GridPoint2 maxPos = terrain.getMapBounds(0).sub(2, 2);
//
// for (int i = 0; i < NUM_BOSS; i++) {
// int fixedX = terrain.getMapBounds(0).x - 1; // Rightmost x-coordinate
// int randomY = MathUtils.random(0, maxPos.y);
// GridPoint2 randomPos = new GridPoint2(fixedX, randomY);
// bossKing2 = BossKingFactory.createBossKing2(player);
// spawnEntityAt(bossKing2,
// mobBoss2 = MobBossFactory.createMobBoss2(player);
// spawnEntityAt(mobBoss2,
// randomPos,
// true,
// false);
// }
// return bossKing2;
// return mobBoss2;
// }

private Entity spawnBossKing2() {
private Entity spawnMobBoss2() {
int[] pickedLanes = new Random().ints(0, 8)
.distinct().limit(5).toArray();
for (int i = 0; i < NUM_BOSSKING2; i++) {
for (int i = 0; i < NUM_MOBBOSS2; i++) {
GridPoint2 randomPos = new GridPoint2(19, pickedLanes[i]);
bossKing2 = BossKingFactory.createBossKing2(player);
spawnEntityAt(bossKing2,
mobBoss2 = MobBossFactory.createMobBoss2(player);
spawnEntityAt(mobBoss2,
randomPos,
true,
false);
}
return bossKing2;
return mobBoss2;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* Defines the properties stored in ghost king config files to be loaded by the NPC Factory.
*/
public class BossKingConfigs extends BaseEntityConfig {
public class MobBossConfigs extends BaseEntityConfig {
public int spookyFactor = 0;
public int health = 1;
public int baseAttack = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ public class NPCConfigs {
new ArrayList<Weapon>(),
10);

public BossKingConfigs BossKing = new BossKingConfigs();
public MobBossConfigs MobBoss = new MobBossConfigs();

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import com.csse3200.game.components.tasks.bosstask.RangeBossTask;
import com.csse3200.game.components.tasks.bosstask.bossDeathTask;
import com.csse3200.game.entities.Entity;
import com.csse3200.game.entities.configs.BossKingConfigs;
import com.csse3200.game.entities.configs.MobBossConfigs;
import com.csse3200.game.entities.configs.NPCConfigs;
import com.csse3200.game.files.FileLoader;
import com.csse3200.game.physics.PhysicsLayer;
Expand All @@ -19,16 +19,16 @@
import com.csse3200.game.rendering.AnimationRenderComponent;
import com.csse3200.game.services.ServiceLocator;

public class BossKingFactory {
public class MobBossFactory {

private static final NPCConfigs configs = FileLoader.readClass(NPCConfigs.class, "configs/Boss.json");
private static final int PRIORITY = 1;
private static final int BOSS_MOB_AGRO_RANGE = 10;

// Create Boss King 1
public static Entity createBossKing1(Entity target, int numLane) {
BossKingConfigs config = configs.BossKing;
Entity bossKing1 = createBaseBoss(target);
public static Entity createMobBoss1(Entity target, int numLane) {
MobBossConfigs config = configs.MobBoss;
Entity mobBoss1 = createBaseBoss(target);

AITaskComponent aiTaskComponent1 = new AITaskComponent()
.addTask(new FinalBossMovementTask(1f, numLane))
Expand All @@ -39,21 +39,21 @@ public static Entity createBossKing1(Entity target, int numLane) {
ServiceLocator.getResourceService().getAsset("images/mobs/robot.atlas", TextureAtlas.class));
animator1.addAnimation("Walk", 0.3f, Animation.PlayMode.LOOP_REVERSED);

bossKing1.addComponent(new CombatStatsComponent(config.health, config.baseAttack))
mobBoss1.addComponent(new CombatStatsComponent(config.health, config.baseAttack))
.addComponent(animator1)
.addComponent(aiTaskComponent1)
.addComponent(new Boss1AnimationController());

bossKing1.getComponent(AnimationRenderComponent.class).scaleEntity();
bossKing1.setScale(1f, 1f);
mobBoss1.getComponent(AnimationRenderComponent.class).scaleEntity();
mobBoss1.setScale(1f, 1f);

return bossKing1;
return mobBoss1;
}

// Create Boss King 2
public static Entity createBossKing2(Entity target) {
BossKingConfigs config = configs.BossKing;
Entity bossKing2 = createBaseBoss(target);
public static Entity createMobBoss2(Entity target) {
MobBossConfigs config = configs.MobBoss;
Entity mobBoss2 = createBaseBoss(target);

AITaskComponent aiTaskComponent2 = new AITaskComponent()
.addTask(new RangeBossTask(2f));
Expand All @@ -69,17 +69,17 @@ public static Entity createBossKing2(Entity target) {
animator2.addAnimation("A2", 0.3f, Animation.PlayMode.LOOP);
animator2.addAnimation("Hurt", 0.3f, Animation.PlayMode.LOOP);

bossKing2.addComponent(new CombatStatsComponent(config.health, config.baseAttack))
mobBoss2.addComponent(new CombatStatsComponent(config.health, config.baseAttack))
.addComponent(animator2)
.addComponent(aiTaskComponent2)
.addComponent(new Boss2AnimationController())
.addComponent(new PhysicsComponent());

bossKing2.getComponent(AnimationRenderComponent.class).scaleEntity();
bossKing2.scaleHeight(3f);
bossKing2.scaleWidth(3f);
mobBoss2.getComponent(AnimationRenderComponent.class).scaleEntity();
mobBoss2.scaleHeight(3f);
mobBoss2.scaleWidth(3f);

return bossKing2;
return mobBoss2;
}

// Create the base boss entity
Expand All @@ -96,7 +96,7 @@ private static Entity createBaseBoss(Entity target) {
return boss;
}

private BossKingFactory() {
private MobBossFactory() {
throw new IllegalStateException("Instantiating static util class");
}
}

0 comments on commit 01b5ed4

Please sign in to comment.