Commit 5e595711 authored by Lucas Delcros's avatar Lucas Delcros

solved spwanning bug

parent ffd27a9d
......@@ -8,6 +8,7 @@ import core.zone.Point;
import core.zone.Zone;
import graphics.guiSkeleton.entityDisplayer.EntityDisplayerType;
import map_generation.tiles.TilePropertyVector;
import map_generation.tiles.TileType;
public class EntitySpecies{
......@@ -59,8 +60,11 @@ public class EntitySpecies{
}
//TODO change this
public boolean canSpawn(Point p) {
return true;
public boolean canSpawn(TileType tile) {
switch (tile){
case WATER : return false;
default : return true;
}
}
}
......@@ -7,6 +7,7 @@ import java.net.URL;
import java.util.HashMap;
import java.util.Objects;
import map_generation.tiles.TileType;
import assets.UsedForLoadingSprites;
import core.zone.Point;
......@@ -87,8 +88,8 @@ public class SpeciesArray {
"Line"+lineError + message);
}
public static boolean canSpawn(Point p,String speciesName){
public static boolean canSpawn(TileType tile,String speciesName){
EntitySpecies species=array.get(speciesName);
return species!=null && species.canSpawn(p);
return species!=null && species.canSpawn(tile);
}
}
......@@ -165,7 +165,7 @@ public final class MapBuilder implements Serializable{
int posY=ii*Point.TileScale;
int posX=jj*Point.TileScale;
//if(tb[jj][ii].getType() != TileType.WATER) entities.add(SpeciesArray.create(posX,posY,100,"Ronflex","Monster "+i));
if(SpeciesArray.canSpawn(Point.construct(posX, posY), "Ronflex")) entities.add(SpeciesArray.create(posX,posY,100,"Ronflex","Monster "+i));
if(SpeciesArray.canSpawn(tb[jj][ii].getType(), "Ronflex")) entities.add(SpeciesArray.create(posX,posY,100,"Ronflex","Monster "+i));
}
}
......
......@@ -97,8 +97,10 @@ public class SurfacesMapGeneration implements Serializable{
int posX=0;
while (bb) { // I choose a random spot for the stairs
idRoom=r.nextInt(rooms.length);
posY=r.nextInt(rooms[idRoom].j2-rooms[idRoom].j1+1)+rooms[idRoom].j1;
posX=r.nextInt(rooms[idRoom].i2-rooms[idRoom].i1+1)+rooms[idRoom].i1;
// posY=r.nextInt(rooms[idRoom].j2-rooms[idRoom].j1+1)+rooms[idRoom].j1;
// posX=r.nextInt(rooms[idRoom].i2-rooms[idRoom].i1+1)+rooms[idRoom].i1;
posX = rooms[idRoom].i1;
posY = rooms[idRoom].j1;
if (3*distanceToStart[posY][posX]>2*max_dist) bb=false; // If the distance from the start position to the stairs position is large enough I choose it (compared to the farest point the player can reach)
}
MapPoint stairsPosition=new MapPoint(posY, posX);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment