package model.objects;

import java.awt.Graphics2D;
import java.awt.geom.Path2D;

public class ShootingLine {
	private Path2D.Double line;
	private int startx, starty, length;

	public ShootingLine(int startx, int starty) {
		line = new Path2D.Double();
		this.startx = startx;
		this.starty = starty;
	}

	public void setLength(int length) {
		this.length = length;
		line = new Path2D.Double();
		line.moveTo(startx, starty);
		int tempy = starty;

		// Create curve
		for (int i = 0; i < length; i++) {
			line.curveTo(startx + 10, tempy - 10, startx - 10, tempy - 20, startx, tempy - 30);
			tempy -= 30;
		}
	}

	// ** Painting **//

	public void paint(Graphics2D g2d) {
		g2d.draw(line);
		g2d.drawLine(startx, getMaxHeight(), startx + 8, getMaxHeight() + 15);
		g2d.drawLine(startx, getMaxHeight(), startx - 8, getMaxHeight() + 15);
	}

	// ** Getters and Setters **//

	public int getLength() {
		return length;
	}

	public int getStartx() {
		return startx;
	}

	public void setStartx(int startx) {
		this.startx = startx;
	}

	public int getStarty() {
		return starty;
	}

	public void setStarty(int starty) {
		this.starty = starty;
	}

	public int getMaxHeight() {
		return starty - length * 30;
	}

	public int getX() {
		return startx;
	}

	public int getY() {
		return starty;
	}

	public int getWidth() {
		return 10;
	}

	public int getHeight() {
		return getLength() * 30;
	}
}
