Package cs.eng1.piazzapanic.stations
Class Station
- java.lang.Object
-
- com.badlogic.gdx.scenes.scene2d.Actor
-
- cs.eng1.piazzapanic.stations.Station
-
- Direct Known Subclasses:
ChoppingStation
,CookingStation
,IngredientStation
,RecipeStation
public class Station extends com.badlogic.gdx.scenes.scene2d.Actor implements Observer<Chef>
-
-
Field Summary
Fields Modifier and Type Field Description protected StationActionUI.ActionAlignment
actionAlignment
protected java.util.List<Subject<Chef>>
chefSubjects
protected int
id
protected boolean
inUse
protected Chef
nearbyChef
protected com.badlogic.gdx.graphics.g2d.TextureRegion
stationImage
protected StationUIController
uiController
-
Constructor Summary
Constructors Constructor Description Station(int id, com.badlogic.gdx.graphics.g2d.TextureRegion image, StationUIController uiController, StationActionUI.ActionAlignment alignment)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSubject(Subject<Chef> chefSubject)
void
deregisterFromAllSubjects()
void
doStationAction(StationAction.ActionType action)
Given an action, the station should attempt to do that action based on the chef that is nearby or what ingredient(s) are currently on the station.void
draw(com.badlogic.gdx.graphics.g2d.Batch batch, float parentAlpha)
void
drawDebug(com.badlogic.gdx.graphics.glutils.ShapeRenderer shapes)
Draw the outline of the shape of the station as a rectangle and draw a blue line from the centre of this station (which is an Observer) to the centre of the stationCollider that it is linked to (the Subject that this is registered to).protected void
drawFoodTexture(com.badlogic.gdx.graphics.g2d.Batch batch, com.badlogic.gdx.graphics.Texture foodTexture)
Take a food texture and render it on top of the station at a smaller size than the station.StationActionUI.ActionAlignment
getActionAlignment()
java.util.List<StationAction.ActionType>
getActionTypes()
int
getId()
java.util.List<Subject<Chef>>
getSubjects()
void
removeSubject(Subject<Chef> chefSubject)
void
reset()
Reset the station values to be the default.void
setImageRotation(float rotation)
void
update(Chef chef)
Take the chef sent from the Subject and decide what interactions are possible.-
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor
act, addAction, addCaptureListener, addListener, ancestorsVisible, ascendantsVisible, clear, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, debug, drawDebugBounds, fire, firstAscendant, getActions, getCaptureListeners, getColor, getDebug, getHeight, getListeners, getName, getOriginX, getOriginY, getParent, getRight, getRotation, getScaleX, getScaleY, getStage, getTop, getTouchable, getUserObject, getWidth, getX, getX, getY, getY, getZIndex, hasActions, hasKeyboardFocus, hasParent, hasScrollFocus, hit, isAscendantOf, isDescendantOf, isTouchable, isTouchFocusListener, isTouchFocusTarget, isVisible, localToActorCoordinates, localToAscendantCoordinates, localToParentCoordinates, localToScreenCoordinates, localToStageCoordinates, moveBy, notify, parentToLocalCoordinates, positionChanged, remove, removeAction, removeCaptureListener, removeListener, rotateBy, rotationChanged, scaleBy, scaleBy, scaleChanged, screenToLocalCoordinates, setBounds, setColor, setColor, setDebug, setHeight, setName, setOrigin, setOrigin, setOriginX, setOriginY, setParent, setPosition, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setStage, setTouchable, setUserObject, setVisible, setWidth, setX, setX, setY, setY, setZIndex, sizeBy, sizeBy, sizeChanged, stageToLocalCoordinates, toBack, toFront, toString
-
-
-
-
Field Detail
-
id
protected final int id
-
uiController
protected final StationUIController uiController
-
actionAlignment
protected final StationActionUI.ActionAlignment actionAlignment
-
stationImage
protected final com.badlogic.gdx.graphics.g2d.TextureRegion stationImage
-
inUse
protected boolean inUse
-
nearbyChef
protected Chef nearbyChef
-
-
Constructor Detail
-
Station
public Station(int id, com.badlogic.gdx.graphics.g2d.TextureRegion image, StationUIController uiController, StationActionUI.ActionAlignment alignment)
-
-
Method Detail
-
reset
public void reset()
Reset the station values to be the default.
-
setImageRotation
public void setImageRotation(float rotation)
-
draw
public void draw(com.badlogic.gdx.graphics.g2d.Batch batch, float parentAlpha)
- Overrides:
draw
in classcom.badlogic.gdx.scenes.scene2d.Actor
-
drawFoodTexture
protected void drawFoodTexture(com.badlogic.gdx.graphics.g2d.Batch batch, com.badlogic.gdx.graphics.Texture foodTexture)
Take a food texture and render it on top of the station at a smaller size than the station.- Parameters:
batch
- the sprite batch to draw rectangles to the screen.foodTexture
- the texture to be drawn onto the screen.
-
drawDebug
public void drawDebug(com.badlogic.gdx.graphics.glutils.ShapeRenderer shapes)
Draw the outline of the shape of the station as a rectangle and draw a blue line from the centre of this station (which is an Observer) to the centre of the stationCollider that it is linked to (the Subject that this is registered to).- Overrides:
drawDebug
in classcom.badlogic.gdx.scenes.scene2d.Actor
- Parameters:
shapes
- The renderer to use to draw debugging information
-
update
public void update(Chef chef)
Take the chef sent from the Subject and decide what interactions are possible.
-
addSubject
public void addSubject(Subject<Chef> chefSubject)
- Specified by:
addSubject
in interfaceObserver<Chef>
-
removeSubject
public void removeSubject(Subject<Chef> chefSubject)
- Specified by:
removeSubject
in interfaceObserver<Chef>
-
deregisterFromAllSubjects
public void deregisterFromAllSubjects()
- Specified by:
deregisterFromAllSubjects
in interfaceObserver<Chef>
-
getSubjects
public java.util.List<Subject<Chef>> getSubjects()
- Specified by:
getSubjects
in interfaceObserver<Chef>
-
getActionTypes
public java.util.List<StationAction.ActionType> getActionTypes()
- Returns:
- the list of possible actions that this station based on the current state
-
doStationAction
public void doStationAction(StationAction.ActionType action)
Given an action, the station should attempt to do that action based on the chef that is nearby or what ingredient(s) are currently on the station.- Parameters:
action
- the action that needs to be done by this station if it can.
-
getActionAlignment
public StationActionUI.ActionAlignment getActionAlignment()
- Returns:
- the direction in which the action buttons should be displayed.
-
getId
public int getId()
-
-