use of eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock in project Eidolons by IDemiurge.
the class LE_MapMaster method moveZone.
public void moveZone(MapZone zone) {
SoundMaster.playStandardSound(STD_SOUNDS.FAIL);
Coordinates c = pickCoordinate();
int offsetX = c.x - zone.getX1();
int offsetY = c.y - zone.getY1();
for (MapBlock b : zone.getBlocks()) {
moveBlock(b, offsetX, offsetY);
}
}
use of eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock in project Eidolons by IDemiurge.
the class LE_MapMaster method loadBlock.
public void loadBlock(MapBlock block) {
if (block == null) {
return;
}
Coordinates c = pickCoordinate();
int offsetX = -CoordinatesMaster.getMinX(block.getCoordinates()) + c.x;
int offsetY = -CoordinatesMaster.getMinY(block.getCoordinates()) + c.y;
List<Coordinates> coordinates = CoordinatesMaster.getCoordinatesWithOffset(block.getCoordinates(), offsetX, offsetY);
// coordinates=CoordinatesMaster.getCoordinatesWithin(c.x, , c.y, y1);
this.block = new MapBlock(getPlan().getBlocks().size(), block.getType(), getPlan().getZones().get(0), getPlan(), coordinates);
// should add to this.block
clearArea(coordinates);
for (Obj obj : block.getObjects()) {
// beware deadlock
LevelEditor.getCurrentLevel().setInitialized(false);
try {
Coordinates newCoordinates = new Coordinates(obj.getCoordinates().x + offsetX, obj.getCoordinates().y + offsetY);
obj.setCoordinates(newCoordinates);
LevelEditor.getObjMaster().addObj(obj.getType(), obj.getCoordinates());
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
} finally {
LevelEditor.getCurrentLevel().setInitialized(true);
}
}
}
use of eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock in project Eidolons by IDemiurge.
the class LE_MapMaster method newRoom.
public void newRoom(List<Coordinates> coordinates) {
ROOM_TYPE type = chooseRoomType();
if (type == null) {
return;
}
if (coordinates == null) {
coordinates = pickCoordinates();
}
MapZone zone = pickZone(coordinates);
MapBlock b = new MapBlock(getPlan().getBlocks().size(), BLOCK_TYPE.ROOM, zone, getPlan(), coordinates);
b.setRoomType(type);
addBlock(b);
}
use of eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock in project Eidolons by IDemiurge.
the class LE_MapMaster method clearArea.
public void clearArea(List<Coordinates> coordinates, boolean ignoreBlockChoice) {
if (!ignoreBlockChoice) {
ArrayList<MapBlock> blocks = new ArrayList<>();
for (Coordinates c : CoordinatesMaster.getCornerCoordinates(coordinates)) {
MapBlock b = getLevel().getBlockForCoordinate(c, true, blocks);
if (b != null) {
if (!blocks.contains(b)) {
blocks.add(b);
}
}
}
if (blocks.size() > 1) {
XList<Object> list = new XList<>(blocks.toArray());
list.add(0, "New");
list.add("Fit for each");
int i = DialogMaster.optionChoice(list.toArray(), "Which block to add coordinates to?");
if (i > 0 && i != list.size() - 1) {
setBlock(blocks.get(i - 1));
} else {
if (i == 0) {
if (DialogMaster.confirm("Create new block?")) {
newRoom(coordinates);
}
}
}
}
}
try {
LE_ObjMaster.removeObjects(coordinates);
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
} finally {
setBlock(null);
}
}
use of eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock in project Eidolons by IDemiurge.
the class Level method addObj.
public void addObj(Unit obj, Coordinates c, boolean stack) {
Chronos.mark("adding " + obj);
obj.setZ(location.getZ());
if (stack) {
if (obj.isLandscape()) {
stack = false;
}
}
// if (!obj.isOverlaying())
// getTopObjMap().put(c, obj);
// if (obj instanceof Entrance) {
// if (location.getMainEntrance() == null) {
// location.setMainEntrance((Entrance) obj);
// location.getPlan().setEntranceLayout(
// DungeonLevelMaster.getLayout(location.getPlan(), c));
// LogMaster.log(1, "Main Entrance: " + obj + "; initComps = "
// + location.getPlan().getEntranceLayout());
// } else if (location.getMainExit() == null) {
// location.setMainExit((Entrance) obj);
// location.getPlan().setExitLayout(DungeonLevelMaster.getLayout(location.getPlan(), c));
// LogMaster.log(1, "Main Exit: " + obj + "; initComps = "
// + location.getPlan().getExitLayout());
// }
// location.getEntrances().add((Entrance) obj);
//
// }
cache();
// overwrite
if (!obj.isOverlaying() && !stack && initialized) {
// for (DC_Obj o : mapObjects)
// if (o.getCoordinates().equals(obj.getCoordinates())) {
List<DC_Obj> objects = getObjects(null, c);
objects.remove(obj);
removeObjects(objects);
}
MapBlock b = getBlockForCoordinate(c, false);
if (b != null) {
if (obj.isLandscape() && obj.getType().getName().equalsIgnoreCase(b.getZone().getFillerType())) {
b.getCoordinates().remove(c);
} else if (initialized) {
b.addObject(obj, c);
}
// TODO
} else {
if (!obj.isLandscape()) {
getWallObjects().add(obj);
}
}
Chronos.logTimeElapsedForMark("adding " + obj);
}
Aggregations