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)
}
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);
}
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;
}
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;
}
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;
}
Aggregations