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
Nested ClassesModifier and TypeClassDescriptionstatic classAbility.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 voidconfigure(int x, int y, double mdps) Configures ability before it can be started.abstract voidCalled byAbilitySystem.draw(Batch, float)each frame.voiddrawBatchAdditive(Batch batch, float deltaTime) Called byAbilitySystem.drawBatchAdditive(Batch, float)(Batch, float)} each frame.final floatGet coin multiplier for enemy kills with this ability.getType()Get ability typeabstract booleanisDone()Used to check if the ability has finished running.voidonDone()Called by theAbilitySystemonce it realizes that the abilityisDone()but before the ability gets unregistered.voidbooleanstart()Starts the ability.voidShows screen effects and UI particles.abstract voidupdate(float deltaTime) Called by the AbilitySystem each frame to update the state of this ability.voidMethods inherited from class com.prineside.tdi2.Registrable
isRegistered, setRegistered, setUnregistered 
- 
Method Details
- 
write
- Specified by:
 writein interfaceKryoSerializable- Overrides:
 writein classRegistrable
 - 
read
- Specified by:
 readin interfaceKryoSerializable- Overrides:
 readin 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 theAbilitySystemand 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 theAbilitySystemto 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 theAbilitySystemonce 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.
 
 
 -