Search in sources :

Example 81 with ObjType

use of main.entity.type.ObjType in project Eidolons by IDemiurge.

the class LocationBuilder method buildDungeonPlan.

// static use and save as templates...
public DungeonPlan buildDungeonPlan(Location location) {
    if (helper == null) {
        helper = new BuildHelper(location, params);
        helper.setPlan(plan);
    }
    if (StringMaster.isEmpty(helper.getParams().getValue(BUILD_PARAMS.FILLER_TYPE))) {
        {
            if (!location.isUnderground()) {
            // return;
            }
            plan = new DungeonPlan(testTemplate, location);
            int x1 = 0;
            int x2 = params.getIntValue(BUILD_PARAMS.WIDTH);
            if (x2 <= 0) {
                x2 = location.getCellsX();
            } else {
                location.setParam(PARAMS.BF_WIDTH, x2);
            }
            int y1 = 0;
            int y2 = params.getIntValue(BUILD_PARAMS.HEIGHT);
            if (y2 <= 0) {
                y2 = location.getCellsY();
            } else {
                location.setParam(PARAMS.BF_HEIGHT, y2);
            }
            MapZone zone = new MapZone(location.getDungeon(), 0, x1, x2, y1, y2);
            List<Coordinates> coordinates = CoordinatesMaster.getCoordinatesWithin(x1 - 1, x2 - 1, y1 - 1, y2 - 1);
            new MapBlock(0, BLOCK_TYPE.ROOM, zone, plan, coordinates);
            plan.getZones().add(zone);
            return plan;
        }
    }
    if (TestDungeonInitializer.PRESET_PLAN != null) {
        File file = FileManager.getFile(PathFinder.getDungeonLevelFolder() + TestDungeonInitializer.PRESET_PLAN);
        if (file.isFile()) {
            String data = FileManager.readFile(file);
            DungeonPlan plan = null;
            try {
                plan = loadDungeonMap(data);
            } catch (Exception e) {
                main.system.ExceptionMaster.printStackTrace(e);
            }
            return plan;
        }
    }
    // preset in location-mission, based
    // on Level?
    // yes, any dungeon could have any template more or less,
    template = location.getTemplate();
    if (testMode) {
        template = testTemplate;
    }
    if (template == null) {
        template = DUNGEON_TEMPLATES.CLASSIC;
    }
    List<MapBlock> blocks = null;
    Map<ObjType, Coordinates> objMap = null;
    plan = new DungeonPlan(template, location);
    location.setPlan(plan);
    plan.setBlocks(blocks);
    plan.setObjMap(objMap);
    plan.setZones(createMapZones());
    // Entrance exit = dungeon.getMainExit();
    // Entrance entrance = dungeon.getMainEntrance();
    // plan.setBaseAnchor(
    // entrance.getCoordinates()
    // );
    // plan.setEndAnchor(exit.getCoordinates());
    // if (!dungeon.isIgnoreRotate())
    plan.setRotated(location.isRotated());
    plan.setFlippedX(location.isFlippedX());
    plan.setFlippedY(location.isFlippedY());
    placeMainRooms();
    if (!location.isSurface()) {
        placeCulDeSacs();
    }
    if (!location.isSurface() && !helper.getParams().isNoRandomRooms()) {
        placeAdditionalRooms();
    }
    if (!location.isSurface() && !helper.getParams().isNoCorridors()) {
        linkWithCorridors();
    }
    return plan;
}
Also used : MapZone(eidolons.game.battlecraft.logic.dungeon.location.building.MapZone) ObjType(main.entity.type.ObjType) DungeonPlan(eidolons.game.battlecraft.logic.dungeon.location.building.DungeonPlan) Coordinates(main.game.bf.Coordinates) BuildHelper(eidolons.game.battlecraft.logic.dungeon.location.building.BuildHelper) MapBlock(eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock) File(java.io.File)

Example 82 with ObjType

use of main.entity.type.ObjType in project Eidolons by IDemiurge.

the class LocationSpawner method getCreepGroupForBlock.

private Wave getCreepGroupForBlock(int preferredPower, Dungeon dungeon, MapBlock block, int min, int max) {
    // alt? vielleicht fur einige spezielle orte...
    String property = dungeon.getProperty(PROPS.ENCOUNTERS);
    int mod = block.getSpawningPriority();
    if (mod == 0) {
        mod = 100;
    }
    Wave wave;
    List<ObjType> list = DataManager.toTypeList(property, DC_TYPE.ENCOUNTERS);
    Collections.shuffle(list);
    ObjType type = null;
    for (ObjType t : list) {
        type = t;
        if (EncounterMaster.getPower(type, false) < min * mod / 100) {
            continue;
        }
        if (EncounterMaster.getPower(type, false) > max * mod / 100) {
            continue;
        }
        break;
    }
    if (type == null) {
        type = new RandomWizard<ObjType>().getObjectByWeight(property, ObjType.class);
    }
    wave = new Wave(type, game, new Ref(game), game.getPlayer(false));
    wave.setPreferredPower(preferredPower * mod / 100);
    wave.setBlock(block);
    return wave;
}
Also used : Wave(eidolons.game.battlecraft.logic.battle.arena.Wave) Ref(main.entity.Ref) ObjType(main.entity.type.ObjType) RandomWizard(main.system.auxiliary.RandomWizard)

Example 83 with ObjType

use of main.entity.type.ObjType in project Eidolons by IDemiurge.

the class LocationSpawner method spawnDungeonCreeps.

public void spawnDungeonCreeps(Location dungeon) {
    String info = dungeon.getProperty(PROPS.ENCOUNTER_INFO);
    Map<Coordinates, Integer> delayMap = new HashMap<>();
    for (String substring : StringMaster.open(info)) {
        Coordinates c = new Coordinates(substring.split("")[0]);
        int round = StringMaster.getInteger(substring.split("=")[1]);
        delayMap.put(c, round);
    }
    /*
         * Assign block per creep group? So a dungeon has a repertoire and map template...
		 * then we calculate total power...
		 * First, spawn the 'must have' groups, around entrances and treasures
		 */
    if (dungeon.isSublevel()) {
    } else {
    // different alg?
    }
    // PartyManager.getParty().getTotalPower();
    // int power = DungeonMaster.getDungeonPowerTotal(dungeon);
    // int maxGroups = dungeon.getIntParam(PARAMS.MAX_GROUPS);
    int power = 0;
    int preferredPower = dungeon.getLevel() + // + PartyManager.getParty().getPower()
    getBattleMaster().getOptionManager().getOptions().getBattleLevel();
    int min = preferredPower * 2 / 3;
    int max = preferredPower * 3 / 2;
    for (MapBlock block : dungeon.getPlan().getBlocks()) {
        Wave group;
        if (specialEncounters.get(dungeon) != null) {
            Map<Coordinates, ObjType> specEncounters = specialEncounters.get(dungeon).get(block);
            for (Coordinates c : specEncounters.keySet()) {
                ObjType waveType = specEncounters.get(c);
                if (waveType.getGroup().equalsIgnoreCase("Substitute")) {
                    waveType = EncounterMaster.getSubstituteEncounterType(waveType, dungeon.getDungeon(), preferredPower);
                }
                group = new Wave(waveType, game, new Ref(), game.getPlayer(false));
                group.setCoordinates(c);
                Integer delay = delayMap.get(c);
                // TODO    getBattleMaster().getConstructor().scheduleEncounter(group, delay);
                // spawnWave(group, true);
                // initGroup(group);
                power += group.getPower();
            }
        } else {
            // TODO POWER PER BLOCK!
            if (!autoSpawnOn) {
                continue;
            }
            // break;
            if (!checkSpawnBlock(block)) {
                continue;
            }
            // sort blocks! by spawn priority...
            // can be more than 1 group, right? maybe merge?
            group = getCreepGroupForBlock(preferredPower, dungeon.getDungeon(), block, min, max);
            group.setPreferredPower(preferredPower);
            // spawnWave(group, true);
            // initGroup(group);
            // power -= group.getPower();
            power += group.getPower();
        }
    }
    if (power > min) {
    // spawn wandering creeps - apart from groups? in max distance from
    // them?
    }
}
Also used : Wave(eidolons.game.battlecraft.logic.battle.arena.Wave) Ref(main.entity.Ref) ObjType(main.entity.type.ObjType) Coordinates(main.game.bf.Coordinates) MapBlock(eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)

Example 84 with ObjType

use of main.entity.type.ObjType in project Eidolons by IDemiurge.

the class DC_MapGenerator method getGatewayObjType.

public static ObjType getGatewayObjType(BF_OBJ_OWNER TYPE) {
    if (!initialized) {
        init();
    }
    ObjType type;
    type = gatewaysMap.get(TYPE);
    if (TYPE == BF_OBJ_OWNER.NEUTRAL) {
        type = DataManager.getType(GenericEnums.ASPECT.NEUTRAL.getGateway());
    }
    if (TYPE == BF_OBJ_OWNER.RANDOM) {
        type = DataManager.getType(GenericEnums.ASPECT.getAspectByCode(new Random().nextInt(GenericEnums.ASPECT.values().length)).getGateway());
    }
    return type;
}
Also used : Random(java.util.Random) ObjType(main.entity.type.ObjType)

Example 85 with ObjType

use of main.entity.type.ObjType in project Eidolons by IDemiurge.

the class DC_MapGenerator method getCrystalObjType.

public static ObjType getCrystalObjType(BF_OBJ_OWNER TYPE) {
    if (!initialized) {
        init();
    }
    ObjType type;
    type = crystalsMap.get(TYPE);
    if (TYPE == BF_OBJ_OWNER.NEUTRAL) {
        type = DataManager.getType(GenericEnums.ASPECT.NEUTRAL.getCrystalName());
    }
    if (TYPE == BF_OBJ_OWNER.RANDOM) {
        type = DataManager.getType(GenericEnums.ASPECT.getAspectByCode(new Random().nextInt(GenericEnums.ASPECT.values().length)).getCrystalName());
    }
    return type;
}
Also used : Random(java.util.Random) ObjType(main.entity.type.ObjType)

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