Ajouté taille dans la map

This commit is contained in:
galaxyoyo 2015-01-08 18:24:59 +01:00
parent d1905acb8e
commit 24d97922c4
3 changed files with 31 additions and 2 deletions

View File

@ -32,7 +32,7 @@ public class EditorAPI
}
}
return RawMap.create(cases);
return RawMap.create(cases, width, height);
}
private static Gson createGson()

View File

@ -5,16 +5,30 @@ import java.util.List;
public class RawMap
{
private List<RawCase> cases;
private int width;
private int height;
public List<RawCase> getCases()
{
return cases;
}
public static RawMap create(List<RawCase> cases)
public int getWidth()
{
return width;
}
public int getHeight()
{
return height;
}
public static RawMap create(List<RawCase> cases, int width, int height)
{
RawMap rm = new RawMap();
rm.cases = cases;
rm.width = width;
rm.height = height;
return rm;
}
}

View File

@ -13,11 +13,16 @@ import java.util.List;
public class Map
{
private final EditorFrame frame;
private int width;
private int height;
private List<Case> cases = new ArrayList<Case>();
private java.util.Map<Point, Case> casesMap = new HashMap<Point, Case>();
public Map(RawMap raw)
{
this.width = raw.getWidth();
this.height = raw.getHeight();
for (RawCase rc : raw.getCases())
{
cases.add(Case.create(rc.getPosX(), rc.getPosY(), SpriteRegister.getCategory(rc.getCoucheOne().getPrimaryIndex()).get(rc.getCoucheOne().getSecondaryIndex()), SpriteRegister.getCategory(rc.getCoucheTwo().getPrimaryIndex()).get(rc.getCoucheTwo().getSecondaryIndex()), SpriteRegister.getCategory(rc.getCoucheThree().getPrimaryIndex()).get(rc.getCoucheThree().getSecondaryIndex())));
@ -33,6 +38,16 @@ public class Map
return frame;
}
public int getWidth()
{
return width;
}
public int getHeight()
{
return height;
}
public Case getCase(int x, int y)
{
if (casesMap.isEmpty())