New hitbox architecture. But need change function addListElement in class ListGUI and load in class Project
This commit is contained in:
@ -7,7 +7,7 @@ public class HitboxRectangle extends Hitbox {
|
||||
private List<Point> listPointsIso = new ArrayList<Point>();
|
||||
private List<Point> listPointsCartesian = new ArrayList<Point>();
|
||||
private float widthHitbox = 0,heightHitbox = 0; // Ширина и высота хитбокса в декартовых координатах.
|
||||
/*
|
||||
|
||||
public HitboxRectangle(){
|
||||
initListsPoints();
|
||||
}
|
||||
@ -17,22 +17,17 @@ public class HitboxRectangle extends Hitbox {
|
||||
this.listPointsCartesian = listPointsCartesian;
|
||||
initListsPoints();
|
||||
}
|
||||
public HitboxRectangle(String informationHitbox, Entity owner){
|
||||
if(informationHitbox!= null) {
|
||||
setOwnerEntity(owner);
|
||||
initListsPoints();
|
||||
String[] informations = informationHitbox.split(" ");
|
||||
//в 0-м индексе всегда идет название фигуры.Так сделан наш xml.
|
||||
shape = new String(informations[0]);
|
||||
if(shape.equals("Rectangle")) {
|
||||
parseStringToRectangleHitbox(informations);
|
||||
createCartesianPointsFromWidthAndHeigh();
|
||||
convertCartesianPointsToIso();
|
||||
printToConsole();
|
||||
}else if(shape.equals("Circle")) {
|
||||
parseStringToCircleHitbox(informations);
|
||||
}
|
||||
}
|
||||
|
||||
//informationHitbox - default="Rectangle 0 0 96 98"
|
||||
public HitboxRectangle(String[] dataHitbox, Entity owner){
|
||||
super(dataHitbox[0]);
|
||||
setOwnerEntity(owner);
|
||||
initListsPoints();
|
||||
//в 0-м индексе всегда идет название фигуры.Так сделан наш xml.
|
||||
parseStringToRectangleHitbox(dataHitbox);
|
||||
createCartesianPointsFromWidthAndHeigh();
|
||||
convertCartesianPointsToIso();
|
||||
printToConsole();
|
||||
}
|
||||
|
||||
private void initListsPoints() {
|
||||
@ -48,14 +43,14 @@ public class HitboxRectangle extends Hitbox {
|
||||
}
|
||||
}
|
||||
|
||||
private void parseStringToRectangleHitbox(String[] informations) {
|
||||
referencePoint.x = Float.parseFloat(informations[1]);
|
||||
referencePoint.y = Float.parseFloat(informations[2]);
|
||||
widthHitbox = Float.parseFloat(informations[3]);
|
||||
heightHitbox = Float.parseFloat(informations[4]);
|
||||
private void parseStringToRectangleHitbox(String[] dataHitbox) {
|
||||
referencePoint.x = Float.parseFloat(dataHitbox[1]);
|
||||
referencePoint.y = Float.parseFloat(dataHitbox[2]);
|
||||
widthHitbox = Float.parseFloat(dataHitbox[3]);
|
||||
heightHitbox = Float.parseFloat(dataHitbox[4]);
|
||||
|
||||
}
|
||||
|
||||
//тут не правильно реализована функция, т.к. до сих пор нигде не используется. Надо переделать будет.
|
||||
public void convertIsoPointsToCartesian() {
|
||||
Point isoPoint;
|
||||
for (int i = 0 ; i<4;i++) {
|
||||
@ -83,6 +78,11 @@ public class HitboxRectangle extends Hitbox {
|
||||
listPointsCartesian.add(new Point(refCartesianPoint.x,refCartesianPoint.y-heightHitbox));
|
||||
listPointsCartesian.add(new Point(refCartesianPoint.x-widthHitbox,refCartesianPoint.y-heightHitbox));
|
||||
}
|
||||
*/
|
||||
|
||||
public List<Point> getListPointsIso() {
|
||||
return listPointsIso;
|
||||
}
|
||||
public List<Point> getListPointsCartesian() {
|
||||
return listPointsCartesian;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user