Class BuildInputComponent

All Implemented Interfaces:
com.badlogic.gdx.input.GestureDetector.GestureListener, com.badlogic.gdx.InputProcessor

public class BuildInputComponent extends InputComponent
Input component for handling in-game tower building. Based on Team 5 implementation of DropInputComponent
  • 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 interface com.badlogic.gdx.InputProcessor
      Overrides:
      touchDown in class InputComponent
      Parameters:
      screenX - The x coordinate, origin is in the upper left corner
      screenY - The y coordinate, origin is in the upper left corner
      pointer - 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 value
      y - y-coordinate int value