use of eidolons.game.battlecraft.logic.dungeon.location.building.DungeonPlan in project Eidolons by IDemiurge.
the class LE_MapMaster method transform.
public static void transform() {
TRANSFORM transform = new EnumMaster<TRANSFORM>().retrieveEnumConst(TRANSFORM.class, ListChooser.chooseEnum(TRANSFORM.class));
if (transform == null) {
return;
}
Location dungeon = LevelEditor.getCurrentLevel().getLocation();
DungeonPlan plan = dungeon.getPlan();
switch(transform) {
case FLIP_X:
plan.setFlippedX(!plan.isFlippedX());
break;
case FLIP_Y:
plan.setFlippedY(!plan.isFlippedY());
break;
case ROTATE:
plan.setRotated(!plan.isRotated());
break;
}
dungeon.setPlan(plan);
plan = new LocationBuilder().transformDungeonPlan(plan);
dungeon.setPlan(plan);
LevelEditor.getSimulation().getUnits().clear();
LevelEditor.getCurrentLevel().init();
LevelEditor.getCurrentLevel().getMinimap().init();
LevelEditor.getCurrentLevel().getMinimap().getGrid().refresh();
}
use of eidolons.game.battlecraft.logic.dungeon.location.building.DungeonPlan in project Eidolons by IDemiurge.
the class LocationBuilder method buildDungeonPlan.
// static use and save as templates...
public DungeonPlan buildDungeonPlan(Location location) {
if (helper == null) {
helper = new BuildHelper(location, params);
helper.setPlan(plan);
}
if (StringMaster.isEmpty(helper.getParams().getValue(BUILD_PARAMS.FILLER_TYPE))) {
{
if (!location.isUnderground()) {
// return;
}
plan = new DungeonPlan(testTemplate, location);
int x1 = 0;
int x2 = params.getIntValue(BUILD_PARAMS.WIDTH);
if (x2 <= 0) {
x2 = location.getCellsX();
} else {
location.setParam(PARAMS.BF_WIDTH, x2);
}
int y1 = 0;
int y2 = params.getIntValue(BUILD_PARAMS.HEIGHT);
if (y2 <= 0) {
y2 = location.getCellsY();
} else {
location.setParam(PARAMS.BF_HEIGHT, y2);
}
MapZone zone = new MapZone(location.getDungeon(), 0, x1, x2, y1, y2);
List<Coordinates> coordinates = CoordinatesMaster.getCoordinatesWithin(x1 - 1, x2 - 1, y1 - 1, y2 - 1);
new MapBlock(0, BLOCK_TYPE.ROOM, zone, plan, coordinates);
plan.getZones().add(zone);
return plan;
}
}
if (TestDungeonInitializer.PRESET_PLAN != null) {
File file = FileManager.getFile(PathFinder.getDungeonLevelFolder() + TestDungeonInitializer.PRESET_PLAN);
if (file.isFile()) {
String data = FileManager.readFile(file);
DungeonPlan plan = null;
try {
plan = loadDungeonMap(data);
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
return plan;
}
}
// preset in location-mission, based
// on Level?
// yes, any dungeon could have any template more or less,
template = location.getTemplate();
if (testMode) {
template = testTemplate;
}
if (template == null) {
template = DUNGEON_TEMPLATES.CLASSIC;
}
List<MapBlock> blocks = null;
Map<ObjType, Coordinates> objMap = null;
plan = new DungeonPlan(template, location);
location.setPlan(plan);
plan.setBlocks(blocks);
plan.setObjMap(objMap);
plan.setZones(createMapZones());
// Entrance exit = dungeon.getMainExit();
// Entrance entrance = dungeon.getMainEntrance();
// plan.setBaseAnchor(
// entrance.getCoordinates()
// );
// plan.setEndAnchor(exit.getCoordinates());
// if (!dungeon.isIgnoreRotate())
plan.setRotated(location.isRotated());
plan.setFlippedX(location.isFlippedX());
plan.setFlippedY(location.isFlippedY());
placeMainRooms();
if (!location.isSurface()) {
placeCulDeSacs();
}
if (!location.isSurface() && !helper.getParams().isNoRandomRooms()) {
placeAdditionalRooms();
}
if (!location.isSurface() && !helper.getParams().isNoCorridors()) {
linkWithCorridors();
}
return plan;
}
use of eidolons.game.battlecraft.logic.dungeon.location.building.DungeonPlan in project Eidolons by IDemiurge.
the class Location method initRootLevel.
private void initRootLevel() {
// TODO entrance fit?
if (isScenario()) {
String data = FileManager.readFile(PathFinder.getDungeonLevelFolder() + getPlaceOrScenario().getProperty(MACRO_PROPS.ROOT_LEVEL));
DungeonPlan plan = new LocationBuilder().loadDungeonMap(data);
root = plan.getDungeon();
return;
} else {
ObjType type = RandomWizard.getObjTypeByWeight(getPlaceOrScenario().getProperty(MACRO_PROPS.ROOT_POOL), DC_TYPE.DUNGEONS);
root = new Dungeon(type);
}
}
use of eidolons.game.battlecraft.logic.dungeon.location.building.DungeonPlan in project Eidolons by IDemiurge.
the class Location method constructSublevels.
private void constructSublevels() {
dungeon = bossLevel;
int z = dungeon.getZ();
ENTRANCE_LAYOUT entranceLayout = getFirstEntranceLayout(root, DirectionMaster.getRandomDirection());
if (isScenario()) {
// Map<SUBDUNGEON_TYPE, String> map = new
// RandomWizard<SUBDUNGEON_TYPE>()
// .constructStringWeightMap(scenario.getProperty(MACRO_PROPS.RANDOM_SUBLEVELS),
// SUBDUNGEON_TYPE.class);
// e.g. "cave(2);dungeon(3);caste(1); ++ insert *BETWEEN* preset
// string - lvlN(n) - which could be key?.. perhaps just a list of
// strings!
// new RandomWizard<>().constructStringWeightMapInversed(scenario
// .getProperty(MACRO_PROPS.RANDOM_SUBLEVELS), SUBDUNGEON_TYPE)
List<String> list = new ArrayList<>();
for (String stretch : StringMaster.open(scenario.getProperty(MACRO_PROPS.RANDOM_SUBLEVELS))) {
int i = 0;
if (StringMaster.isInteger(stretch)) {
// for (int i = 0; i < StringMaster.getInteger(stretch);
// i++) {
// dungeon = dungeon.getSubLevels().getOrCreate(0); // TODO unsafe
// }
i = StringMaster.getInteger(stretch);
continue;
}
String typeName;
if (stretch.contains(StringMaster.OR)) {
List<String> names = StringMaster.openContainer(stretch, StringMaster.OR);
stretch = names.get(RandomWizard.getRandomListIndex(names));
}
typeName = VariableManager.removeVarPart(stretch);
int depth = (StringMaster.getInteger(VariableManager.getVarPart(stretch)));
SUBDUNGEON_TYPE type = new EnumMaster<SUBDUNGEON_TYPE>().retrieveEnumConst(SUBDUNGEON_TYPE.class, typeName);
String element = i + "=" + typeName + StringMaster.wrapInParenthesis("" + depth);
list.add(element);
// depth = Math.max(1, depth);
}
Dungeon dungeon = root;
for (String stretch : StringMaster.open(scenario.getProperty(PROPS.SUBLEVELS))) {
for (String s : list) {
int i = StringMaster.getInteger(s.split("=")[0]);
VariableManager.removeVarPart((s.split("=")[1]));
VariableManager.getVarPart((s.split("=")[1]));
}
}
String stretch = null;
int depth = RandomWizard.getRandomInt(StringMaster.getInteger(VariableManager.getVarPart(stretch)));
for (int level = 0; level < depth; level++) {
z = (up) ? z++ : z--;
String typeName = null;
File randomFile = FileManager.getRandomFile(PathFinder.getDungeonLevelFolder() + typeName);
// filter?
String data = FileManager.readFile(randomFile);
DungeonPlan plan = new LocationBuilder().loadDungeonMap(data);
ObjType dungeonType = null;
newSublevel(dungeon, dungeonType, z, level, entranceLayout);
// adjust plan , set z
}
} else {
int i = maxLevel;
List<ObjType> typePool = DataManager.toTypeList(getPlaceOrScenario().getProperty(MACRO_PROPS.SUBLEVEL_POOL), DC_TYPE.DUNGEONS);
Map<Integer, ObjType> map = distributeLevels(typePool, maxLevel);
ObjType prevType = null;
int level = 0;
while (true) {
i--;
ObjType type = map.get(i);
if (type != prevType) {
level = 0;
}
z = (up) ? z++ : z--;
level++;
entranceLayout = getNextEntranceLayout(entranceLayout);
dungeon = newSublevel(dungeon, type, z, level, entranceLayout);
// checkAddSecretLevels(dungeon);
if (i <= 0) {
break;
}
prevType = type;
}
}
// dungeon.getSubLevels().add(bossLevel);
}
use of eidolons.game.battlecraft.logic.dungeon.location.building.DungeonPlan in project Eidolons by IDemiurge.
the class Location method initBossLevel.
private void initBossLevel() {
if (isScenario()) {
String data = FileManager.readFile(PathFinder.getDungeonLevelFolder() + getPlaceOrScenario().getProperty(MACRO_PROPS.BOSS_LEVEL));
if (data.isEmpty()) {
return;
}
DungeonPlan plan = new LocationBuilder().loadDungeonMap(data);
bossLevel = plan.getDungeon();
return;
} else {
ObjType type = RandomWizard.getObjTypeByWeight(getPlaceOrScenario().getProperty(MACRO_PROPS.BOSS_LEVEL_POOL), DC_TYPE.DUNGEONS);
bossLevel = new Dungeon(type);
}
// new DungeonMapGenerator().generateMap(bossLevel); ???
}
Aggregations