package ei.game.scene;

import ei.engine.math.Vector2i;
import ei.engine.scene.Entity;
import ei.game.player.Player;

public abstract class GameEntity{
	private int max_life;
	private int life;
	private Player player;
	
	public GameEntity(int l, Player p){
		setLife(l);
		player = p;
	}
	
	/**
	 * Returns the life
	 * 
	 * @return The life
	 */
	public int getLife(){
		return life;
	}

	
	/**
	 * Set the life
	 * @param l The life to set to
	 */
	public void setLife(int l){
		life = l;
		if(life > max_life){
			max_life = life;
		}
		if(getSelection() != null)getSelection().setValue(l);
	}
	/**
	 * The unit looses life.
	 * @param l
	 */
	public void damaged(int l) {
		setLife(life-l);
	}
	/**
	 * The unit is destroyed.
	 *
	 */
	public abstract void destroyed();
	/**
	 * Returns the max life
	 * 
	 * @return The max life
	 */
	public int getMaxLife(){
		return max_life;
	}

	
	/**
	 * Set the max life
	 * @param l The max life
	 */
	public void setMaxLife(int l){
		max_life = l;
	}
	
	/**
	 * Returns the player.
	 */
	public Player getPlayer(){
		return player;
	}
	/**
	 * Sets a unit to be selected or not.
	 * @param b true or false.
	 */
	public abstract void setSelected(boolean b);
	
	/**
	 * Set if the mouse is over the unit or not
	 * @param b If the mouse is over the unit or not
	 */
	public abstract void setMouseOver(boolean b);
	
	protected abstract SelectBox getSelection();
	
	public void move(int x, int y) {
		
	}
	
	public abstract void update();
	
	public abstract Entity getNode();
	
	public abstract void attack(Vector2i target);
	
	public abstract Entity getSprite();
}

