Search in sources :

Example 1 with ObjAtCoordinate

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;
}
Also used : ObjAtCoordinate(main.entity.type.ObjAtCoordinate)

Example 2 with ObjAtCoordinate

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);
}
Also used : ObjAtCoordinate(main.entity.type.ObjAtCoordinate) ObjType(main.entity.type.ObjType) ArrayList(java.util.ArrayList)

Example 3 with ObjAtCoordinate

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;
}
Also used : ObjAtCoordinate(main.entity.type.ObjAtCoordinate) Coordinates(main.game.bf.Coordinates) FACING_DIRECTION(main.game.bf.Coordinates.FACING_DIRECTION) UnitLevelManager(eidolons.client.cc.logic.UnitLevelManager) ObjType(main.entity.type.ObjType) EnumMaster(main.system.auxiliary.EnumMaster)

Example 4 with ObjAtCoordinate

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);
        }
    }
}
Also used : FACING_DIRECTION(main.game.bf.Coordinates.FACING_DIRECTION) ObjAtCoordinate(main.entity.type.ObjAtCoordinate) ObjType(main.entity.type.ObjType) Coordinates(main.game.bf.Coordinates) Event(main.game.logic.event.Event) Unit(eidolons.entity.obj.unit.Unit)

Example 5 with ObjAtCoordinate

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;
}
Also used : FACING_DIRECTION(main.game.bf.Coordinates.FACING_DIRECTION) ObjAtCoordinate(main.entity.type.ObjAtCoordinate) ObjType(main.entity.type.ObjType) Coordinates(main.game.bf.Coordinates)

Aggregations

ObjAtCoordinate (main.entity.type.ObjAtCoordinate)9 ObjType (main.entity.type.ObjType)5 Coordinates (main.game.bf.Coordinates)5 FACING_DIRECTION (main.game.bf.Coordinates.FACING_DIRECTION)3 UnitLevelManager (eidolons.client.cc.logic.UnitLevelManager)2 Unit (eidolons.entity.obj.unit.Unit)1 ArrayList (java.util.ArrayList)1 Obj (main.entity.obj.Obj)1 AiGroupData (main.game.logic.dungeon.editor.logic.AiGroupData)1 Event (main.game.logic.event.Event)1 EnumMaster (main.system.auxiliary.EnumMaster)1