use of main.entity.type.ObjAtCoordinate in project Eidolons by IDemiurge.
the class UnitGroupMaster method saveGroup.
private static String saveGroup(List<ObjAtCoordinate> units, String faction, String name) {
String content = "";
for (ObjAtCoordinate obj : units) {
content += DC_ObjInitializer.getObjString(obj) + DC_ObjInitializer.OBJ_SEPARATOR;
}
XML_Writer.write(content, getGroupFilePath(faction), name + ".xml");
return content;
}
use of main.entity.type.ObjAtCoordinate in project Eidolons by IDemiurge.
the class UnitGroupMaster method createUnitGroup.
public static String createUnitGroup(Entity hero, ObjType factionType, int level) {
power = 0;
limit = getPowerForLevel(level);
if (CoreEngine.isArcaneVault()) {
limit += limit / 5;
}
min = 2;
max = 5 + level / 2;
power_limit = limit / 2;
unitList = (new ArrayList<>());
int i = 0;
while (true) {
ObjType unit = chooseUnit(factionType, limit - power, power_limit);
if (unit == null) {
if (i < min) {
if (!DialogMaster.confirm("You must select at least " + (min - i) + " more units, proceed or abort?")) {
return null;
}
continue;
}
if (i >= max) {
if (DialogMaster.confirm("You have selected maximum number of units " + (max - i) + " do you wish to proceed? Power points remaining: " + getRemainingPower())) {
break;
}
ObjType last = getUnitList().get(getUnitList().size() - 1);
if (!DialogMaster.confirm("Do you wish to remove last - " + last.getName() + "?")) {
break;
}
getUnitList().remove(last);
power += getUnitCost(last, factionType);
continue;
}
break;
}
i++;
power += getUnitCost(unit, factionType);
getUnitList().add(unit);
}
String name = DialogMaster.inputText("Enter a name for this group", getNewName(factionType.getName(), level));
List<ObjAtCoordinate> units = mapPositions(getUnitList(), hero);
if (CoreEngine.isArcaneVault()) {
name = "std " + name;
}
return saveGroup(units, factionType.getName(), name);
}
use of main.entity.type.ObjAtCoordinate 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.entity.type.ObjAtCoordinate 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);
}
}
}
use of main.entity.type.ObjAtCoordinate in project Eidolons by IDemiurge.
the class WaveAssembler method applyFill.
public boolean applyFill() {
// TODO for each group, add a (next) unit from filler pool
int i = 0;
for (List<ObjAtCoordinate> group : unitGroups) {
ObjType objType = getFillingType();
if (objType == null) {
return false;
}
FACING_DIRECTION side;
try {
side = positioner.getSides().get(i);
} catch (Exception e) {
// if (group.size() == 0)
return false;
// Coordinates c = (Coordinates) group.keySet().toArray()[0];
// if (c == null)
// return false;
// side = positioner.getFacingForEnemy(c);
}
i++;
Coordinates c = null;
try {
c = positioner.getCoordinatesForNewUnitInGroup(side, objType);
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
if (c == null) {
return false;
}
ObjAtCoordinate objAtCoordinate = new ObjAtCoordinate(objType, c);
group.add(objAtCoordinate);
typeMap.add(objAtCoordinate);
if (fillApplied >= getMaxFillNumber() || !checkPowerAdjustmentNeeded()) {
return false;
}
}
return true;
}
Aggregations