Package com.csse3200.game.input
Class BuildInputComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.input.InputComponent
com.csse3200.game.input.BuildInputComponent
- All Implemented Interfaces:
com.badlogic.gdx.input.GestureDetector.GestureListener
,com.badlogic.gdx.InputProcessor
Input component for handling in-game tower building. Based on Team 5 implementation of
DropInputComponent
-
Field Summary
Fields inherited from class com.csse3200.game.input.InputComponent
priority
-
Constructor Summary
ConstructorDescriptionBuildInputComponent
(com.badlogic.gdx.graphics.Camera camera) Constructor for the BuildInputComponent -
Method Summary
Modifier and TypeMethodDescriptionvoid
buildTower
(int x, int y) Instantiates and spawns the selected tower at the given x y coordinates on the tile map.com.badlogic.gdx.graphics.Camera
Getter for the cameraboolean
touchDown
(int screenX, int screenY, int pointer, int button) When the mouse is clicked, this method is called.Methods inherited from class com.csse3200.game.input.InputComponent
create, dispose, fling, getPriority, keyDown, keyTyped, keyUp, longPress, mouseMoved, pan, panStop, pinch, pinchStop, pinchStopHandled, scrolled, setPriority, tap, touchDown, touchDragged, touchUp, zoom
Methods inherited from class com.csse3200.game.components.Component
earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
-
Constructor Details
-
BuildInputComponent
public BuildInputComponent(com.badlogic.gdx.graphics.Camera camera) Constructor for the BuildInputComponent- Parameters:
camera
- the camera to be used, this is the camera that the game is rendered with
-
-
Method Details
-
getCamera
public com.badlogic.gdx.graphics.Camera getCamera()Getter for the camera- Returns:
- the camera
-
touchDown
public boolean touchDown(int screenX, int screenY, int pointer, int button) When the mouse is clicked, this method is called. Checks that the mouse is clicked on an empty tile Instantiates a new Tower entity at the clicked location if valid, and decrements the cost of the build from the currency pool- Specified by:
touchDown
in interfacecom.badlogic.gdx.InputProcessor
- Overrides:
touchDown
in classInputComponent
- Parameters:
screenX
- The x coordinate, origin is in the upper left cornerscreenY
- The y coordinate, origin is in the upper left cornerpointer
- the pointer for the event.button
- the button- Returns:
- true if successful, false otherwise
- See Also:
-
InputProcessor.touchDown(int, int, int, int)
-
buildTower
public void buildTower(int x, int y) Instantiates and spawns the selected tower at the given x y coordinates on the tile map. Assumes that the given x and y coordinate is valid and that the TowerType exists in the CurrencyService.- Parameters:
x
- x-coordinate int valuey
- y-coordinate int value
-