package me.benjozork.onyx.entity;

import com.badlogic.gdx.math.Vector2;

import me.benjozork.onyx.game.GameScreenManager;
import me.benjozork.onyx.utils.Utils;

/**
 * @author Benjozork
 */
public abstract class LivingEntity extends Entity {

    private float health = 100f;

    private final float maxBulletTime = 0.1f;
    private float bulletTimer = 0f;
    private Vector2 bulletShootOrigin = new Vector2();

    public Type type;

    public LivingEntity(float x, float y) {
        super(x, y);
    }

    public void fireProjectile(String path) {
        bulletTimer += Utils.delta();
        if (bulletTimer >= maxBulletTime) {
            ProjectileEntity projectile = new ProjectileEntity(getX() + bulletShootOrigin.x, getY() + bulletShootOrigin.y);
            projectile.accelerate(2550f);
            projectile.setDamage(10f);
            projectile.source = type;

            GameScreenManager.addEntity(projectile);

            //if (ammo < 0) return;
            //ammo -= 1;

            bulletTimer = 0f;
        }
    }

    public void damage(float v) {
        health -= v;
        if (health < 0) this.dispose();
    }

    public Vector2 getBulletShootOrigin() {
        return bulletShootOrigin;
    }

    public void setBulletShootOrigin(float x, float y) {
        bulletShootOrigin.set(x, y);
    }

    /*
    public int getAmmo() {
        return ammo;
    }

    public void setAmmo(int ammo) {
        this.ammo = ammo;
    }
    */

    public enum Type {
        ENEMY,
        PLAYER
    }
}
@@ -1117,16 +1117,108 @@
 lth %3C 0)
+ %7B%0A            if (this instanceof EnemyEntity) GameScreenManager.addScore(100);%0A           
  this.di
@@ -1222,24 +1222,34 @@
 .dispose();%0A
+        %7D%0A
     %7D%0A%0A    p

Add to score when enemy dies