working on parsing ReferencePoint into CurrentIsoPoint
This commit is contained in:
@ -3,22 +3,22 @@
|
|||||||
<objecttype color="#a0a0a4" name="misato">
|
<objecttype color="#a0a0a4" name="misato">
|
||||||
<property default="Solid" name="class" type="string"/>
|
<property default="Solid" name="class" type="string"/>
|
||||||
<property default="22 10 232 3 264 199 5 198 " name="drawbox" type="string"/>
|
<property default="22 10 232 3 264 199 5 198 " name="drawbox" type="string"/>
|
||||||
<property default="Rectangle 22 -1 63 67" name="hitbox" type="string"/>
|
<property default="Circle 1 14 61" name="hitbox" type="string"/>
|
||||||
</objecttype>
|
</objecttype>
|
||||||
<objecttype color="#a0a0a4" name="starlight">
|
<objecttype color="#a0a0a4" name="starlight">
|
||||||
<property default="Solid" name="class" type="string"/>
|
<property default="Solid" name="class" type="string"/>
|
||||||
<property default="0 4 196 0 197 119 34 140 " name="drawbox" type="string"/>
|
<property default="0 4 196 0 197 119 34 140 " name="drawbox" type="string"/>
|
||||||
<property default="Circle 23 13 29" name="hitbox" type="string"/>
|
<property default="Rectangle 38 30 88 62" name="hitbox" type="string"/>
|
||||||
</objecttype>
|
</objecttype>
|
||||||
<objecttype color="#a0a0a4" name="tavern">
|
<objecttype color="#a0a0a4" name="tavern">
|
||||||
<property default="Solid" name="class" type="string"/>
|
<property default="Solid" name="class" type="string"/>
|
||||||
<property default="3 2 252 1 253 605 6 608" name="drawbox" type="string"/>
|
<property default="3 2 252 1 253 605 6 608" name="drawbox" type="string"/>
|
||||||
<property default="Rectangle 0 0 96 98" name="hitbox" type="string"/>
|
<property default="Rectangle -1855 -3037 304 298" name="hitbox" type="string"/>
|
||||||
</objecttype>
|
</objecttype>
|
||||||
<objecttype color="#a0a0a4" name="TopHome">
|
<objecttype color="#a0a0a4" name="TopHome">
|
||||||
<property default="Solid" name="class" type="string"/>
|
<property default="Solid" name="class" type="string"/>
|
||||||
<property default="3 2 252 1 253 605 6 608" name="drawbox" type="string"/>
|
<property default="3 2 252 1 253 605 6 608" name="drawbox" type="string"/>
|
||||||
<property default="Rectangle 0 0 96 98" name="hitbox" type="string"/>
|
<property default="Rectangle -431 -2181 323 51" name="hitbox" type="string"/>
|
||||||
</objecttype>
|
</objecttype>
|
||||||
<objecttype color="000000" name="newtest">
|
<objecttype color="000000" name="newtest">
|
||||||
<property default="solid" name="class" type="string"/>
|
<property default="solid" name="class" type="string"/>
|
||||||
|
|||||||
@ -26,10 +26,15 @@ public class HitboxCircleRenderingFunction implements ShapeRenderingFunction {
|
|||||||
public void drawing(Graphics2D g) {
|
public void drawing(Graphics2D g) {
|
||||||
HitboxCircle nowHitbox = (HitboxCircle)entity.getHitbox();
|
HitboxCircle nowHitbox = (HitboxCircle)entity.getHitbox();
|
||||||
if(nowHitbox.getRadius()!=0) {
|
if(nowHitbox.getRadius()!=0) {
|
||||||
g.drawOval((int)nowHitbox.getCurrentRefPoint().x, (int)(nowHitbox.getCurrentRefPoint().y-(nowHitbox.getDiametrY()/2)), (int)nowHitbox.getDiametrX(), (int)(nowHitbox.getDiametrY()));
|
g.drawOval((int)nowHitbox.getCurrentRefPoint().x, (int)(nowHitbox.getCurrentRefPoint().y-(nowHitbox.getDiametrY()/2)), (int)nowHitbox.getDiametrX(), (int)(nowHitbox.getDiametrY()));
|
||||||
|
System.out.println("READY: diametrX = "+nowHitbox.getDiametrX()+ ". diametrY = "+nowHitbox.getDiametrY());
|
||||||
|
System.out.println("READY: coordX = "+(int)nowHitbox.getCurrentRefPoint().x+ ". coordY = "+(int)(nowHitbox.getCurrentRefPoint().y-(nowHitbox.getDiametrY()/2)));
|
||||||
|
|
||||||
}else if(firstIsoPoint != null) {
|
}else if(firstIsoPoint != null) {
|
||||||
currentDiametrX = Math.abs((int)firstIsoPoint.x-(int)currentIsoPoint.x);
|
currentDiametrX = Math.abs((int)firstIsoPoint.x-(int)currentIsoPoint.x);
|
||||||
g.drawOval((int)firstIsoPoint.x, (int)(firstIsoPoint.y-currentDiametrX/4), currentDiametrX, currentDiametrX/2);
|
System.out.println("CURRENT: coordX = "+(int)firstIsoPoint.x+ ". coordX = "+(int)(firstIsoPoint.y-currentDiametrX/4));
|
||||||
|
System.out.println("CURRENT: diametrX = "+currentDiametrX+ ". diametrY = "+currentDiametrX/2);
|
||||||
|
g.drawOval((int)firstIsoPoint.x, (int)(firstIsoPoint.y-currentDiametrX/4), (int)currentDiametrX, (int)currentDiametrX/2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,13 +47,17 @@ public class HitboxCircleRenderingFunction implements ShapeRenderingFunction {
|
|||||||
//Формула высчитывания радиуса из диаметров circle.
|
//Формула высчитывания радиуса из диаметров circle.
|
||||||
nowHitbox.getCurrentRefPoint().setXY(firstIsoPoint.x, firstIsoPoint.y);
|
nowHitbox.getCurrentRefPoint().setXY(firstIsoPoint.x, firstIsoPoint.y);
|
||||||
nowHitbox.setDiametrXY(Math.abs(firstIsoPoint.x-e.getX()),Math.abs((firstIsoPoint.x-e.getX())/2));
|
nowHitbox.setDiametrXY(Math.abs(firstIsoPoint.x-e.getX()),Math.abs((firstIsoPoint.x-e.getX())/2));
|
||||||
System.out.println("X = "+nowHitbox.getDiametrX()+ "Y = "+nowHitbox.getDiametrY());
|
System.out.println("X = "+nowHitbox.getDiametrX()+ ". Y = "+nowHitbox.getDiametrY());
|
||||||
float temp = (float)Math.sqrt(2);
|
float temp = (float)Math.sqrt(2);
|
||||||
nowHitbox.setRadius((nowHitbox.getDiametrY()/2)*temp);
|
nowHitbox.setRadius((nowHitbox.getDiametrY()/2)*temp);
|
||||||
// высчитываем в параметры хитбокссеркла нужный радиус и текущую реф поинт.
|
// высчитываем в параметры хитбокссеркла нужный радиус и текущую реф поинт.
|
||||||
// Не забываем высчитать реф поинт хитбокса относительно текущей.
|
// Не забываем высчитать реф поинт хитбокса относительно текущей.
|
||||||
// после чего вызываем listPointsToString и нотифай, который отправляет данные на сохранение
|
// после чего вызываем listPointsToString и нотифай, который отправляет данные на сохранение
|
||||||
notifySubscribers();
|
notifySubscribers();
|
||||||
|
//возвращаем локальные данные текущего рисования хитбокса в нулевые значения.
|
||||||
|
//необходимо, что бы при переходе в новый обьект, при создании хитбокса, очистился кэш канваса.
|
||||||
|
firstIsoPoint = null;
|
||||||
|
currentDiametrX = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,6 @@ public class HitboxRectengleRenderingFunction implements ShapeRenderingFunction
|
|||||||
private List<Point> LocalListPointsIso = new ArrayList<Point>();
|
private List<Point> LocalListPointsIso = new ArrayList<Point>();
|
||||||
private List<Point> LocalListPointsCartesian = new ArrayList<Point>();
|
private List<Point> LocalListPointsCartesian = new ArrayList<Point>();
|
||||||
|
|
||||||
|
|
||||||
public List<Point> getLocalListPointsIso() {
|
public List<Point> getLocalListPointsIso() {
|
||||||
return LocalListPointsIso;
|
return LocalListPointsIso;
|
||||||
}
|
}
|
||||||
@ -82,15 +81,13 @@ public class HitboxRectengleRenderingFunction implements ShapeRenderingFunction
|
|||||||
nowHitbox.getListPointsIso().addAll(LocalListPointsIso);
|
nowHitbox.getListPointsIso().addAll(LocalListPointsIso);
|
||||||
nowHitbox.getListPointsCartesian().addAll(LocalListPointsCartesian);
|
nowHitbox.getListPointsCartesian().addAll(LocalListPointsCartesian);
|
||||||
System.out.println("mouseClicked Event 2 TIME: "+LocalTime.now());
|
System.out.println("mouseClicked Event 2 TIME: "+LocalTime.now());
|
||||||
|
|
||||||
/*
|
|
||||||
* В данном месте при нажатии закрепляющей точки, необходимо вызывать функцию,
|
|
||||||
* которая будет формировать из текущих декартовых координат:
|
|
||||||
* 1. Точку старта и ширину с высотой.
|
|
||||||
* 2. Так же необходимо реализовать слушатель сохранения новых хитбоксов в дерево.
|
|
||||||
*
|
|
||||||
* */
|
|
||||||
notifySubscribers();
|
notifySubscribers();
|
||||||
|
//очистка кэша
|
||||||
|
firstIsoPoint = null;
|
||||||
|
LocalListPointsIso.clear();
|
||||||
|
LocalListPointsCartesian.clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -17,11 +17,18 @@ public class HitboxCircle extends Hitbox {
|
|||||||
radiusHitbox = 0;
|
radiusHitbox = 0;
|
||||||
}
|
}
|
||||||
private void parseStringToCircleHitbox(String[] informations) {
|
private void parseStringToCircleHitbox(String[] informations) {
|
||||||
|
float temp = (float)Math.sqrt(2);
|
||||||
referencePoint.x = Float.parseFloat(informations[1]);
|
referencePoint.x = Float.parseFloat(informations[1]);
|
||||||
referencePoint.y = Float.parseFloat(informations[2]);
|
referencePoint.y = Float.parseFloat(informations[2]);
|
||||||
currentRefPoint.x = owner.getImage().getWidth()/2+referencePoint.x;
|
|
||||||
currentRefPoint.y = owner.getImage().getHeight()+referencePoint.y;
|
|
||||||
radiusHitbox = Float.parseFloat(informations[3]);
|
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(referencePoint.x+cartesianCenterImagePoint.x, referencePoint.y+cartesianCenterImagePoint.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;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public String listPointsToString() {
|
public String listPointsToString() {
|
||||||
|
|||||||
Reference in New Issue
Block a user