Skip to content

Commit

Permalink
created new component to handle mob effects given by projectiles
Browse files Browse the repository at this point in the history
  • Loading branch information
gregchan550 committed Oct 9, 2023
1 parent 520e5eb commit e0aa90f
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ public void create() {
spawnGapScanners();

// spawnTNTTower();
// spawnWeaponTower();
spawnWeaponTower(new GridPoint2(10, 4));
// spawnGapScanners();
// spawnDroidTower();
// spawnFireWorksTower(); // Commented these out until they are needed for Demonstration
Expand Down Expand Up @@ -818,7 +818,7 @@ private void spawnSplitFireWorksFireBall(Vector2 position, short targetLayer, in
spawnEntity(projectile);
}

private void spawnWeaponTower() {
private void spawnWeaponTower(GridPoint2 pos) {
GridPoint2 minPos = new GridPoint2(0, 0);
GridPoint2 maxPos = terrain.getMapBounds(0).sub(5, 1);

Expand All @@ -832,6 +832,8 @@ private void spawnWeaponTower() {
spawnEntityAt(stunTower, randomPos2, true, true);
spawnEntityAt(wallTower, randomPos2, true, true);
}
// Entity fireTower = TowerFactory.createDroidTower();
// spawnEntityAt(fireTower, pos, true, true);
}

// * TEMPORARY FOR TESTING
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package com.csse3200.game.components.npc;

import com.csse3200.game.components.Component;
import com.csse3200.game.components.ProjectileEffects;
import com.csse3200.game.services.GameTime;
import com.csse3200.game.services.ServiceLocator;

public class MobEffectComponent extends Component {
private static final long EFFECT_DURATION = 5000;
private GameTime gameTime;
// effect flags
private boolean burnFlag;
private boolean slowFlag;
private boolean stunFlag;
private long burnTime;
private long slowTime;
private long stunTime;

public MobEffectComponent() {
gameTime = ServiceLocator.getTimeSource();
}

public void start() {
burnTime = 0;
slowTime = 0;
stunTime = 0;
}

@Override
public void update() {
// update effect flags
if (burnTime > gameTime.getTime()) {
burnFlag = true;
} else {
burnFlag = false;
}
if (slowTime > gameTime.getTime()) {
slowFlag = true;
} else {
slowFlag = false;
}
if (stunTime > gameTime.getTime()) {
stunFlag = true;
} else {
stunFlag = false;
}

// apply effects

}
public void applyEffect(ProjectileEffects effect) {
switch (effect) {
case BURN -> burnTime = gameTime.getTime() + EFFECT_DURATION;
case SLOW -> slowTime = gameTime.getTime() + EFFECT_DURATION;
case STUN -> stunTime = gameTime.getTime() + EFFECT_DURATION;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.csse3200.game.ai.tasks.DefaultTask;
import com.csse3200.game.ai.tasks.PriorityTask;
import com.csse3200.game.components.CombatStatsComponent;
import com.csse3200.game.components.EffectsComponent;
import com.csse3200.game.components.ProjectileEffects;
import com.csse3200.game.components.tasks.MovementTask;
import com.csse3200.game.entities.Entity;
Expand Down

0 comments on commit e0aa90f

Please sign in to comment.