-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
created new component to handle mob effects given by projectiles
- Loading branch information
1 parent
520e5eb
commit e0aa90f
Showing
3 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
source/core/src/main/com/csse3200/game/components/npc/MobEffectComponent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters