Search in sources :

Example 1 with MapBlock

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);
    }
}
Also used : Coordinates(main.game.bf.Coordinates) MapBlock(eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)

Example 2 with MapBlock

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);
        }
    }
}
Also used : Obj(main.entity.obj.Obj) Coordinates(main.game.bf.Coordinates) MapBlock(eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)

Example 3 with MapBlock

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);
}
Also used : ROOM_TYPE(eidolons.game.battlecraft.logic.dungeon.location.LocationBuilder.ROOM_TYPE) MapZone(eidolons.game.battlecraft.logic.dungeon.location.building.MapZone) MapBlock(eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)

Example 4 with MapBlock

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);
    }
}
Also used : Coordinates(main.game.bf.Coordinates) ArrayList(java.util.ArrayList) XList(main.data.XList) MapBlock(eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)

Example 5 with MapBlock

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);
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) 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