simogl.gameobjects.building
Class AbstractBuilding

java.lang.Object
  extended by simogl.gameobjects.AbstractGameObject
      extended by simogl.gameobjects.building.AbstractBuilding
Direct Known Subclasses:
CityHall, Farm, House

public abstract class AbstractBuilding
extends AbstractGameObject

This abstract class is the basic version of a building. Any specialized building must extend this class.

Author:
Frank Bruns

Field Summary
static int CITY_HALL
           
static int FARM
           
static int HOUSE
           
 int type
           
 
Constructor Summary
AbstractBuilding(int type, float x, float y, float z, int price, int regCosts, int taxRate, int inhabLimit)
          Creates a new abstract building
 
Method Summary
 void addToScene()
          Adds the building to the scene, if there is no collision with other buildings.
 void decreaseNumberInhabitants(int amount)
          Decrease the number of inhabitants of the building by the specified amount.
 void deleteBuilding()
          Call this method to delete the building and everything that is connected to it (inhabitants, particle effects) from the scene.
 int getFoodConsumption()
          Returns the sum of food that gets consumed during every time intervall.
 int getNumberInhabitants()
          Returns the number of inhabitants belonging to this building
 int getPrice()
          Returns the costs for contruction of the building
 int getRegularCosts()
          Returns the regular cost for running the building
 int getTaxes()
          Returns the total tax payments of this building, according to the tax rate multiplied by the number of inhabitants.
 int getTaxRate()
          Returns the taxes per inhabitant of the building
static int getTotalNumberInhabitants()
          Returns the total number of inhabitant.
 int getType()
          Returns the type of the building as a constant.
 void increaseNumberInhabitants(int amount)
          Increase the number of inhabitants of the building by the specified amount.
 void setPrice(int price)
          Sets the price for the building
 void setRegularCost(int regCosts)
          Sets the regular costs for running the building
 void setTaxRate(int taxRate)
          Sets the price for the building
 void setVisibleBox(boolean showBox)
          Determines whether the (bounding) box of the bilding should be displayed.
 void update(long elapsedTime)
          Updates a game object
 
Methods inherited from class simogl.gameobjects.AbstractGameObject
getModel, getName, getPosition, getX, getY, getZ, setPosition, setPosition, setX, setY, setZ
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HOUSE

public static final int HOUSE
See Also:
Constant Field Values

FARM

public static final int FARM
See Also:
Constant Field Values

CITY_HALL

public static final int CITY_HALL
See Also:
Constant Field Values

type

public int type
Constructor Detail

AbstractBuilding

public AbstractBuilding(int type,
                        float x,
                        float y,
                        float z,
                        int price,
                        int regCosts,
                        int taxRate,
                        int inhabLimit)
Creates a new abstract building

Parameters:
type - the constant describing the building. E.g. AbstractBuilding.HOUSE
x - x-coordinate
y - y-coordinate
z - z-coordinate
price - cost for construction of this building
regCosts - regluar costs for running the building
taxRate - taxes per inhabitant of the building
inhabLimit - maximaum possible number of inhabitants for the building. Inhabitants are people that pay taxes, so only asign a number greater 0 to building that shall be considered for tax paying
Method Detail

decreaseNumberInhabitants

public void decreaseNumberInhabitants(int amount)
Decrease the number of inhabitants of the building by the specified amount. But the number can't fall below 0.

Parameters:
amount - number of inhabitants to subtract from the building

increaseNumberInhabitants

public void increaseNumberInhabitants(int amount)
Increase the number of inhabitants of the building by the specified amount. But the number can't increase above the inhabitant limit of the building.

Parameters:
amount - number of inhabitants to add to the building

deleteBuilding

public void deleteBuilding()
Call this method to delete the building and everything that is connected to it (inhabitants, particle effects) from the scene.


addToScene

public void addToScene()
Adds the building to the scene, if there is no collision with other buildings.


setVisibleBox

public void setVisibleBox(boolean showBox)
Determines whether the (bounding) box of the bilding should be displayed. Only works, if the building just has one animation frame.

Parameters:
showBox - show (bounding) box? true=yes, false=no

getType

public int getType()
Returns the type of the building as a constant. E.g. the return value could be something like AbstractBuilding.HOUSE or AbstractBuilding.FARM

Returns:
type of the building according to its constant

getNumberInhabitants

public int getNumberInhabitants()
Returns the number of inhabitants belonging to this building

Returns:
number of inhabitants of this building

getTotalNumberInhabitants

public static int getTotalNumberInhabitants()
Returns the total number of inhabitant. This is the sum of every inhabitant belonging to a building.

Returns:
total number of inhabitants

getFoodConsumption

public int getFoodConsumption()
Returns the sum of food that gets consumed during every time intervall. It is calculated by multiplying the number of inhabitants of the building by the its food consuption factor. Afterwards a rounding operation is applied to the result to get an integer value.

Returns:
amount of food that gets consumed during every time intervall

getPrice

public int getPrice()
Returns the costs for contruction of the building

Returns:
price of the building

setPrice

public void setPrice(int price)
Sets the price for the building

Parameters:
price - price for the building

getRegularCosts

public int getRegularCosts()
Returns the regular cost for running the building

Returns:
regular cost for running the building

setRegularCost

public void setRegularCost(int regCosts)
Sets the regular costs for running the building

Parameters:
regCosts - regular costs for running the building

getTaxRate

public int getTaxRate()
Returns the taxes per inhabitant of the building

Returns:
tax rate of the building

setTaxRate

public void setTaxRate(int taxRate)
Sets the price for the building

Parameters:
taxRate - tax rate for the building

getTaxes

public int getTaxes()
Returns the total tax payments of this building, according to the tax rate multiplied by the number of inhabitants.

Returns:
total tax payment of the building

update

public void update(long elapsedTime)
Description copied from class: AbstractGameObject
Updates a game object

Specified by:
update in class AbstractGameObject
Parameters:
elapsedTime - time between two frames