use of main.entity.type.ObjType 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.ObjType 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.entity.type.ObjType 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.ObjType 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.entity.type.ObjType 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