Combat Terrain Factory - UQcsse3200/2024-studio-2 GitHub Wiki
The Combat Terrain Factory handles the spawning of the background terrain for Combat Screen. This class is called once the correct kingdom is identified in Combat Area to spawn the appropriate kingdom background i.e. land, water, or air.
The methods in this class are called from the Combat Area class as below.
private CombatTerrainFactory combatTerrainFactory; // declare an instance of the terrain factory
public void spawnTerrain() {
if(kingdomType == KINGDOM.LAND){ // land
terrain = combatTerrainFactory.createBackgroundTerrainLand(TerrainType.FOREST_DEMO, playerSpawn, MAP_SIZE);
} else if (kingdomType == KINGDOM.AIR) { // air
terrain = combatTerrainFactory.createBackgroundTerrainAir(TerrainType.FOREST_DEMO, playerSpawn, MAP_SIZE);
} else { // water
terrain = combatTerrainFactory.createBackgroundTerrainWater(TerrainType.FOREST_DEMO, playerSpawn, MAP_SIZE);
}
Entity terrainEntity = new Entity();
spawnEntityAt((terrainEntity.addComponent(terrain)), new GridPoint2(-10, 0), true, true);
}
public TerrainComponent createBackgroundTerrainAir(TerrainType terrainType, GridPoint2 playerPosition, GridPoint2 screenSize){...}
- Spawns the background terrain when combat occurs in the Sky Kingdom
- Accepts an enum of the terrain type, the player's spawn position, and the size of the screen to scale the image to
- Returns the terrain as an entity to be spawned on the Combat Area prior to spawning of other entities (i.e. player, enemy etc.)
public TerrainComponent createBackgroundTerrainLand(TerrainType terrainType, GridPoint2 playerPosition, GridPoint2 screenSize) {...}
- Spawns the background terrain when combat occurs in the Land Kingdom
- Accepts an enum of the terrain type, the player's spawn position, and the size of the screen to scale the image to
- Returns the terrain as an entity to be spawned on the Combat Area prior to spawning of other entities (i.e. player, enemy etc.)
public TerrainComponent createBackgroundTerrainWater(TerrainType terrainType, GridPoint2 playerPosition, GridPoint2 screenSize) {...}
- Spawns the background terrain when combat occurs in the Sea Kingdom
- Accepts an enum of the terrain type, the player's spawn position, and the size of the screen to scale the image to
- Returns the terrain as an entity to be spawned on the Combat Area prior to spawning of other entities (i.e. player, enemy etc.)
Kingdom Type | Image |
---|---|
Land | |
Sea | |
Sky |