Class StructureFactory

java.lang.Object
com.deco2800.game.entities.factories.StructureFactory

public class StructureFactory extends Object
Factory to create structure entities with predefined components.

Each structure entity type should have a creation method that returns a corresponding entity. Predefined entity properties can be loaded from configs stored as json files which are defined in "StructureConfigs".

If needed, this factory can be separated into more specific factories for entities with similar characteristics.

  • Method Details

    • createVisualFeedbackTile

      public static Entity createVisualFeedbackTile(String name, String texture)
      creates an entity of a coloured tile to show where a building can be placed
      Parameters:
      name - of the entity
      texture - the entity uses
      Returns:
      a coloured tile entity
    • createWall

      public static Entity createWall(String name, Boolean isTemp, int orientation)
      Creates a wall entity.
      Returns:
      specialised Wall entity
    • createTrap

      public static Entity createTrap(String name, Boolean isTemp, int trapNum)
      Creates a trap entity
      Returns:
      entity
    • createTurret

      public static Entity createTurret(String name)
    • createTower1

      public static Entity createTower1(int level, String name, Boolean isTemp, int orientation)
      Creates a tower1 entity.
      Parameters:
      level - of the tower to create
      Returns:
      entity
    • createTower2

      public static Entity createTower2(int level, String name, Boolean isTemp, int orientation)
      Creates a tower2 entity, adding various components to create a defensive tower
      Parameters:
      level - of the tower
      Returns:
      tower2 entity
    • createTower3

      public static Entity createTower3(int level, String name, Boolean isTemp, int orientation)
      Creates a tower3 entity, and adds various components to create a defensive tower.
      Parameters:
      level - of the tower
      Returns:
      tower3 entity
    • createBaseStructure

      public static Entity createBaseStructure(String texture, String name, boolean animated)
      Creates a generic Structure to be used as a base entity by more specific Structure creation methods.
      Parameters:
      texture - image representation for created structure
      Returns:
      structure entity
    • handleRefund

      public static void handleRefund(Entity structure, float refundMultiplier)
      Function which handles the refund of player's resources should they sell a building. Refunds 80% of the buildings original cost
      Parameters:
      structure - : the building to refund
    • handleBuildingDestruction

      public static void handleBuildingDestruction(String name)
      Function which handles the destruction / sale of building.
      Parameters:
      name - : true if building has been sold, false if building has otherwise been destroyed In future could be expanded by using Enums vs boolean
    • upgradeStructure

      public static void upgradeStructure(com.badlogic.gdx.math.GridPoint2 gridPos, String structName)
      Function which handles upgrading buildings. Does so by first obtaining and storing building state, removing building and replacing with upgraded version.
      Parameters:
      structName - : Name of the structure to be upgraded