Class StructureFactory
java.lang.Object
com.deco2800.game.entities.factories.StructureFactory
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 Summary
Modifier and TypeMethodDescriptionstatic 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.static Entity
createTower1
(int level, String name, Boolean isTemp, int orientation) Creates a tower1 entity.static Entity
createTower2
(int level, String name, Boolean isTemp, int orientation) Creates a tower2 entity, adding various components to create a defensive towerstatic Entity
createTower3
(int level, String name, Boolean isTemp, int orientation) Creates a tower3 entity, and adds various components to create a defensive tower.static Entity
createTrap
(String name, Boolean isTemp, int trapNum) Creates a trap entitystatic Entity
createTurret
(String name) static Entity
createVisualFeedbackTile
(String name, String texture) creates an entity of a coloured tile to show where a building can be placedstatic Entity
createWall
(String name, Boolean isTemp, int orientation) Creates a wall entity.static void
Function which handles the destruction / sale of building.static void
handleRefund
(Entity structure, float refundMultiplier) Function which handles the refund of player's resources should they sell a building.static void
upgradeStructure
(com.badlogic.gdx.math.GridPoint2 gridPos, String structName) Function which handles upgrading buildings.
-
Method Details
-
createVisualFeedbackTile
creates an entity of a coloured tile to show where a building can be placed- Parameters:
name
- of the entitytexture
- the entity uses- Returns:
- a coloured tile entity
-
createWall
Creates a wall entity.- Returns:
- specialised Wall entity
-
createTrap
Creates a trap entity- Returns:
- entity
-
createTurret
-
createTower1
Creates a tower1 entity.- Parameters:
level
- of the tower to create- Returns:
- entity
-
createTower2
Creates a tower2 entity, adding various components to create a defensive tower- Parameters:
level
- of the tower- Returns:
- tower2 entity
-
createTower3
Creates a tower3 entity, and adds various components to create a defensive tower.- Parameters:
level
- of the tower- Returns:
- tower3 entity
-
createBaseStructure
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
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
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
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
-