java.lang.Object
com.deco2800.game.areas.MapGenerator.Buildings.CityRow

public class CityRow extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
    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
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    addBuilding(Building building, boolean corner)
    Attempts to add a building to this City Row
    void
    Distributes buildings evenly across the city based on how much empty space is left
    boolean
    equals(Object other)
     
    Returns a copy of this CityRow's building list
    int
     
    int
     
    int
     
    int
     
    int
    Returns the total amount of buildings placed in this row
    int
     
    void
     
    void
    setBuildingCoordinates(int xOffset, int yOffset)
    Updates the height of all buildings in the city row, after rows have been centred
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • 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 tiles
      CITY_BUFFER - Space to leave (in tiles) between each building
      WALL_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

      public boolean addBuilding(Building building, boolean corner)
      Attempts to add a building to this City Row
      Parameters:
      building - building to be added
      corner - 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 map
      yOffset - 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

      public LinkedList<Building> getBuildings()
      Returns a copy of this CityRow's building list
      Returns:
      list of buildings in the row
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object