package model;

public class HitboxCircle extends Hitbox {
	private float radiusHitbox;
	private float diametrX,diametrY;
	Point cartesianCenterImagePoint= new Point(0,0);
	//currentRefPoint - точка хранящая  изометрические(экранные) коорды, от которой рисуется овал
	private Point currentRefPoint= new Point(0,0);
	public HitboxCircle(String[] dataHitbox, Entity owner){
		super(dataHitbox[0]);
		setOwnerEntity(owner);
		parseStringToCircleHitbox(dataHitbox);
	}
	public HitboxCircle(String shape, Entity owner){
		super(shape);
		setOwnerEntity(owner);
		radiusHitbox = 0;
	}
	private void parseStringToCircleHitbox(String[] informations) {
		float temp = (float)Math.sqrt(2);
		referencePoint.x = Float.parseFloat(informations[1]);
		referencePoint.y = Float.parseFloat(informations[2]);
		radiusHitbox = Float.parseFloat(informations[3]);
		diametrX = radiusHitbox/temp*4;
		diametrY = radiusHitbox/temp*2;
		cartesianCenterImagePoint = isometricToCartesian(owner.getImage().getWidth()/2,owner.getImage().getHeight(),cartesianCenterImagePoint);
		Point cartesianCenterRefPoint = new Point(cartesianCenterImagePoint.x-referencePoint.x, cartesianCenterImagePoint.y-referencePoint.y);
		Point isoCenterRefPoint = new Point(0,0);
		isoCenterRefPoint = cartesianToIsometric(cartesianCenterRefPoint.x,cartesianCenterRefPoint.y,isoCenterRefPoint);
		currentRefPoint.x = isoCenterRefPoint.x-diametrY;
		currentRefPoint.y = isoCenterRefPoint.y-diametrY/2;
		System.out.println("----------------------------");
		System.out.println("Entity = "+owner.getName());
		System.out.println("refCartEntPoint X ="+cartesianCenterRefPoint.x+"||cartesianCenterRefPoint Y ="+cartesianCenterRefPoint.y);
		System.out.println("CartCenterImage X ="+cartesianCenterImagePoint.x+"||CartCenterImage Y ="+cartesianCenterImagePoint.y);
		System.out.println("refIsoEntPoint X ="+currentRefPoint.x+"||refIsoEntPoint Y ="+currentRefPoint.y);
		System.out.println("diametrY "+ diametrY);
		System.out.println(" ");
		
		
	}
	@Override
	public String listPointsToString() {
		Point cartesianCenterRefPoint = new Point(0, 0);
		cartesianCenterImagePoint = isometricToCartesian(owner.getImage().getWidth()/2,owner.getImage().getHeight(),cartesianCenterImagePoint);
		cartesianCenterRefPoint = isometricToCartesian(currentRefPoint.x+diametrY,currentRefPoint.y+(diametrY/2),cartesianCenterRefPoint);
		System.out.println("");
		referencePoint.x = cartesianCenterImagePoint.x-cartesianCenterRefPoint.x;
		referencePoint.y = cartesianCenterImagePoint.y-cartesianCenterRefPoint.y;
		System.out.println("----------------------------");
		System.out.println("Entity = "+owner.getName());
		System.out.println("refCartEntPoint X ="+cartesianCenterRefPoint.x+"||cartesianCenterRefPoint Y ="+cartesianCenterRefPoint.y);
		System.out.println("CartCenterImage X ="+cartesianCenterImagePoint.x+"||CartCenterImage Y ="+cartesianCenterImagePoint.y);
		System.out.println("refIsoEntPoint X ="+currentRefPoint.x+"||refIsoEntPoint Y ="+currentRefPoint.y);
		System.out.println("diametrY "+ diametrY);
		System.out.println(" ");
		return "Circle "+(int)referencePoint.x+" "+(int)referencePoint.y+" "+(int)radiusHitbox;
	}
	
	public float getRadius() {
		return radiusHitbox;
	}
	public void setDiametrXY(float diametrX, float diametrY) {
		this.diametrX = diametrX;
		this.diametrY = diametrY;
	}
	public float getDiametrX() {
		return diametrX;
	}
	public float getDiametrY() {
		return diametrY;
	}
	public void setRadius(float radius) {
		 radiusHitbox = radius;
	}
	public Point getCurrentRefPoint() {
		return currentRefPoint;
	}
	
	
	
}
