package spaceObject.spaceShip;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.ArrayList;

import javafx.geometry.Point2D;
import javafx.scene.Group;
import javafx.scene.image.Image;
import spaceObject.projectile.Projectile;

public abstract class Enemy extends SpaceShip implements Ability {

	public static ArrayList<Enemy> opponent = new ArrayList<Enemy>();
	private double _reloadTime, _ts = 0;

	public Enemy(Group group, String string, double height, double widht,
			double reload, int live, int points) throws FileNotFoundException {
		super(opponent, Allied.player, group, new Image(new FileInputStream(string)), Projectile.KEY_RED, height,
				widht, live);

		_reloadTime = reload;

		setMovePoint2d(new Point2D(0, 1));
		setPoints(points);
		
		opponent.add(this);
	}

	@Override
	public void update(double deltaT) {
		move(deltaT);
		if (_reloadTime <= _ts) {
			shoot(new Point2D(0, 1));
			specialAbility();
			_ts -= _reloadTime;
		} else {
			_ts += deltaT;
		}
	}
}
