Search in sources :

Example 16 with MapBlock

use of eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock 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 17 with MapBlock

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

the class LE_MapMaster method removeBlock.

public void removeBlock(MapBlock block) {
    // fill
    LevelEditor.getMainPanel().getPlanPanel().getTreePanel().blockRemoved(block);
    LE_ObjMaster.removeObjects(block.getCoordinates());
    LE_ObjMaster.fill(block.getCoordinates(), DataManager.getType(block.getZone().getFillerType(), DC_TYPE.BF_OBJ));
    for (MapBlock b : getPlan().getBlocks()) {
        // connected
        b.getConnectedBlocks().remove(block);
    }
    getPlan().getBlocks().remove(block);
}
Also used : MapBlock(eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)

Example 18 with MapBlock

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

the class Level method removeObj.

public void removeObj(DC_Obj obj) {
    Chronos.mark("removing " + obj);
    Unit unit = null;
    if (obj instanceof Unit) {
        unit = (Unit) obj;
    }
    if (obj instanceof Entrance) {
        if (location.getMainEntrance() != null) {
            location.setMainEntrance(null);
            location.getPlan().setEntranceLayout(null);
        } else if (location.getMainExit() == null) {
            location.setMainExit(null);
            location.getPlan().setExitLayout(null);
        }
        location.getEntrances().remove(obj);
    }
    // TODO getOrCreate Top object!
    // ++ ZOrder...
    Coordinates coordinates = obj.getCoordinates();
    LevelEditor.getSimulation().remove(obj);
    // TODO ???
    // obj = dungeon.getMinimap().getGrid().getTopObj(coordinates);
    // if (obj != null)
    // if (!unit.isOverlaying())TODO
    MapBlock b = LevelEditor.getMapMaster().getBlock();
    if (b == null) {
        b = getBlockForCoordinate(coordinates, false);
    }
    if (b != null) {
        boolean result = !b.removeObject(obj, coordinates);
        if (result) {
            if (unit.isLandscape()) {
                b.addCoordinate(obj.getCoordinates());
            }
        }
    } else {
        b = LevelEditor.getMainPanel().getPlanPanel().getSelectedBlock();
        if (b == null) {
            b = getBlockForCoordinate(coordinates, true);
        } else if (!CoordinatesMaster.isAdjacent(b.getCoordinates(), coordinates)) {
            b = getBlockForCoordinate(coordinates, true);
        }
        if (b != null) {
            if (!unit.isOverlaying()) {
                b.addCoordinate(obj.getCoordinates());
            }
        }
    }
    if (unit != null) {
        if (!unit.isOverlaying()) // if (LevelEditor.isMinimapMode())
        {
            if (LE_MapViewComp.isMinimapMode()) {
                LevelEditor.getMainPanel().getMiniGrid().refreshComp(null, obj.getCoordinates());
            } else {
                LE_MapViewComp comp = LevelEditor.getMainPanel().getMapViewComp();
                comp.getGrid().getCompForObject(obj).refresh();
                comp.getGrid().refresh();
                comp.getGrid().getCompForObject(obj).refresh();
                comp.getGrid().getPanel().repaint();
            }
        }
    }
    // TODO ADD COORDINATE!
    Chronos.logTimeElapsedForMark("removing " + obj);
}
Also used : Entrance(eidolons.game.module.dungeoncrawl.dungeon.Entrance) Coordinates(main.game.bf.Coordinates) LE_MapViewComp(main.game.logic.dungeon.editor.gui.LE_MapViewComp) MapBlock(eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock) Unit(eidolons.entity.obj.unit.Unit)

Example 19 with MapBlock

use of eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock 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 20 with MapBlock

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

the class LocationBuilder method linkWithCorridors.

private void linkWithCorridors() {
    // TODO link each room, some more than once...
    // TODO
    List<MapBlock> blocksToLink = new ArrayList<>(plan.getBlocks());
    for (MapBlock b : plan.getBlocks()) {
        if (b.getType() == BLOCK_TYPE.CULDESAC) {
            blocksToLink.remove(b);
        }
    }
    // TODO fail condition? u
    Loop.startLoop(10000);
    while (!blocksToLink.isEmpty()) {
        List<MapBlock> blocksToRemove = new ArrayList<>();
        for (MapBlock block : blocksToLink) {
            if (block.getConnectedBlocks().size() > 1) {
                blocksToRemove.add(block);
                continue;
            }
            FACING_DIRECTION direction = FacingMaster.getRandomFacing();
            Coordinates baseCoordinate = helper.getRandomWallCoordinate(direction, block);
            if (helper.tryPlaceCorridor(block, baseCoordinate, direction)) {
                if (// TODO depends!
                block.getConnectedBlocks().size() > 1) {
                    blocksToRemove.add(block);
                }
            }
        }
        if (Loop.loopEnded()) {
            break;
        }
        blocksToLink.removeAll(blocksToRemove);
    }
}
Also used : FACING_DIRECTION(main.game.bf.Coordinates.FACING_DIRECTION) Coordinates(main.game.bf.Coordinates) MapBlock(eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)

Aggregations

MapBlock (eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)22 Coordinates (main.game.bf.Coordinates)13 MapZone (eidolons.game.battlecraft.logic.dungeon.location.building.MapZone)9 Obj (main.entity.obj.Obj)4 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)3 ObjType (main.entity.type.ObjType)3 ArrayList (java.util.ArrayList)2 XList (main.data.XList)2 Ref (main.entity.Ref)2 FACING_DIRECTION (main.game.bf.Coordinates.FACING_DIRECTION)2 Node (org.w3c.dom.Node)2 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)1 DC_Obj (eidolons.entity.obj.DC_Obj)1 Unit (eidolons.entity.obj.unit.Unit)1 GroupAI (eidolons.game.battlecraft.ai.GroupAI)1 Wave (eidolons.game.battlecraft.logic.battle.arena.Wave)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 Entrance (eidolons.game.module.dungeoncrawl.dungeon.Entrance)1