Search in sources :

Example 46 with Coordinates

use of main.game.bf.Coordinates in project Eidolons by IDemiurge.

the class Level method addObj.

// TODO *added*
public void addObj(Unit obj, boolean stack) {
    Coordinates c = obj.getCoordinates();
    addObj(obj, c, stack);
}
Also used : Coordinates(main.game.bf.Coordinates)

Example 47 with Coordinates

use of main.game.bf.Coordinates in project Eidolons by IDemiurge.

the class Location method initEntrances.

public void initEntrances() {
    if (StringMaster.isEmpty(entranceData)) {
        entranceData = getProperty(PROPS.DUNGEON_MAIN_ENTRANCES, true);
    }
    if (StringMaster.isEmpty(entranceData)) {
        return;
    }
    String enterData = entranceData.split(DungeonLevelMaster.ENTRANCE_SEPARATOR)[0];
    String name = VariableManager.removeVarPart(enterData);
    Coordinates c = new Coordinates(true, VariableManager.getVar(enterData));
    for (Entrance e : getEntrances()) {
        if (e.getCoordinates().equals(c)) {
            if (e.getName().equals(name)) {
                setMainEntrance(e);
            }
        }
    }
    if (getMainEntrance() == null) {
        setMainEntrance(new Entrance(c.x, c.y, DataManager.getType(name, DC_TYPE.BF_OBJ), getDungeon(), getDungeon()));
    }
    if (entranceData.split(DungeonLevelMaster.ENTRANCE_SEPARATOR).length < 2) {
        return;
    }
    String exitData = entranceData.split(DungeonLevelMaster.ENTRANCE_SEPARATOR)[1];
    name = VariableManager.removeVarPart(exitData);
    c = new Coordinates(true, VariableManager.getVar(exitData));
    for (Entrance e : getEntrances()) {
        if (e.getCoordinates().equals(c)) {
            if (e.getName().equals(name)) {
                setMainExit(e);
            }
        }
    }
    if (getMainExit() == null) {
        setMainExit(new Entrance(c.x, c.y, DataManager.getType(name, DC_TYPE.BF_OBJ), getDungeon(), getDungeon()));
    }
}
Also used : Entrance(eidolons.game.module.dungeoncrawl.dungeon.Entrance) Coordinates(main.game.bf.Coordinates)

Example 48 with Coordinates

use of main.game.bf.Coordinates 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 49 with Coordinates

use of main.game.bf.Coordinates 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)

Example 50 with Coordinates

use of main.game.bf.Coordinates in project Eidolons by IDemiurge.

the class LocationBuilder method constructBlock.

@Refactor
public static // TODO the way it's done, we can't have Structures in non-Location dungeons!!!
MapBlock constructBlock(Node node, int id, MapZone zone, DungeonPlan map, Dungeon dungeon) {
    List<Coordinates> coordinates = new ArrayList<>();
    Map<Coordinates, ? extends Obj> objectMap = new HashMap<>();
    MapBlock b = new MapBlock(id, null, zone, map, coordinates);
    // TODO b-data, coordinates, objects
    for (Node subNode : XML_Converter.getNodeList(node)) {
        if (StringMaster.compareByChar(subNode.getNodeName(), COORDINATES_NODE)) {
            coordinates = CoordinatesMaster.getCoordinatesFromString(subNode.getTextContent());
        } else if (StringMaster.compareByChar(subNode.getNodeName(), OBJ_NODE)) {
            // TODO BETTER IN TYPES?
            objectMap = DC_ObjInitializer.initMapBlockObjects(dungeon, b, subNode.getTextContent());
        // TODO encounters?
        } else {
            // BLOCK TYPE
            if (StringMaster.compareByChar(subNode.getNodeName(), BLOCK_TYPE_NODE)) {
                BLOCK_TYPE type = new EnumMaster<BLOCK_TYPE>().retrieveEnumConst(BLOCK_TYPE.class, subNode.getTextContent());
                b.setType(type);
            }
            if (StringMaster.compareByChar(subNode.getNodeName(), ROOM_TYPE_NODE)) {
                ROOM_TYPE type = new EnumMaster<ROOM_TYPE>().retrieveEnumConst(ROOM_TYPE.class, subNode.getTextContent());
                b.setRoomType(type);
            }
        }
    }
    b.setCoordinates(coordinates);
    if (objectMap == null) {
        return b;
    }
    b.getMap().putAll(objectMap);
    b.getObjects().addAll(objectMap.values());
    return b;
}
Also used : EnumMaster(main.system.auxiliary.EnumMaster) Coordinates(main.game.bf.Coordinates) Node(org.w3c.dom.Node) MapBlock(eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock) Refactor(main.system.util.Refactor)

Aggregations

Coordinates (main.game.bf.Coordinates)226 Unit (eidolons.entity.obj.unit.Unit)49 ObjType (main.entity.type.ObjType)30 ArrayList (java.util.ArrayList)29 Obj (main.entity.obj.Obj)28 DC_Obj (eidolons.entity.obj.DC_Obj)22 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)21 FACING_DIRECTION (main.game.bf.Coordinates.FACING_DIRECTION)21 DIRECTION (main.game.bf.Coordinates.DIRECTION)20 Ref (main.entity.Ref)15 MapBlock (eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)13 DC_Cell (eidolons.entity.obj.DC_Cell)12 Action (eidolons.game.battlecraft.ai.elements.actions.Action)11 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)9 BufferedImage (java.awt.image.BufferedImage)8 DequeImpl (main.system.datatypes.DequeImpl)8 Vector2 (com.badlogic.gdx.math.Vector2)7 DC_UnitAction (eidolons.entity.active.DC_UnitAction)7 ZCoordinates (main.game.bf.ZCoordinates)6 ObjAtCoordinate (main.entity.type.ObjAtCoordinate)5