Class CityRow
java.lang.Object
com.deco2800.game.areas.MapGenerator.Buildings.CityRow
-
Constructor Summary
ConstructorsConstructorDescriptionCityRow
(int cityWidth, int CITY_BUFFER, int WALL_BUFFER, int RIGHT_BUFFER, int index) Creates a new row of the city to allocate buildings to, given the width of the city in tiles, the amount of tiles to dedicate to walls around the city, and the amount of space to place between each city -
Method Summary
Modifier and TypeMethodDescriptionboolean
addBuilding
(Building building, boolean corner) Attempts to add a building to this City Rowvoid
Distributes buildings evenly across the city based on how much empty space is leftboolean
Returns a copy of this CityRow's building listint
int
getIndex()
int
int
int
Returns the total amount of buildings placed in this rowint
hashCode()
void
resetRow()
void
setBuildingCoordinates
(int xOffset, int yOffset) Updates the height of all buildings in the city row, after rows have been centredtoString()
-
Constructor Details
-
CityRow
public CityRow(int cityWidth, int CITY_BUFFER, int WALL_BUFFER, int RIGHT_BUFFER, int index) Creates a new row of the city to allocate buildings to, given the width of the city in tiles, the amount of tiles to dedicate to walls around the city, and the amount of space to place between each city- Parameters:
cityWidth
- Width of the city in tilesCITY_BUFFER
- Space to leave (in tiles) between each buildingWALL_BUFFER
- Space to leave (in tiles) between the edge of the city and the first and last buildings
-
-
Method Details
-
getTotalPlacements
public int getTotalPlacements()Returns the total amount of buildings placed in this row- Returns:
- amount of buildings placed in this row
-
getRowWidth
public int getRowWidth() -
getHeight
public int getHeight() -
getSpaceRemaining
public int getSpaceRemaining() -
getIndex
public int getIndex() -
resetRow
public void resetRow() -
addBuilding
Attempts to add a building to this City Row- Parameters:
building
- building to be addedcorner
- whether to place a building on the right side- Returns:
- true if the building was placed, else false if no space
-
setBuildingCoordinates
public void setBuildingCoordinates(int xOffset, int yOffset) Updates the height of all buildings in the city row, after rows have been centred- Parameters:
xOffset
- x value to be added onto start point to make this a valid coordinate on the mapyOffset
- y value to be added onto start point to make this a valid coordinate on the map
-
centreRow
public void centreRow()Distributes buildings evenly across the city based on how much empty space is left -
getBuildings
Returns a copy of this CityRow's building list- Returns:
- list of buildings in the row
-
equals
-
hashCode
public int hashCode() -
toString
-