use of main.game.bf.Coordinates in project Eidolons by IDemiurge.
the class ArenaPositioner method getAdjacentCoordinateInRow.
private Coordinates getAdjacentCoordinateInRow(Coordinates c) {
boolean clockwise = RandomWizard.random();
Coordinates adjacentCoordinate = c.getAdjacentCoordinate(DirectionMaster.rotate90(side.getDirection(), clockwise));
if (checkCanPlaceUnitOnCoordinate(adjacentCoordinate, null)) {
return adjacentCoordinate;
}
adjacentCoordinate = c.getAdjacentCoordinate(DirectionMaster.rotate90(side.getDirection(), !clockwise));
if (checkCanPlaceUnitOnCoordinate(adjacentCoordinate, null)) {
return adjacentCoordinate;
}
return null;
}
use of main.game.bf.Coordinates in project Eidolons by IDemiurge.
the class ArenaPositioner method getCoordinatesForUnitGroup.
public List<ObjAtCoordinate> getCoordinatesForUnitGroup(List<ObjType> presetGroupTypes, Wave wave, int unitLevel) {
Map<Coordinates, ObjType> map = new LinkedHashMap<>();
boolean custom = false;
Coordinates presetCenterCoordinate = wave.getCoordinates();
if (wave.isPresetCoordinate()) {
if (presetCenterCoordinate != null) {
custom = isAutoOptimalFacing();
}
}
if (wave.getBlock() != null) {
// TODO return
// getCoordinatesForUnitGroupInMapBlock(presetGroupTypes, wave,
// wave.getBlock());
}
if (forcedSide != null) {
side = forcedSide;
// forcedSide = null;
} else {
side = new EnumMaster<FACING_DIRECTION>().retrieveEnumConst(FACING_DIRECTION.class, wave.getProperty(PROPS.SPAWNING_SIDE));
if (side == null) {
nextSide();
}
}
unitGroups.put(side, map);
int maxUnitsPerRow = getMaxUnitsPerRow(side);
List<Coordinates> list = getCoordinatesForUnits(presetGroupTypes, custom, presetCenterCoordinate, maxUnitsPerRow);
List<ObjAtCoordinate> group = new ArrayList<>();
int i = 0;
for (Coordinates c : list) {
ObjType type = new ObjType(presetGroupTypes.get(i));
type.getGame().initType(type);
i++;
if (unitLevel > 0) {
type = new UnitLevelManager().getLeveledType(type, unitLevel, false);
}
ObjAtCoordinate objAtCoordinate = new ObjAtCoordinate(type, c);
group.add(objAtCoordinate);
}
return group;
}
use of main.game.bf.Coordinates in project Eidolons by IDemiurge.
the class ArenaPositioner method getCoordinatesForUnits.
public List<Coordinates> getCoordinatesForUnits(List<ObjType> presetGroupTypes, boolean custom, Coordinates presetCenterCoordinate, int maxUnitsPerRow) {
unitCache = new HashMap<>();
List<Coordinates> list = new ArrayList<>();
for (ObjType type : presetGroupTypes) {
// c = getNextSideCoordinate(getBaseCoordinate(side));
Coordinates c;
if (custom) {
c = getFirstLayerCenterCoordinate(presetCenterCoordinate, type, isAutoOptimalFacing());
} else {
c = getNextCoordinate(side, maxUnitsPerRow);
}
List<ObjType> units = unitCache.get(c);
if (units == null) {
units = new ArrayList<>();
}
// TODO [update] use facing with this map..
units.add(type);
unitCache.put(c, units);
list.add(c);
// TODO facingMap.put(c, FacingMaster.rotate180(side)
// // side
// );
// coordinates.add(c);
}
return list;
}
use of main.game.bf.Coordinates in project Eidolons by IDemiurge.
the class ArenaPositioner method getPartyCoordinates.
@Unimplemented
public List<Coordinates> getPartyCoordinates(Coordinates origin, Boolean me, List<String> partyTypes) {
List<Coordinates> list = new ArrayList<>();
// TODO
if (CoreEngine.isArcaneVault() || CoreEngine.isLevelEditor()) {
origin = new Coordinates(PositionMaster.getMiddleIndex(false), PositionMaster.getMiddleIndex(true));
} else {
FACING_DIRECTION side = ArenaPositioner.DEFAULT_PLAYER_SIDE;
// if ( getSpawningSide() != null) {
// side = getSpawningSide();
// }
unitGroups.put(side, new LinkedHashMap<>());
}
return list;
}
use of main.game.bf.Coordinates in project Eidolons by IDemiurge.
the class ArenaSpawner method spawnWave.
private void spawnWave(List<ObjAtCoordinate> unitMap, Wave wave, boolean prespawnMode) {
game.getLogManager().log("New encounter: " + wave.getName());
if (unitMap == null) {
getPositioner().setMaxSpacePercentageTaken(MAX_SPACE_PERC_CREEPS);
wave.initUnitMap();
unitMap = wave.getUnitMap();
}
try {
getBattleMaster().getWaveAssembler().resetPositions(wave);
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
for (ObjAtCoordinate oac : unitMap) {
Coordinates c = oac.getCoordinates();
FACING_DIRECTION facing = getFacingAdjuster().getFacingForEnemy(c);
boolean invalid = false;
if (c == null) {
invalid = true;
} else if (c.isInvalid()) {
invalid = true;
} else if (game.getBattleField().getGrid().isCoordinateObstructed(c)) {
invalid = true;
}
if (invalid) {
c = Positioner.adjustCoordinate(c, facing);
}
ObjType type = oac.getType();
Unit unit = (Unit) game.createUnit(type, c, wave.getOwner());
UnitTrainingMaster.train(unit);
unit.setFacing(facing);
wave.addUnit(unit);
game.fireEvent(new Event(STANDARD_EVENT_TYPE.UNIT_HAS_CHANGED_FACING, Ref.getSelfTargetingRefCopy(unit)));
}
if (!PartyHelper.checkMergeParty(wave)) {
try {
PartyHelper.addCreepParty(wave);
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
}
}
Aggregations