Search in sources :

Example 91 with ObjType

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

Example 92 with ObjType

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);
}
Also used : DUNGEON_MAP_TEMPLATE(main.content.enums.DungeonEnums.DUNGEON_MAP_TEMPLATE) ObjType(main.entity.type.ObjType) MAP_FILL_TEMPLATE(main.content.enums.DungeonEnums.MAP_FILL_TEMPLATE) Coordinates(main.game.bf.Coordinates)

Example 93 with ObjType

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;
}
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 94 with ObjType

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

Example 95 with ObjType

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

Aggregations

ObjType (main.entity.type.ObjType)354 ArrayList (java.util.ArrayList)42 Coordinates (main.game.bf.Coordinates)30 Ref (main.entity.Ref)25 Unit (eidolons.entity.obj.unit.Unit)24 OBJ_TYPE (main.content.OBJ_TYPE)18 PROPERTY (main.content.values.properties.PROPERTY)18 DC_TYPE (main.content.DC_TYPE)16 PARAMETER (main.content.values.parameters.PARAMETER)16 File (java.io.File)15 Entity (main.entity.Entity)12 XLinkedMap (main.data.XLinkedMap)11 EnumMaster (main.system.auxiliary.EnumMaster)11 DC_SpellObj (eidolons.entity.active.DC_SpellObj)9 MATERIAL (main.content.enums.entity.ItemEnums.MATERIAL)9 Obj (main.entity.obj.Obj)9 QUALITY_LEVEL (main.content.enums.entity.ItemEnums.QUALITY_LEVEL)8 MusicList (main.music.entity.MusicList)8 Wave (eidolons.game.battlecraft.logic.battle.arena.Wave)6 C_OBJ_TYPE (main.content.C_OBJ_TYPE)6