Class SelectableComponent
java.lang.Object
com.deco2800.game.components.Component
com.deco2800.game.components.friendlyunits.SelectableComponent
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancontains(float inside, float from, float to) booleancontainsUs(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 areavoidcreate()Called when the entity is created and registered.booleanbooleanisIn(int xCoordinate, int yCoordinate) Called when a single click form the player happens.booleanvoidmoveLocation(int screenX, int screenY) voidmultipleHover(int startX, int startY, int endX, int endY) voidmultipleSelect(int startX, int startY, int endX, int endY) com.badlogic.gdx.math.Vector2screenToWorldPosition(int screenX, int screenY) Turns a selected screen position to the world positionvoidsingleHover(int xCoordinate, int yCoordinate) voidsingleSelect(int xCoordinate, int yCoordinate) voidunselect()Methods inherited from class com.deco2800.game.components.Component
dispose, earlyUpdate, getEntity, isAnimationRenderComponent, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
-
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:ComponentCalled 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. -
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 mouseyCoordinate- 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 boxstartY- start of y coordinate of boxendX- end of x coordinate of boxendY- end of y coordinate of box
-
contains
public boolean contains(float inside, float from, float to) - Parameters:
inside- position to checkfrom- one bound to checkto- 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 xscreenY- 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()
-