package ei.game.scene.buildings;

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.weapons.Explotion;
import ei.game.scene.weapons.WeaponHandler;

/**
 * 
 * @author Jesper Lundin
 *
 */
public class CommandCenter extends Building{
	private SelectBox selectionBox;
	private Sprite building;
	private Sprite ground;
	
	public CommandCenter(Player p) {
		this(0, 0, p);
	}
	
	public CommandCenter(int x, int y, Player p){
		super(1000, new Vector2i(x,y), p, 4);
	}
	
	public void initGraphics(){
		ground = new Sprite("CC_Ground", "data/buildings/cc/cc_ground.png");
		ground.setSize(new Vector2f(200,200));
		getNode().add(ground);
		building = new Sprite("CC", "data/buildings/cc/cc_building.png");
		building.setSize(new Vector2f(200,200));
		getNode().add(building);

		selectionBox = new SelectBox(0,200,200,getMaxLife());
	}

	protected SelectBox getSelection() {	
		return selectionBox;
	}
	
	/**
	 * This unit type is now destroyed.
	 */
	public void destroyed(){
		WeaponHandler.getInstance().addWeapon(new Explotion(new Vector2f(getNode().getLocation().getX(), getNode().getLocation().getY())));
	}
	
	/**
	 * Doesnt matter anyway. Since buildings cant attack.
	 */
	public void attack(Vector2i target, boolean play) {
		
	}
	
	/**
	 * Manages the sprite connected to this unit.
	 * 
	 * @param s
	 */
	public void setSprite(Sprite s) {
		building = s;
	}
	
	/**
	 * returns the sprite connected to this type
	 * of unit.
	 * 
	 * @return
	 */
	public Entity getSprite() {
		return building;
	}

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

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