Class BoxFactory.AutonomousBoxBuilder
java.lang.Object
com.csse3200.game.entities.factories.BoxFactory.AutonomousBoxBuilder
- Enclosing class:
BoxFactory
Builder that creates autonomous (kinematic) box entities that can be used as moving game
obstacles.
By default, the autonomous box spawns as an orange square at the minimum X and Y movement bounds, scaled to half a game unit. Default values also exist for speed, scale, damage, knockback and the tooltip text where specific values are not set.
The autonomous box's kinematic nature means it will not be affected by gravity or move as a result of a collision force applied to it. It can be set to continuously travel along a horizontal or vertical path at a set speed and distance, reversing direction when reaching each bound.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds and returns the autonomous box entity with all its properties configured.damage
(int damage) Sets the damage the box deals to the player on each contact.float
Returns the x coordinate where the box will spawn.float
Returns the y coordinate where the box will spawn.knockback
(int knockback) Sets the knockback applied to the player on contact.moveX
(float minX, float maxX) Sets the horizontal movement bounds for the box.moveY
(float minY, float maxY) Sets the vertical movement bounds for the box.scale
(float scaleX, float scaleY) Sets the visual scale of the box, relative to a single world unit.speed
(float speed) Sets the speed at which the box moves.Sets a custom texture for the box.tooltip
(String text, TooltipSystem.TooltipStyle style) Sets a tooltip for the box
-
Constructor Details
-
AutonomousBoxBuilder
public AutonomousBoxBuilder()
-
-
Method Details
-
moveX
Sets the horizontal movement bounds for the box. The box spawns midway between the min and max bounds.- Parameters:
minX
- The minimum X coordinatemaxX
- The maximum X coordinate- Returns:
- the builder for chaining the horizontal movement bounds
-
moveY
Sets the vertical movement bounds for the box. The box spawns midway between the min and max bounds.- Parameters:
minY
- The minimum Y coordinatemaxY
- The maximum Y coordinate- Returns:
- the builder for chaining the vertical movement bounds
-
speed
Sets the speed at which the box moves.- Parameters:
speed
- Movement speed in world units per second- Returns:
- the builder for chaining the movement speed
-
scale
Sets the visual scale of the box, relative to a single world unit.- Parameters:
scaleX
- Horizontal scalescaleY
- Vertical scale- Returns:
- the builder for chaining the scale
-
damage
Sets the damage the box deals to the player on each contact.- Parameters:
damage
- The amount of damage applied to the player- Returns:
- the builder for chaining the amount of damage
-
knockback
Sets the knockback applied to the player on contact.- Parameters:
knockback
- The knockback force applied to the player- Returns:
- the builder for chaining the knockback force
-
texture
Sets a custom texture for the box.- Parameters:
texturePath
- path to the image file- Returns:
- the builder for chaining the texture image
-
tooltip
Sets a tooltip for the box- Parameters:
text
- The tooltip textstyle
- The tooltip style- Returns:
- the builder for chaining the tooltip text
-
getSpawnX
public float getSpawnX()Returns the x coordinate where the box will spawn.- Returns:
- spawn location's x coordinate.
-
getSpawnY
public float getSpawnY()Returns the y coordinate where the box will spawn.- Returns:
- spawn location's y coordinate.
-
build
Builds and returns the autonomous box entity with all its properties configured.- Returns:
- The constructed autonomous box entity
-