Class TimedCollectable

All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
Direct Known Subclasses:
DamageDeflect, SpeedBoost

public abstract class TimedCollectable extends Collectable
A TimedCollectable is a Collectable, that applies an effect to the Player for a specified time. After that the effect is removed.
  • Field Details

    • duration

      protected float duration
      Duration of the effect in seconds
    • elapsedTIme

      protected float elapsedTIme
  • Constructor Details

    • TimedCollectable

      public TimedCollectable(com.badlogic.gdx.math.Vector2 position, com.badlogic.gdx.physics.box2d.World world, box2dLight.RayHandler rayHandler, com.badlogic.gdx.graphics.g2d.TextureAtlas textureAtlas)
  • Method Details

    • apply

      protected abstract void apply(Player player)
      Applies the effect to the player. The effect is restored by restore(Player)
      Parameters:
      player - the Player to apply the effect to.
    • restore

      public abstract void restore(Player player)
    • getDurationAndElapsed

      public Float[] getDurationAndElapsed()
      Gets Duration and Elapsed time.
      Returns:
      Array of size 2 with first the elapsed time and the duration;
    • update

      public void update(float deltaTime)
      Description copied from class: GameElement
      Updates the Object
      Overrides:
      update in class Collectable
      Parameters:
      deltaTime - Time since last frame.
    • collect

      public void collect(Player player)
      Description copied from class: Collectable
      Called when a Player is collects it.
      Specified by:
      collect in class Collectable
      Parameters:
      player - the Player that collected it
    • remove

      public void remove()
      Description copied from class: Collectable
      Removes the collectable
      Overrides:
      remove in class Collectable
    • dispose

      public void dispose()
      Specified by:
      dispose in interface com.badlogic.gdx.utils.Disposable
      Overrides:
      dispose in class Collectable
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object