package zero1hd.rhythmbullet.entity.enemies;

import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.math.Rectangle;

import zero1hd.rhythmbullet.entity.Entity;
import zero1hd.rhythmbullet.entity.ally.Laser;

public class Shard extends Entity {
	private int hp;
	private int maxHp;
	
	@Override
	public void preInit() {
		sprite = new Sprite(assets.get("shard.png", Texture.class));
		setSize(2f, 2f);
		sprite.setSize(3f, 2f);
		enemy = true;
		super.preInit();
	}
	
	@Override
	public void init(float deg, float speed, int hp) {
		this.speed = speed;
		this.hp = hp;
		maxHp = hp;
		this.angle = deg;
		super.init(deg, speed, hp);
	}
	
	@Override
	public void reset() {
		hp = 0;
		maxHp = 0;
		super.reset();
	}
	
	@Override
	public void calculate(float delta) {
		if (hp <= 0) {
			dead = true;
		}
		super.calculate(delta);
	}
	
	@Override
	public void draw(Batch batch) {
		sprite.setColor(((float)hp/(float)maxHp), ((float)hp/(float)maxHp), ((float)hp/(float)maxHp), 0.5f);
		super.draw(batch);
	}
	
	@Override
	public void collided(Entity entity) {
		if (entity.getClass() == Laser.class) {
			hp --;
		} else {
			dead = true;
		}
	}

	@Override
	public Rectangle getHitZone() {
		return hitbox;
	}

}
