package ei.game.scene.map;

import ei.engine.math.Vector2f;
import ei.engine.math.Vector2i;
import ei.engine.scene.Entity;
import ei.engine.scene.Sprite;
import ei.game.player.Player;
import ei.game.scene.SelectBox;
import ei.game.scene.buildings.Building;
import ei.game.scene.weapons.Explotion;
import ei.game.scene.weapons.WeaponHandler;

public class Factory extends Building{
	private static final String[] img = {
		"data/buildings/factory/factory_1.png",
		"data/buildings/factory/factory_2.png"
	};
	private SelectBox selectionBox;
	private Sprite factory;

	public Factory(Vector2i pos, Player p) {
		super(500, pos, p, 4);
	}
	
	public void initGraphics(){
		factory = new Sprite("Factory",img[(int)(Math.random()*img.length)]);
		factory.setSize(new Vector2f(200,200));
		getNode().add(factory);
		
		selectionBox = new SelectBox(0,200,200,getMaxLife());
	}

	@Override
	public Entity getSprite() {
		return factory;
	}

	@Override
	public int getMaintenanceCost() {
		return 0;
	}

	@Override
	public Entity getGroundSprite() {
		return null;
	}

	@Override
	public void attack(Vector2i target, boolean play) {
		
	}

	@Override
	public void destroyed() {
		WeaponHandler.getInstance().addWeapon(new Explotion(new Vector2f(getNode().getLocation().getX(), getNode().getLocation().getY())));	
	}

	@Override
	protected SelectBox getSelection() {
		return selectionBox;
	}
	
	public boolean isTerrain(){
		return true;
	}
	
}
