Class WaterDisplay
java.lang.Object
com.deco2800.game.components.Component
com.deco2800.game.rendering.RenderComponent
com.deco2800.game.ui.UIComponent
com.deco2800.game.components.foodAndwater.WaterDisplay
- All Implemented Interfaces:
Disposable
,Renderable
,java.lang.Comparable<Renderable>
public class WaterDisplay extends UIComponent
A ui component for displaying water system. Player lose a chicken for 2 sec
-
Field Summary
Fields Modifier and Type Field Description static java.util.ArrayList<Image>
waterImage
-
Constructor Summary
Constructors Constructor Description WaterDisplay()
-
Method Summary
Modifier and Type Method Description static void
addOrRemoveImage(int value)
Add/remove a imagevoid
create()
Creates reusable water ui styles and adds actors to the stage.void
dispose()
remove waterImage by using a for loopvoid
draw(SpriteBatch batch)
Draw the renderable.java.util.ArrayList<Image>
getThirst()
return the waterImagestatic boolean
isThirst()
when player have no water, this function will return truevoid
update()
Reduce water when time increasevoid
updatePlayerHealth(int dis)
void
updatePlayerTimerUI(int dis)
Updates the water 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
-
WaterDisplay
public WaterDisplay()
-
-
Method Details
-
create
public void create()Creates reusable water 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 water when time increase -
updatePlayerHealth
public void updatePlayerHealth(int dis) -
updatePlayerTimerUI
public void updatePlayerTimerUI(int dis)Updates the water ui time by time increase. -
dispose
public void dispose()remove waterImage by using a for loop- Specified by:
dispose
in interfaceDisposable
- Overrides:
dispose
in classRenderComponent
-
getThirst
return the waterImage -
addOrRemoveImage
public static void addOrRemoveImage(int value)Add/remove a image- Parameters:
value
- = 1, add a image;value
- = -1, remove a image
-
isThirst
public static boolean isThirst()when player have no water, this function will return true
-