Class BoxFactory.AutonomousBoxBuilder

java.lang.Object
com.csse3200.game.entities.factories.BoxFactory.AutonomousBoxBuilder
Enclosing class:
BoxFactory

public static class BoxFactory.AutonomousBoxBuilder extends Object
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 Details

    • AutonomousBoxBuilder

      public AutonomousBoxBuilder()
  • Method Details

    • moveX

      public BoxFactory.AutonomousBoxBuilder moveX(float minX, float maxX)
      Sets the horizontal movement bounds for the box. The box spawns midway between the min and max bounds.
      Parameters:
      minX - The minimum X coordinate
      maxX - The maximum X coordinate
      Returns:
      the builder for chaining the horizontal movement bounds
    • moveY

      public BoxFactory.AutonomousBoxBuilder moveY(float minY, float maxY)
      Sets the vertical movement bounds for the box. The box spawns midway between the min and max bounds.
      Parameters:
      minY - The minimum Y coordinate
      maxY - The maximum Y coordinate
      Returns:
      the builder for chaining the vertical movement bounds
    • speed

      public BoxFactory.AutonomousBoxBuilder speed(float 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

      public BoxFactory.AutonomousBoxBuilder scale(float scaleX, float scaleY)
      Sets the visual scale of the box, relative to a single world unit.
      Parameters:
      scaleX - Horizontal scale
      scaleY - Vertical scale
      Returns:
      the builder for chaining the scale
    • damage

      public BoxFactory.AutonomousBoxBuilder damage(int 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

      public BoxFactory.AutonomousBoxBuilder knockback(int 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

      public BoxFactory.AutonomousBoxBuilder texture(String texturePath)
      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 text
      style - 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

      public Entity build()
      Builds and returns the autonomous box entity with all its properties configured.
      Returns:
      The constructed autonomous box entity