Class Ability

All Implemented Interfaces:
KryoSerializable
Direct Known Subclasses:
BallLightningAbility, BlizzardAbility, BulletWallAbility, FireballAbility, FirestormAbility, LoicAbility, LoopAbility, MagnetAbility, NukeAbility, OverloadAbility, SmokeBombAbility, ThunderAbility, WindstormAbility

public abstract class Ability extends Registrable implements KryoSerializable

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.

  • Method Details

    • write

      public void write(Kryo kryo, Output output)
      Specified by:
      write in interface KryoSerializable
      Overrides:
      write in class Registrable
    • read

      public void read(Kryo kryo, Input input)
      Specified by:
      read in interface KryoSerializable
      Overrides:
      read in class Registrable
    • getType

      public AbilityType 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 start
      y - Y position (px) where this ability will start
      mdps - MDPS value which will be used to calculate the efficiency of this ability. Normally S.enemy.getTowersMaxDps() is used here.
    • start

      public boolean start()
      Starts the ability. Normally only called by the AbilitySystem and not manually. Use AbilitySystem.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 the AbilitySystem 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 the AbilitySystem once it realizes that the ability isDone() but before the ability gets unregistered. Usually used by the implementations of this class to remove particle effects and event listeners.
    • draw

      public abstract void draw(Batch batch, float deltaTime)
      Called by AbilitySystem.draw(Batch, float) each frame. Allows to update realtime graphics of the ability.
      Parameters:
      batch - Batch used for rendering
      deltaTime - delta time since the last frame (dynamic)
    • drawBatchAdditive

      public void drawBatchAdditive(Batch batch, float deltaTime)
      Called by AbilitySystem.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 rendering
      deltaTime - 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.