Package de.tum.cit.ase.maze.objects
Class CollectableManager
java.lang.Object
de.tum.cit.ase.maze.objects.CollectableManager
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable
Manages collectables like
Collectable
or TimedCollectable
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
Task that schedules a respawn by aTimer
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCollectableManager
(com.badlogic.gdx.physics.box2d.World world, box2dLight.RayHandler rayHandler, boolean canRespawn) This class manages the collectables in the game. -
Method Summary
Modifier and TypeMethodDescriptionvoid
dispose()
com.badlogic.gdx.utils.Timer
getTimer()
void
render
(com.badlogic.gdx.graphics.g2d.SpriteBatch spriteBatch) Renders allCollectables
.protected final void
Schedules a respawn.final void
spawn
(@NonNull Class<? extends Collectable> collectableClass, float areaToCover) SpawnsCollectables
final void
spawn
(@NonNull Class<? extends Collectable> collectableClass, int amount) SpawnsCollectables
final void
spawn
(@NonNull Class<? extends Collectable> collectableClass, List<com.badlogic.gdx.math.Vector2> positionList) void
update
(float dt) Updates the collectables
-
Field Details
-
RESPAWN_TIME
public final float RESPAWN_TIME- See Also:
-
canRespawn
public boolean canRespawn
-
-
Constructor Details
-
CollectableManager
public CollectableManager(com.badlogic.gdx.physics.box2d.World world, box2dLight.RayHandler rayHandler, boolean canRespawn) This class manages the collectables in the game. It handles the spawning, respawning, rendering, and updating of collectables.
-
-
Method Details
-
update
public void update(float dt) Updates the collectables- Parameters:
dt
- delta time. SeeGraphics.getDeltaTime()
-
spawn
SpawnsCollectables
- Parameters:
collectableClass
- the class of theCollectable
to spawnamount
- amount to spawn
-
render
public void render(com.badlogic.gdx.graphics.g2d.SpriteBatch spriteBatch) Renders allCollectables
.- Parameters:
spriteBatch
- theSpriteBatch
to render
-
spawn
SpawnsCollectables
- Parameters:
collectableClass
- the class of theCollectable
to spawnareaToCover
- percentage of the area that will be covered
-
spawn
public final void spawn(@NonNull Class<? extends Collectable> collectableClass, List<com.badlogic.gdx.math.Vector2> positionList) -
scheduleRespawn
protected final void scheduleRespawn()Schedules a respawn. Called by therespawn task
. -
getTimer
public com.badlogic.gdx.utils.Timer getTimer() -
getRespawnTask
-
dispose
public void dispose()- Specified by:
dispose
in interfacecom.badlogic.gdx.utils.Disposable
-