Search in sources :

Example 1 with MapZone

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

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

the class LE_TreePlanPanel method getTreeCellRendererComponent.

public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    if (value == null) {
        return null;
    }
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
    value = node.getUserObject();
    if (value instanceof MapZone) {
        return getZoneComponent((MapZone) value, selected);
    }
    if (value instanceof MapBlock) {
        return getBlockComponent((MapBlock) value, selected);
    }
    if (value instanceof Obj) {
        return getObjComponent((Obj) value, selected);
    }
    // TODO add dungeon icon
    JLabel label = new JLabel(value.toString());
    label.setForeground(ColorManager.GOLDEN_WHITE);
    label.setFont(FontMaster.getFont(FONT.AVQ, 19, Font.PLAIN));
    return label;
// new DefaultTreeCellRenderer().getTreeCellRendererComponent(tree,
// value, selected, expanded, leaf, row, hasFocus)
}
Also used : MapZone(eidolons.game.battlecraft.logic.dungeon.location.building.MapZone) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) Obj(main.entity.obj.Obj) MapBlock(eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)

Example 3 with MapZone

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

the class LE_TreePlanPanel method initTree.

public void initTree() {
    root = new DefaultMutableTreeNode(plan.getDungeon().getName() + " plan");
    for (MapZone z : plan.getZones()) {
        DefaultMutableTreeNode node = new DefaultMutableTreeNode(z);
        root.add(node);
        for (MapBlock b : plan.getBlocks()) {
            if (b.getType() == BLOCK_TYPE.CORRIDOR) {
                // TODO
                continue;
            }
            DefaultMutableTreeNode blockNode = new DefaultMutableTreeNode(b);
            node.add(blockNode);
            if (b.getObjects() != null) {
                for (Obj o : b.getObjects()) {
                    blockNode.add(new DefaultMutableTreeNode(o));
                    b.getConnectedBlocks();
                }
            }
        }
        root.add(node);
    }
    setTree(new JTree(root));
    tree.setOpaque(false);
    tree.setSize(new Dimension(VISUALS.PLAN_PANEL_FRAME.getWidth() - 50, 20 * 32));
    getTree().setLargeModel(true);
    try {
        getTree().setUI(this);
    } catch (Exception e) {
        // new Thread (
        // getTree().setUI(this); ).start()
        main.system.ExceptionMaster.printStackTrace(e);
    }
    getTree().getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    getTree().setCellRenderer(this);
    getTree().addTreeSelectionListener(this);
}
Also used : MapZone(eidolons.game.battlecraft.logic.dungeon.location.building.MapZone) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) Obj(main.entity.obj.Obj) MapBlock(eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)

Example 4 with MapZone

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

the class LE_TreePlanPanel method valueChanged.

public void valueChanged(final TreeSelectionEvent e1) {
    if (((JTree) e1.getSource()).getSelectionPath() == null) {
        return;
    }
    new Thread(new Runnable() {

        @Override
        public void run() {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) (((JTree) e1.getSource()).getSelectionPath().getLastPathComponent());
            Object value = node.getUserObject();
            if (value instanceof MapBlock) {
                MapBlock block = (MapBlock) value;
                planPanel.setSelectedZone(null);
                planPanel.setSelectedBlock(block);
            }
            if (value instanceof MapZone) {
                MapZone mapZone = (MapZone) value;
                planPanel.setSelectedBlock(null);
            // planPanel.setSelectedZone(mapZone);
            }
            SwingUtilities.invokeLater(new Runnable() {

                public void run() {
                    planPanel.refresh();
                }
            });
        }
    }).start();
}
Also used : MapZone(eidolons.game.battlecraft.logic.dungeon.location.building.MapZone) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) MapBlock(eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)

Example 5 with MapZone

use of eidolons.game.battlecraft.logic.dungeon.location.building.MapZone 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;
}
Also used : MapZone(eidolons.game.battlecraft.logic.dungeon.location.building.MapZone) ObjType(main.entity.type.ObjType) DungeonPlan(eidolons.game.battlecraft.logic.dungeon.location.building.DungeonPlan) Coordinates(main.game.bf.Coordinates) BuildHelper(eidolons.game.battlecraft.logic.dungeon.location.building.BuildHelper) MapBlock(eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock) File(java.io.File)

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