Search in sources :

Example 56 with Coordinates

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

the class Dungeon method getPoint.

public Coordinates getPoint(String arg) {
    Coordinates c = null;
    if (arg.contains(ScriptSyntax.SPAWN_POINT) || StringMaster.isInteger(arg)) {
        arg = arg.replace(ScriptSyntax.SPAWN_POINT, "");
        Integer i = StringMaster.getInteger(arg) - 1;
        List<String> spawnPoints = StringMaster.openContainer(getProperty(PROPS.COORDINATE_POINTS));
        c = new Coordinates(spawnPoints.get(i));
    } else {
        Map<String, String> map = new DataUnitFactory(true).deconstructDataString(getProperty(PROPS.NAMED_COORDINATE_POINTS));
        String string = map.get(arg);
        if (string == null) {
            // find
            Object key = new SearchMaster<>().findClosest(arg, map.keySet());
            string = map.get(key);
        }
        return new Coordinates(string);
    }
    return c;
// getProperty(PROPS.ENCOUNTER_SPAWN_POINTS)
}
Also used : Coordinates(main.game.bf.Coordinates) DataUnitFactory(main.system.data.DataUnitFactory)

Example 57 with Coordinates

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

the class DungeonMapGenerator method fill.

private void fill(Coordinates c, String fillerType) {
    ObjType type = DataManager.getType(fillerType, DC_TYPE.BF_OBJ);
    if (type == null) {
        MAP_FILL_TEMPLATE leTemplate = new EnumMaster<MAP_FILL_TEMPLATE>().retrieveEnumConst(MAP_FILL_TEMPLATE.class, fillerType);
        if (leTemplate != null) {
            int i = 0;
            for (Coordinates adj : c.getAdjacentCoordinates()) {
                ObjType objType = objMap.get(adj);
                if (objType != null) {
                    if ((leTemplate.getPeripheryObjects() + leTemplate.getCenterObjects()).contains(objType.getName())) {
                        i++;
                    }
                }
            }
            if (i >= c.getAdjacentCoordinates().size() * 2 / 5) {
                type = RandomWizard.getObjTypeByWeight(leTemplate.getCenterObjects(), DC_TYPE.BF_OBJ);
                objMap.put(c, type);
                return;
            }
            type = RandomWizard.getObjTypeByWeight(leTemplate.getPeripheryObjects(), DC_TYPE.BF_OBJ);
        } else {
            // other random groups
            DUNGEON_MAP_TEMPLATE template = new EnumMaster<DUNGEON_MAP_TEMPLATE>().retrieveEnumConst(DUNGEON_MAP_TEMPLATE.class, fillerType);
            if (template != null) {
                type = RandomWizard.getObjTypeByWeight(template.getObjects(), DC_TYPE.BF_OBJ);
            }
        }
    }
    objMap.put(c, type);
}
Also used : DUNGEON_MAP_TEMPLATE(main.content.enums.DungeonEnums.DUNGEON_MAP_TEMPLATE) ObjType(main.entity.type.ObjType) MAP_FILL_TEMPLATE(main.content.enums.DungeonEnums.MAP_FILL_TEMPLATE) Coordinates(main.game.bf.Coordinates)

Example 58 with Coordinates

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

the class FacingAdjuster method getPartyMemberFacing.

public FACING_DIRECTION getPartyMemberFacing(Unit unit) {
    if (getGame().getGameMode() == GAME_MODES.DUNGEON_CRAWL) {
        return FacingMaster.getOptimalFacingTowardsEmptySpaces(unit);
    }
    Coordinates c = unit.getCoordinates();
    if (isAutoOptimalFacing())
        return getFacingOptimal(c, true);
    if (facingMap.containsKey(c)) {
        return facingMap.get(c);
    }
    MAP_ZONES zone = null;
    for (MAP_ZONES z : MAP_ZONES.values()) {
        for (String s : StringMaster.open(z.getCoordinates(), ",")) {
            if (c.toString().equals(s)) {
                zone = z;
                break;
            }
        }
    }
    if (zone != null) {
        switch(zone) {
            case SIDE_EAST:
                return FACING_DIRECTION.WEST;
            case SIDE_NORTH:
                return FACING_DIRECTION.SOUTH;
            case SIDE_SOUTH:
                return FACING_DIRECTION.NORTH;
            case SIDE_WEST:
                return FACING_DIRECTION.EAST;
        }
    }
    return FACING_DIRECTION.NORTH;
}
Also used : Coordinates(main.game.bf.Coordinates) MAP_ZONES(eidolons.game.battlecraft.logic.dungeon.universal.DungeonMapGenerator.MAP_ZONES)

Example 59 with Coordinates

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

the class Positioner method getEnemyTestPartyCoordinates.

public Coordinates getEnemyTestPartyCoordinates() {
    // TODO encounter?
    // default - getOrCreate a random point in some range from player start
    Coordinates playerC = getPlayerSpawnCoordinates();
    if (// TODO sometimes not?
    true)
        return new Coordinates(playerC.x, playerC.y - (TestSpawner.isPlayerUnitGroupMode() ? 1 : 3));
    if (playerC == null) {
        // Coordinates.getMiddleCoordinate(ArenaPositioner.DEFAULT_PLAYER_SIDE);
        playerC = getPlayerSpawnCoordinates();
    }
    Loop.startLoop(100);
    while (Loop.loopContinues()) {
        int x = playerC.x + RandomWizard.getRandomIntBetween(-4, 4);
        int y = playerC.y + RandomWizard.getRandomIntBetween(-4, 4);
        if (y >= getDungeon().getCellsY() - 1) {
            continue;
        }
        if (x >= getDungeon().getCellsX() - 1) {
            continue;
        }
        if (y <= 0) {
            continue;
        }
        if (x <= 0) {
            continue;
        }
        return new Coordinates(x, y);
    }
    return null;
}
Also used : Coordinates(main.game.bf.Coordinates)

Example 60 with Coordinates

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

the class Spawner method spawnUnitGroup.

protected List<Unit> spawnUnitGroup(boolean me, String filePath) {
    String data = UnitGroupMaster.readGroupFile(filePath);
    boolean mirror = me;
    if (UnitGroupMaster.isFactionMode()) {
        if (UnitGroupMaster.factionLeaderRequired) {
            data += UnitGroupMaster.getHeroData(me);
        }
        mirror = !mirror;
    }
    UnitGroupMaster.setMirror(mirror);
    int width = UnitGroupMaster.maxX;
    int height = UnitGroupMaster.maxY;
    Coordinates offset_coordinate;
    Coordinates spawnCoordinates;
    int offsetX = -width / 2;
    int offsetY = -height / 2;
    if (!UnitGroupMaster.isFactionMode()) {
        UnitGroupMaster.setCurrentGroupHeight(MathMaster.getMaxY(data));
        UnitGroupMaster.setCurrentGroupWidth(MathMaster.getMaxX(data));
        width = 1 + UnitGroupMaster.getCurrentGroupWidth();
        height = 2 * UnitGroupMaster.getCurrentGroupHeight();
        offsetX = -width / 2;
        offsetY = -height / 2;
    } else {
        if (UnitGroupMaster.isMirror()) {
            offsetY -= 1;
        }
    }
    spawnCoordinates = (me) ? getPositioner().getPlayerSpawnCoordinates() : getPositioner().getEnemySpawningCoordinates();
    offset_coordinate = spawnCoordinates.getOffsetByX(offsetX).getOffsetByY(offsetY);
    List<MicroObj> units = DC_ObjInitializer.createUnits(game.getPlayer(me), data, offset_coordinate);
    LogMaster.logToFile("spawnCoordinates=" + spawnCoordinates + " ;offset_coordinate=" + offset_coordinate + ";height=" + height + "; width=" + width);
    LogMaster.log(1, "spawnCoordinates=" + spawnCoordinates + " ;offset_coordinate=" + offset_coordinate + ";height=" + height + "; width=" + width);
    List<Unit> list = new ArrayList<>();
    units.stream().forEach(unit -> list.add((Unit) unit));
    return list;
}
Also used : MicroObj(main.entity.obj.MicroObj) Coordinates(main.game.bf.Coordinates) ArrayList(java.util.ArrayList) Unit(eidolons.entity.obj.unit.Unit)

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