Class SelectableComponent

java.lang.Object
com.deco2800.game.components.Component
com.deco2800.game.components.friendlyunits.SelectableComponent

public class SelectableComponent extends Component
  • Constructor Details

    • SelectableComponent

      public SelectableComponent()
      initializes component with unit not being selected
  • Method Details

    • unselect

      public void unselect()
    • create

      public void create()
      Description copied from class: Component
      Called when the entity is created and registered. Initial logic such as calls to GetComponent should be made here, not in the constructor which is called before an entity is finished.
      Overrides:
      create in class Component
    • singleHover

      public void singleHover(int xCoordinate, int yCoordinate)
    • multipleHover

      public void multipleHover(int startX, int startY, int endX, int endY)
    • singleSelect

      public void singleSelect(int xCoordinate, int yCoordinate)
    • multipleSelect

      public void multipleSelect(int startX, int startY, int endX, int endY)
    • isIn

      public boolean isIn(int xCoordinate, int yCoordinate)
      Called when a single click form the player happens. Checks if the hitbox of current entity is inside that click If it is, this unit is selected and if it's not, then do nothing
      Parameters:
      xCoordinate - The x coordinate of the mouse
      yCoordinate - The y coordinate of the mouse
      Returns:
    • containsUs

      public boolean containsUs(int startX, int startY, int endX, int endY)
      Called when player wishes to select units in a certain area on the screen and checks if this unit is in that area
      Parameters:
      startX - start of x coordinate of box
      startY - start of y coordinate of box
      endX - end of x coordinate of box
      endY - end of y coordinate of box
    • contains

      public boolean contains(float inside, float from, float to)
      Parameters:
      inside - position to check
      from - one bound to check
      to - other bounch to check
      Returns:
      true if inside is between from and to
    • screenToWorldPosition

      public com.badlogic.gdx.math.Vector2 screenToWorldPosition(int screenX, int screenY)
      Turns a selected screen position to the world position
      Parameters:
      screenX - screen position of x
      screenY - screen position of y
      Returns:
      (x,y) in vector form in the world
    • moveLocation

      public void moveLocation(int screenX, int screenY)
    • isSelected

      public boolean isSelected()
      Returns:
      if the unit is selected to function with other components
    • isHovered

      public boolean isHovered()