Class FoodDisplay
java.lang.Object
com.deco2800.game.components.Component
com.deco2800.game.rendering.RenderComponent
com.deco2800.game.ui.UIComponent
com.deco2800.game.components.foodAndwater.FoodDisplay
- All Implemented Interfaces:
Disposable
,Renderable
,java.lang.Comparable<Renderable>
public class FoodDisplay extends UIComponent
A ui component for displaying food system. Player lose a chicken for 3 sec
-
Field Summary
-
Constructor Summary
Constructors Constructor Description FoodDisplay()
-
Method Summary
Modifier and Type Method Description static void
addOrRemoveImage(int value)
Add/remove a imagevoid
create()
Creates reusable food ui styles and adds actors to the stage.void
dispose()
remove foodImage by useing a for loopvoid
draw(SpriteBatch batch)
Draw the renderable.java.util.ArrayList<Image>
getHunger()
return the foodImagestatic boolean
isHunger()
when player have no food, this function will return truevoid
update()
Reduce food when time increasevoid
updatePlayerHealth(int dis)
void
updatePlayerTimerUI(int dis)
Updates the Chicken ui time by time increase.Methods inherited from class com.deco2800.game.components.Component
earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate
-
Field Details
-
Constructor Details
-
FoodDisplay
public FoodDisplay()
-
-
Method Details
-
create
public void create()Creates reusable food ui styles and adds actors to the stage. And starts the counting the time.- Overrides:
create
in classUIComponent
-
draw
Description copied from class:RenderComponent
Draw the renderable. Should be called only by the renderer, not manually.- Specified by:
draw
in classRenderComponent
- Parameters:
batch
- Batch to render to.
-
update
public void update()Reduce food when time increase -
updatePlayerHealth
public void updatePlayerHealth(int dis) -
updatePlayerTimerUI
public void updatePlayerTimerUI(int dis)Updates the Chicken ui time by time increase. -
dispose
public void dispose()remove foodImage by useing a for loop- Specified by:
dispose
in interfaceDisposable
- Overrides:
dispose
in classRenderComponent
-
getHunger
return the foodImage -
addOrRemoveImage
public static void addOrRemoveImage(int value)Add/remove a image- Parameters:
value
- = 1, add a image;value
- = -1, remove a image
-
isHunger
public static boolean isHunger()when player have no food, this function will return true
-