import java.applet.*;
import java.awt.*;

public class Tower {
	
	public int x_pos;
	public int y_pos;
	public int x_middle;
	public int y_middle;
	public int attack_power;
	public int rate_of_fire;
	public int range;
	public int level;
	public int price;
	public int upgrade_price;
	public String img;
	public String img_gun;
	private String name;
	
	// Creates a new "Tower" with a name and x,y coordinates as parameters
	public Tower(String t_name, int x, int y){
			this.name = t_name;
			this.x_pos = x;
			this.y_pos = y;
			
			if(name == "turret"){
				this.img = "turret.png";
				this.img_gun = "turret_gun.png";
				this.rate_of_fire = 30;
				this.range = 60;
				this.attack_power = 50;
			}
			this.x_middle = this.x_pos + 8;
			this.y_middle = this.y_pos + 8;
		}
	
	public void attack(Enemy e, long frame){
		if(frame % this.rate_of_fire == 10){
			e.current_hp -= this.attack_power;
		}	
	}
	public void attack_animation(int x, int y, long frame, Graphics g){
		int displacement_x = Math.round((this.x_middle - x)/10);
		int displacement_y = Math.round((this.y_middle - y)/10);
		if(frame % this.rate_of_fire >= 0 && frame % this.rate_of_fire <= 10){
			int coefficent = (int)frame % this.rate_of_fire;
			g.setColor(Color.red);
			g.fillOval(this.x_middle - coefficent*displacement_x, this.y_middle - coefficent*displacement_y, 3, 3);
			g.setColor(Color.black);
		}
	}
}
