Package com.prineside.tdi2
Class Ability
java.lang.Object
com.prineside.tdi2.Registrable
com.prineside.tdi2.Ability
- All Implemented Interfaces:
KryoSerializable
- Direct Known Subclasses:
BallLightningAbility
,BlizzardAbility
,BulletWallAbility
,FireballAbility
,FirestormAbility
,LoicAbility
,LoopAbility
,MagnetAbility
,NukeAbility
,OverloadAbility
,SmokeBombAbility
,ThunderAbility
,WindstormAbility
Abilities are temporary effects which are normally started by the player manually (for example,
FireballAbility
or NukeAbility
).
They are shown in the game's UI during the run, and most levels allow to start a run with a different set of abilities.
AbilitySystem
is responsible for storing and handling the abilities.
Usage example:
Ability ability = S.ability.registerConfigureAndStartAbility(AbilityType.FIREBALL, 150, 250, S.enemy.getTowersMaxDps());
if (ability != null) {
ability.startEffects();
}
See AbilitySystem
for more ways of using abilities.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Ability.Factory<T extends Ability>
Ability type factory is responsible for creation of abilities and provides some additional info for some particular type of ability (such as ability name and color). -
Field Summary
Fields inherited from class com.prineside.tdi2.Registrable
S
-
Method Summary
Modifier and TypeMethodDescriptionabstract void
configure
(int x, int y, double mdps) Configures ability before it can be started.abstract void
Called byAbilitySystem.draw(Batch, float)
each frame.void
drawBatchAdditive
(Batch batch, float deltaTime) Called byAbilitySystem.drawBatchAdditive(Batch, float)
(Batch, float)} each frame.final float
Get coin multiplier for enemy kills with this ability.getType()
Get ability typeabstract boolean
isDone()
Used to check if the ability has finished running.void
onDone()
Called by theAbilitySystem
once it realizes that the abilityisDone()
but before the ability gets unregistered.void
boolean
start()
Starts the ability.void
Shows screen effects and UI particles.abstract void
update
(float deltaTime) Called by the AbilitySystem each frame to update the state of this ability.void
Methods inherited from class com.prineside.tdi2.Registrable
isRegistered, setRegistered, setUnregistered
-
Method Details
-
write
- Specified by:
write
in interfaceKryoSerializable
- Overrides:
write
in classRegistrable
-
read
- Specified by:
read
in interfaceKryoSerializable
- Overrides:
read
in classRegistrable
-
getType
Get ability type- Returns:
- type of this ability
-
configure
public abstract void configure(int x, int y, double mdps) Configures ability before it can be started. Sets the position on map where this ability will start - depending on ability type, it can apply an effect in that point. Some abilities can ignore the position completely.- Parameters:
x
- X position (px) where this ability will starty
- Y position (px) where this ability will startmdps
- MDPS value which will be used to calculate the efficiency of this ability. NormallyS.enemy.getTowersMaxDps()
is used here.
-
start
public boolean start()Starts the ability. Normally only called by theAbilitySystem
and not manually. UseAbilitySystem.startAbility(Ability)
to trigger the events and handle the ability properly.- Returns:
- true if started, false if can't start and should be ignored
-
startEffects
public void startEffects()Shows screen effects and UI particles. It is suggested not to call this method if ability gets started frequently, as it may flash the screen too much. -
update
public abstract void update(float deltaTime) Called by the AbilitySystem each frame to update the state of this ability.- Parameters:
deltaTime
- delta time since the last frame (fixed)
-
isDone
public abstract boolean isDone()Used to check if the ability has finished running. Used by theAbilitySystem
to finish the handling of the ability.- Returns:
- true if ability has finished running and can be unregistered from the game state
-
onDone
public void onDone()Called by theAbilitySystem
once it realizes that the abilityisDone()
but before the ability gets unregistered. Usually used by the implementations of this class to remove particle effects and event listeners. -
draw
Called byAbilitySystem.draw(Batch, float)
each frame. Allows to update realtime graphics of the ability.- Parameters:
batch
- Batch used for renderingdeltaTime
- delta time since the last frame (dynamic)
-
drawBatchAdditive
Called byAbilitySystem.drawBatchAdditive(Batch, float)
(Batch, float)} each frame. Allows to update realtime graphics of the ability and render additive graphics on top of the regular (draw) ones.- Parameters:
batch
- Batch used for renderingdeltaTime
- delta time since the last frame (dynamic)
-
getKilledEnemiesCoinMultiplier
public final float getKilledEnemiesCoinMultiplier()Get coin multiplier for enemy kills with this ability.- Returns:
- coin multiplier for enemy kills, which is 1.0 by default and depends on GameValues and ability type.
-