Skip to content

Commit

Permalink
Add various mobtypes with splitmoblings component
Browse files Browse the repository at this point in the history
  • Loading branch information
freshc0w committed Oct 13, 2023
1 parent 5d80561 commit 033694d
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.csse3200.game.components.npc;

import com.csse3200.game.components.Component;
import com.csse3200.game.components.tasks.MobTask.MobType;
import com.csse3200.game.entities.Entity;
import com.csse3200.game.entities.factories.NPCFactory;
import com.csse3200.game.services.ServiceLocator;
Expand All @@ -17,6 +18,8 @@
*/
public class SplitMoblings extends Component {
private int amount;
private MobType mobType;
private int baseMoblingHealth = 60;
private float scaleX, scaleY;
public static final float DEFAULT_MINIFIED_SCALE = 0.75f;
public static final double OFFSET_DISTANCE = 1.5;
Expand All @@ -31,10 +34,12 @@ public class SplitMoblings extends Component {
* Initialises a component that splits mob into multiple moblings. Amount of
* moblings split based on the amount provided param.
*
* @param amount Amount of moblings to be split.
* @param mobType Type of moblings split on death based on the MobType enum.
* @param amount Amount of moblings to be split.
* @require amount > 0
*/
public SplitMoblings(int amount) {
public SplitMoblings(MobType mobType, int amount) {
this.mobType = mobType;
this.amount = amount;
scaleX = scaleY = DEFAULT_MINIFIED_SCALE;
}
Expand All @@ -44,12 +49,15 @@ public SplitMoblings(int amount) {
* moblings split is based on the amount provided param.
* The overalling scaling (x and y) is also altered in the param.
*
* @param amount Amount of moblings to be split.
* @param scale X and Y scaling of the moblings in respect to the original size
* of the mobs.
* @param mobType Type of moblings split on death based on the MobType enum.
* @param amount Amount of moblings to be split.
* @param scale X and Y scaling of the moblings in respect to the original
* size
* of the mobs.
* @require amount > 0
*/
public SplitMoblings(int amount, float scale) {
public SplitMoblings(MobType mobType, int amount, float scale) {
this.mobType = mobType;
this.amount = amount;
this.scaleX = this.scaleY = scale;
}
Expand All @@ -59,12 +67,14 @@ public SplitMoblings(int amount, float scale) {
* moblings split is based on the amount provided param.
* The individual scaling (x and y) is also altered in the param.
*
* @param amount Amount of moblings to be split.
* @param scaleX X scaling of the moblings compared to original size.
* @param scaleY Y scaling of the moblings compared to original size.
* @param mobType Type of moblings split on death based on the MobType enum.
* @param amount Amount of moblings to be split.
* @param scaleX X scaling of the moblings compared to original size.
* @param scaleY Y scaling of the moblings compared to original size.
* @require amount > 0
*/
public SplitMoblings(int amount, float scaleX, float scaleY) {
public SplitMoblings(MobType mobType, int amount, float scaleX, float scaleY) {
this.mobType = mobType;
this.amount = amount;
this.scaleX = scaleX;
this.scaleY = scaleY;
Expand Down Expand Up @@ -120,15 +130,26 @@ private void onDeath() {
*/
public void spawnAdditionalMob(float positionX, float positionY,
float initialScaleX, float initialScaleY) {
// MAKE A SWITCH CASE STATEMENT HERE, ASK JASON HOW TO
// Entity waterSlime = NPCFactory.createBaseWaterSlime(60);
Entity waterSlime = NPCFactory.createNightBorne(60);
waterSlime.setPosition(positionX, positionY);
Entity entityType;
switch (mobType) {
case WATER_SLIME -> {
entityType = NPCFactory.createBaseWaterSlime(baseMoblingHealth);
}

case NIGHT_BORNE -> {
entityType = NPCFactory.createNightBorne(baseMoblingHealth);
}

default -> {
entityType = NPCFactory.createBaseWaterSlime(baseMoblingHealth);
}
}
entityType.setPosition(positionX, positionY);

waterSlime.setScale(initialScaleX * scaleX, initialScaleY * scaleY);
// waterSlime.setScale(initialScaleX, initialScaleY);
entityType.setScale(initialScaleX * scaleX, initialScaleY * scaleY);

ServiceLocator.getEntityService().register(waterSlime);
ServiceLocator.getEntityService().register(entityType);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ public static Entity createSplittingXenoGrunt(int health) {
Entity splitXenoGrunt = createXenoGrunt(health)
// add the scaling yourself. can also scale the X and Y component,
// leading to some very interesting mob designs.
.addComponent(new SplitMoblings(7, 0.5f))
.addComponent(new SplitMoblings(MobType.WATER_SLIME, 7, 0.5f))
.addComponent(new DodgingComponent(PhysicsLayer.PROJECTILE, 0.25f));

// * TEMPORARY TESTING FOR PROJECTILE DODGING
Expand All @@ -535,7 +535,7 @@ public static Entity createSplittingXenoGrunt(int health) {
public static Entity createSplittingWaterSlime(int health) {
Entity splitWaterSlime = createBaseWaterSlime(health)

.addComponent(new SplitMoblings(7, 0.5f));
.addComponent(new SplitMoblings(MobType.WATER_SLIME, 7, 0.5f));

return splitWaterSlime;
}
Expand All @@ -549,7 +549,7 @@ public static Entity createSplittingWaterSlime(int health) {
public static Entity createSplittingNightBorne(int health) {
Entity splitWaterSlime = createNightBorne(health)

.addComponent(new SplitMoblings(7, 0.5f));
.addComponent(new SplitMoblings(MobType.NIGHT_BORNE, 7, 0.5f));

return splitWaterSlime;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import com.badlogic.gdx.math.Vector2;
import com.csse3200.game.components.npc.SplitMoblings;
import com.csse3200.game.components.tasks.MobTask.MobType;
import com.csse3200.game.entities.Entity;
import com.csse3200.game.entities.EntityService;
import com.csse3200.game.entities.factories.NPCFactory;
Expand Down Expand Up @@ -309,25 +310,26 @@ public void shouldScaleXAndYbasedOnParamsMultiAmt() {
}
}

// For now water slimes will be moblings spawned
Entity createSplitMob(int amount) {
Entity mob = NPCFactory.createBaseWaterSlime(10);
mob.addComponent(new CombatStatsComponent(10, 10));
mob.addComponent(new SplitMoblings(amount));
mob.addComponent(new SplitMoblings(MobType.WATER_SLIME, amount));
ServiceLocator.getEntityService().register(mob);
return mob;
}

Entity createSplitMob(int amount, float scale) {
Entity mob = NPCFactory.createBaseWaterSlime(10);
mob.addComponent(new SplitMoblings(amount, scale));
mob.addComponent(new SplitMoblings(MobType.WATER_SLIME, amount, scale));
mob.addComponent(new CombatStatsComponent(10, 10));
ServiceLocator.getEntityService().register(mob);
return mob;
}

Entity createSplitMob(int amount, float scaleX, float scaleY) {
Entity mob = NPCFactory.createBaseWaterSlime(10);
mob.addComponent(new SplitMoblings(amount, scaleX, scaleY));
mob.addComponent(new SplitMoblings(MobType.WATER_SLIME, amount, scaleX, scaleY));
mob.addComponent(new CombatStatsComponent(10, 10));
ServiceLocator.getEntityService().register(mob);
return mob;
Expand Down

0 comments on commit 033694d

Please sign in to comment.