package simogl.gameobjects.building;

import simogl.effect.particle.custom.Fire;
import simogl.gameobjects.character.Elder;
import simogl.level.AbstractLevel;
import simogl.model.building.MD2CityHall;
import simogl.model.character.MD2Elder;

/**
 * This class represents a house in the game
 * @author Frank Bruns
 *
 */
public class CityHall extends AbstractBuilding
{
	/**
	 * This counter counts the number of build city halls
	 */
	private static int counter = 0;
	private static int collectableTaxes = 20;
	
	/**
	 * Creates a new house
	 * @param x x-coordinate
	 * @param y y-coordinate
	 * @param z z-coordinate
	 */
	public CityHall(float x, float y, float z)
	{
		super(AbstractBuilding.CITY_HALL,x,y,z,25,9,0,0);
		counter++;
		
		this.md2Model = new MD2CityHall(this.getX(),this.getY(),this.getZ());
		this.name = "city hall";
		
		this.centerBuildingOnConstructionPoint();
		
		// Add a particle effet to the left vessel
		Fire fire1 = new Fire(this.getX()+1.2f,
				this.getY()+0.6f, this.getZ()-1.2f,35,350,10);		
		this.partEffects.add(fire1);
		AbstractLevel.partEffects.add(fire1);
		
		// Add a particle effet to the right vessel
		Fire fire2 = new Fire(this.getX()+16.2f,
				this.getY()+0.6f, this.getZ()-1.2f,35,350,10);		
		this.partEffects.add(fire2);
		AbstractLevel.partEffects.add(fire2);
				
		// add an elder to the scene		
		this.character = new Elder(this.getX()+this.getModel().getCurrentAnim().getCurrentFrame().getMesh().getBoundingBox().getWidth()/2f,
				this.getY()+0.6f, this.getZ()-this.getModel().getCurrentAnim().getCurrentFrame().getMesh().getBoundingBox().getLength()/2f);
		this.character.getModel().setAnimationState(MD2Elder.STAND);
		AbstractLevel.characters.add(this.character);
		
	}
	
	/**
	 * Returns the number of city halls built so far
	 * @return number of built city halls
	 */
	public int getNumberCityHalls()
	{
		return counter;
	}
	
	/**
	 * Static method to decrease the value of the city hall counter by the
	 * specified amount.
	 * @param amount amount to decrease the city hall counter
	 */
	public static void decreaseNumberOfCityHall(int amount)
	{
		counter -= amount;
	}
	
	/**
	 * Returns the maximum amount of collectable taxes, if you
	 * sum up the collection capabilities of all city halls together
	 * @return overall collectable taxes by city halls
	 */
	public static int getMaxCollectableTaxes()
	{
		return collectableTaxes * counter;
	}
}

