Class TimedCollectable
java.lang.Object
de.tum.cit.ase.maze.objects.GameElement
de.tum.cit.ase.maze.objects.still.collectable.Collectable
de.tum.cit.ase.maze.objects.still.collectable.TimedCollectable
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
- Direct Known Subclasses:
DamageDeflect,SpeedBoost
A
TimedCollectable is a Collectable, that applies an effect to the Player for a specified time. After that the effect is removed.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected floatDuration of the effect in secondsprotected floatFields inherited from class de.tum.cit.ase.maze.objects.still.collectable.Collectable
active, frameHeight, frameWidth, light, rayHandler, removable, textureAtlas, textureRegion, ZOOMFields inherited from class de.tum.cit.ase.maze.objects.GameElement
body, texture, world -
Constructor Summary
ConstructorsConstructorDescriptionTimedCollectable(com.badlogic.gdx.math.Vector2 position, com.badlogic.gdx.physics.box2d.World world, box2dLight.RayHandler rayHandler, com.badlogic.gdx.graphics.g2d.TextureAtlas textureAtlas) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidApplies the effect to the player.voidCalled when aPlayeris collects it.voiddispose()booleanFloat[]Gets Duration and Elapsed time.inthashCode()voidremove()Removes the collectableabstract voidRestores the changes made byapply(de.tum.cit.ase.maze.objects.dynamic.Player)toString()voidupdate(float deltaTime) Updates the ObjectMethods inherited from class de.tum.cit.ase.maze.objects.still.collectable.Collectable
createBoy, isActive, isRemovableMethods inherited from class de.tum.cit.ase.maze.objects.GameElement
render
-
Field Details
-
duration
protected float durationDuration 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
Applies the effect to the player. The effect is restored byrestore(Player)- Parameters:
player- thePlayerto apply the effect to.
-
restore
Restores the changes made byapply(de.tum.cit.ase.maze.objects.dynamic.Player) -
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:GameElementUpdates the Object- Overrides:
updatein classCollectable- Parameters:
deltaTime- Time since last frame.
-
collect
Description copied from class:CollectableCalled when aPlayeris collects it.- Specified by:
collectin classCollectable- Parameters:
player- thePlayerthat collected it
-
remove
public void remove()Description copied from class:CollectableRemoves the collectable- Overrides:
removein classCollectable
-
dispose
public void dispose()- Specified by:
disposein interfacecom.badlogic.gdx.utils.Disposable- Overrides:
disposein classCollectable
-
equals
-
hashCode
public int hashCode() -
toString
-