Skip to content

Commit

Permalink
Added back in mob drops
Browse files Browse the repository at this point in the history
  • Loading branch information
Hasakev committed Oct 16, 2023
1 parent 292a185 commit d70f4dd
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
//import com.csse3200.game.rendering.DebugRenderer;


/// THIS CODE IS REDUNDANT ///

/**
* Task that prints a message to the terminal whenever it is called.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.csse3200.game.components.tasks.mobtask;

import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Timer;
import com.csse3200.game.ai.tasks.DefaultTask;
Expand All @@ -8,6 +9,7 @@
import com.csse3200.game.components.ProjectileEffects;
import com.csse3200.game.components.tasks.MovementTask;
import com.csse3200.game.entities.Entity;
import com.csse3200.game.entities.factories.DropFactory;
import com.csse3200.game.entities.factories.ProjectileFactory;
import com.csse3200.game.physics.PhysicsLayer;
import com.csse3200.game.physics.components.HitboxComponent;
Expand All @@ -32,6 +34,9 @@ public class MobTask extends DefaultTask implements PriorityTask {
private static final long RANGE_ATTACK_SPEED = 5000;
private static final float MELEE_ATTACK_RANGE = 0.2f;

private static final float CRYSTAL_DROP_RATE = 0.1f;
private static final float SCRAP_DROP_RATE = 0.6f;

// Private variables
private final MobType mobType;
private State state = State.DEFAULT;
Expand Down Expand Up @@ -120,6 +125,7 @@ public void update() {
} else if (deathFlag && animation.isFinished()) {
ServiceLocator.getWaveService().updateEnemyCount();
mob.setFlagForDelete(true);
dropCurrency();
}

if(gameTime.getTime() >= dodgeEndTime) {
Expand Down Expand Up @@ -329,4 +335,20 @@ public int getPriority() {
public void setDodge(boolean dodgeFlag) {
this.canDodge = dodgeFlag;
}

private void dropCurrency() {
float randomValue = MathUtils.random(0,1);
Entity currency;
if (randomValue <= CRYSTAL_DROP_RATE) {
currency = DropFactory.createCrystalDrop();

}
else if (randomValue <= SCRAP_DROP_RATE) {
currency = DropFactory.createScrapDrop();

}
currency.setPosition(mob.getPosition().x,mob.getPosition().y);
ServiceLocator.getEntityService().register(currency);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import com.csse3200.game.services.GameTime;
import com.csse3200.game.services.ServiceLocator;

//CODE IS REDUNDANT ///

/**
* Task that prints a message to the terminal whenever it is called.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ public static Entity createIceBoss(int health) {
* @return a base mob boss entity
*/
public static Entity createBaseBoss() {

return new Entity()
.addComponent(new PhysicsComponent())
// .addComponent(new ColliderComponent())
Expand Down

0 comments on commit d70f4dd

Please sign in to comment.