Search in sources :

Example 6 with MapBlock

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

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

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

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

Example 10 with MapBlock

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

the class LocationBuilder method placeCulDeSacs.

// public static ObjType getDungeonTypeFromLevelData(String data) {
// return null;
// }
private void placeCulDeSacs() {
    int n = helper.getParams().CUL_DE_SACS;
    n = MathMaster.applyMod(n, getDungeon().getPlan().getWidthMod());
    n = RandomWizard.getRandomIntBetween(n / 2, n * 2);
    Loop.startLoop(10000);
    while (!Loop.loopEnded()) {
        MapBlock block = new RandomWizard<MapBlock>().getRandomListItem(plan.getBlocks());
        FACING_DIRECTION direction = FacingMaster.getRandomFacing();
        Coordinates baseCoordinate = helper.getRandomWallCoordinate(direction, block);
        if (helper.tryPlaceCorridor(block, baseCoordinate, direction, true)) {
            n--;
        }
        if (n < 0) {
            break;
        }
    }
}
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