package zero1hd.polyjet.entity;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Batch;

import zero1hd.polyjet.Polyjet;

public class Projectile extends Entity {
	float rate;
	int damage;
	Texture texture;
	int hp;
	int storedPoints;
	
	public Projectile() {
		super();
		Gdx.app.debug("Projectile", "A new projectile was created.");
	}
	/**
	 * 
	 * @param spawnX x spawn location
	 * @param spawnY y spawn location
	 * @param rate r/second
	 * @param hp health this projectile should have
	 * @param texture texture this projectile should render.
	 */
	public void initiate(float spawnX, float spawnY, float rate, int hp, Texture texture, float width, float height) {
		this.hp = hp;
		setX(spawnX);
		setY(spawnY);
		this.texture = texture;
		this.rate = rate;
		setSize(width, height);
		damage = 1;
	}
	
	public void setDamage(int damage) {
		this.damage = damage;
	}
	
	public void printDebug() {
		Gdx.app.debug("Projectile", "Coordinates (X,Y): (" + getX() + ", " + getY() + ") Current parent: " + getParent().getName());
		Gdx.app.debug("Projectile", "Width and height: " + getWidth() + "x" + getHeight());
	}
	
	
	@Override
	public void act(float delta) {
		moveBy(0, delta*rate);
		if (getY() > Polyjet.GAME_AREA_HEIGHT) {
			hp = 0;
		}
		super.act(delta);
	}
	
	@Override
	public void draw(Batch batch, float parentAlpha) {
		batch.draw(texture, getX(), getY(), getWidth(), getHeight());
		super.draw(batch, parentAlpha);
	}
	
	@Override
	public void reset() {
		texture = null;
		storedPoints = 0;
		rate = 0;
		damage = 0;
		setDebug(false);
	}
	@Override
	public int getHitPoints() {
		return hp;
	}
}
