Search in sources :

Example 6 with MapZone

use of eidolons.game.battlecraft.logic.dungeon.location.building.MapZone in project Eidolons by IDemiurge.

the class LocationBuilder method createZone.

private MapZone createZone(DungeonPlan plan, int zoneId, Node zoneNode) {
    String name = zoneNode.getNodeName();
    String nodeName = XML_Formatter.restoreXmlNodeName(name);
    if (!nodeName.contains(",")) {
        nodeName = XML_Formatter.restoreXmlNodeNameOld(name);
    }
    int[] c = CoordinatesMaster.getMinMaxCoordinates(nodeName.split(",")[1]);
    MapZone zone = new MapZone(plan.getDungeon(), zoneId, c[0], c[1], c[2], c[3]);
    return zone;
}
Also used : MapZone(eidolons.game.battlecraft.logic.dungeon.location.building.MapZone)

Example 7 with MapZone

use of eidolons.game.battlecraft.logic.dungeon.location.building.MapZone in project Eidolons by IDemiurge.

the class LE_PlanPanel method edit.

private boolean edit() {
    MapZone zone = getSelectedZone();
    if (zone == null) {
        return false;
    }
    // Boolean filler_size_position =
    // DialogMaster.askAndWait("What to edit for ",
    // "Filler", "Size",
    // "Position");
    // move?
    String prevFiller = zone.getFillerType();
    String filler = DialogMaster.inputText("Set new Filler Type for " + zone.getName() + "...", prevFiller);
    if (filler != null) {
        if (!Objects.equals(filler, prevFiller)) {
            zone.setFillerType(filler);
        }
    }
    // zone.setX1(x1);
    // zone.setName(name)
    // size -> re-fill spaces!
    List<Coordinates> coordinates = zone.getCoordinates();
    for (MapBlock b : zone.getBlocks()) {
        coordinates.removeAll(b.getCoordinates());
    }
    LevelEditor.getMapMaster().replace(prevFiller, filler, coordinates);
    return true;
}
Also used : MapZone(eidolons.game.battlecraft.logic.dungeon.location.building.MapZone) Coordinates(main.game.bf.Coordinates) MapBlock(eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)

Example 8 with MapZone

use of eidolons.game.battlecraft.logic.dungeon.location.building.MapZone in project Eidolons by IDemiurge.

the class LE_MapMaster method addBlock.

public void addBlock(MapBlock block) {
    clearArea(block.getCoordinates(), true);
    Set<MapZone> zones = new HashSet<>();
    // remove from other blocks?
    for (Coordinates c : block.getCoordinates()) {
        MapBlock b = getPlan().getBlockByCoordinate(c);
        if (b != null) {
            b.getCoordinates().remove(c);
            zones.add(b.getZone());
            // blocks.add(b);
            // hard to Undo...
            b.getCoordinates().remove(c);
        // perhaps I can keep a copy of the *PLAN* or even *LEVEL* to
        // return to?
        }
    }
    if (zones.isEmpty()) {
        zones.addAll(getPlan().getZones());
    }
    MapZone zone = (MapZone) zones.toArray()[0];
    if (zones.size() > 1) {
        int index = DialogMaster.optionChoice(zones.toArray(), "Choose zone");
        if (index != -1) {
            zone = (MapZone) zones.toArray()[index];
        }
    }
    zone.addBlock(block);
    block.setZone(zone);
    LevelEditor.getMainPanel().getPlanPanel().getTreePanel().blockAdded(block);
    getPlan().getBlocks().add(block);
// for (MapBlock b: blocks){
// b.getCoordinates().removeAll(block.getCoordinates());
// }
}
Also used : MapZone(eidolons.game.battlecraft.logic.dungeon.location.building.MapZone) Coordinates(main.game.bf.Coordinates) MapBlock(eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock) HashSet(java.util.HashSet)

Example 9 with MapZone

use of eidolons.game.battlecraft.logic.dungeon.location.building.MapZone in project Eidolons by IDemiurge.

the class DungeonBuilder method initDynamicObjData.

protected void initDynamicObjData(Location location, DungeonPlan plan) {
    int z = location.getIntParam(G_PARAMS.Z_LEVEL);
    for (MapBlock b : plan.getBlocks()) {
        ArrayList<Obj> objects = new ArrayList<>(b.getObjects());
        for (Obj obj : objects) {
            // TODO of course - the issue was that I added an object to
            // block too! ... init?
            BattleFieldObject unit = (BattleFieldObject) obj;
            if (z != 0) {
                unit.setZ(z);
            }
        }
    }
    for (MapZone zone : plan.getZones()) {
        ObjType wallType = DataManager.getType(zone.getFillerType(), DC_TYPE.BF_OBJ);
        if (wallType == null)
            continue;
        List<Coordinates> list = zone.getCoordinates();
        for (MapBlock b : zone.getBlocks()) {
            list.removeAll(b.getCoordinates());
        }
        for (Coordinates c : list) {
            getGame().getManager().getObjCreator().createUnit(wallType, c.x, c.y, Player.NEUTRAL, new Ref(game));
        }
    }
    for (Obj obj : plan.getWallObjects()) {
        BattleFieldObject unit = (BattleFieldObject) obj;
        if (z != 0) {
            unit.setZ(z);
        }
    }
    if (plan.getDirectionMap() != null) {
        try {
            DC_ObjInitializer.initDirectionMap(z, plan.getDirectionMap());
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        }
    }
    if (plan.getFlipMap() != null) {
        try {
            DC_ObjInitializer.initFlipMap(z, plan.getFlipMap());
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        }
    }
}
Also used : MapZone(eidolons.game.battlecraft.logic.dungeon.location.building.MapZone) Ref(main.entity.Ref) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) ObjType(main.entity.type.ObjType) Obj(main.entity.obj.Obj) Coordinates(main.game.bf.Coordinates) ArrayList(java.util.ArrayList) MapBlock(eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)

Example 10 with MapZone

use of eidolons.game.battlecraft.logic.dungeon.location.building.MapZone in project Eidolons by IDemiurge.

the class LocationBuilder method createMapZones.

private List<MapZone> createMapZones() {
    List<MapZone> list = new ArrayList<>();
    int i = 0;
    MapZone zone = new MapZone(getDungeon().getDungeon(), i, 0, getDungeon().getCellsX(), 0, getDungeon().getCellsY());
    list.add(zone);
    // }
    return list;
}
Also used : MapZone(eidolons.game.battlecraft.logic.dungeon.location.building.MapZone)

Aggregations

MapZone (eidolons.game.battlecraft.logic.dungeon.location.building.MapZone)11 MapBlock (eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)9 Coordinates (main.game.bf.Coordinates)4 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)3 Obj (main.entity.obj.Obj)3 ObjType (main.entity.type.ObjType)2 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)1 ROOM_TYPE (eidolons.game.battlecraft.logic.dungeon.location.LocationBuilder.ROOM_TYPE)1 BuildHelper (eidolons.game.battlecraft.logic.dungeon.location.building.BuildHelper)1 DungeonPlan (eidolons.game.battlecraft.logic.dungeon.location.building.DungeonPlan)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Ref (main.entity.Ref)1 Node (org.w3c.dom.Node)1