Search in sources :

Example 51 with Coordinates

use of main.game.bf.Coordinates in project Eidolons by IDemiurge.

the class LocationBuilder method getRandomCoordinate.

private Coordinates getRandomCoordinate(ROOM_TYPE roomType) {
    // TODO totally random? a fair start...
    boolean corner = false;
    boolean center = false;
    ROOM_TYPE[] adjacentRoomRequired = null;
    switch(roomType) {
        case DEATH_ROOM:
        case GUARD_ROOM:
            adjacentRoomRequired = new ROOM_TYPE[] { ROOM_TYPE.TREASURE_ROOM, ROOM_TYPE.THRONE_ROOM, ROOM_TYPE.EXIT_ROOM };
            break;
        case SECRET_ROOM:
        case TREASURE_ROOM:
            corner = true;
            break;
    }
    Coordinates c = null;
    if (adjacentRoomRequired != null) {
        Loop.startLoop(500);
        while (!Loop.loopEnded()) {
            MapBlock block = new RandomWizard<MapBlock>().getRandomListItem(plan.getBlocks());
            if (Arrays.asList(adjacentRoomRequired).contains(block.getRoomType())) {
                List<Coordinates> list = CoordinatesMaster.getAdjacentToSquare(block.getCoordinates());
                c = new RandomWizard<Coordinates>().getRandomListItem(list);
                if (c.isInvalid()) {
                    continue;
                }
                if (helper.getUsedCoordinates().contains(c)) {
                    continue;
                }
                return c;
            }
        }
        return null;
    }
    Loop.startLoop(100);
    while (!Loop.loopEnded()) {
        c = CoordinatesMaster.getRandomCoordinate(getDungeon().getCellsX(), getDungeon().getCellsY());
        if (helper.getUsedCoordinates().contains(c)) {
            continue;
        }
        // add the outer walls to usedCoordinates?
        if (corner) {
            if (Math.min(plan.getBorderX() - c.x, c.x) + Math.min(plan.getBorderY() - c.y, c.y) > 6) {
                continue;
            }
        }
        break;
    }
    return c;
}
Also used : RandomWizard(main.system.auxiliary.RandomWizard) Coordinates(main.game.bf.Coordinates) MapBlock(eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)

Example 52 with Coordinates

use of main.game.bf.Coordinates in project Eidolons by IDemiurge.

the class LocationSpawner method spawn.

@Override
public List<Unit> spawn(UnitData data, DC_Player player, SPAWN_MODE mode) {
    if (data.getValue(PARTY_VALUE.MEMBERS) != null) {
        String units = data.getValue(PARTY_VALUE.MEMBERS).replace(DataUnitFactory.getContainerSeparator(UnitData.FORMAT), "");
        if (FileManager.isFile(units))
            return spawnUnitGroup(player.isMe(), units);
    }
    if (player.isMe() && PresetMaster.getPreset() == null && getGame().getMetaMaster() != null) {
        Party party = getGame().getMetaMaster().getPartyManager().getParty();
        if (party == null) {
            return new LinkedList<>();
        }
        List<String> list = ListMaster.toNameList(party.getMembers());
        getPositioner().setMaxSpacePercentageTaken(50);
        List<Coordinates> coords = getPositioner().getPlayerPartyCoordinates(list);
        Iterator<Coordinates> iterator = coords.iterator();
        for (Unit member : party.getMembers()) {
            if (!iterator.hasNext()) {
                main.system.auxiliary.log.LogMaster.log(1, "Spawn failed: Coordinates: " + coords + "; Units" + list);
                break;
            }
            member.setCoordinates(iterator.next());
            member.setConstructed(false);
            getGame().getState().addObject(member);
            member.setOriginalOwner(player);
            member.setOwner(player);
            member.setFacing(getFacingAdjuster().getPartyMemberFacing(member));
            applyStartBonuses(member);
        // what else should be done to *spawn*?
        }
    } else {
        super.spawn(data, player, mode);
    }
    return null;
}
Also used : Party(eidolons.client.cc.logic.party.Party) Coordinates(main.game.bf.Coordinates) Unit(eidolons.entity.obj.unit.Unit)

Example 53 with Coordinates

use of main.game.bf.Coordinates 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 54 with Coordinates

use of main.game.bf.Coordinates in project Eidolons by IDemiurge.

the class BuildHelper method checkLinkOrReject.

private Boolean checkLinkOrReject(MapBlock baseBlock, Coordinates c, boolean culdesac) {
    Coordinates adjacent = getAdjacentPassage(c, baseBlock.getCoordinates(), false);
    if (adjacent != null) {
        if (culdesac) {
            return false;
        }
        // WILL BE IN LINK_COORDINATE
        usedCoordinates.add(adjacent);
        c = adjacent;
    }
    if (baseBlock.getType() == BLOCK_TYPE.CULDESAC) {
        // or false?
        return null;
    }
    MapBlock block = plan.getBlockByCoordinate(c);
    if (block == null) {
        return null;
    }
    if (block == baseBlock || culdesac) {
        return false;
    }
    int links = block.getConnectedBlocks().size();
    if (links > 2) {
        return false;
    }
    // if (baseBlock.getRoomType()==) TODO
    if (block.getType() == BLOCK_TYPE.CULDESAC) {
        return false;
    }
    if (block.getConnectedBlocks().containsKey(baseBlock)) {
        return false;
    }
    baseBlock.link(block, c);
    block.link(baseBlock, c);
    return true;
}
Also used : Coordinates(main.game.bf.Coordinates)

Example 55 with Coordinates

use of main.game.bf.Coordinates in project Eidolons by IDemiurge.

the class DC_Map method initMapCrystals.

private void initMapCrystals(String enemycrystals, String factioncrystals, String neutralcrystals, String randomcrystals, int randomCrystals) {
    BF_OBJ_OWNER TYPE;
    for (Coordinates c : Coordinates.getCoordinates(factioncrystals)) {
        TYPE = BF_OBJ_OWNER.MY;
        LogMaster.log(LogMaster.MAP_GENERATION_DEBUG, TYPE + " crystal at " + c);
        crystals.put(c, BF_OBJ_OWNER.MY);
    }
    for (Coordinates c : Coordinates.getCoordinates(enemycrystals)) {
        TYPE = BF_OBJ_OWNER.ENEMY;
        LogMaster.log(LogMaster.MAP_GENERATION_DEBUG, TYPE + " crystal at " + c);
        crystals.put(c, BF_OBJ_OWNER.ENEMY);
    }
    for (Coordinates c : Coordinates.getCoordinates(neutralcrystals)) {
        TYPE = BF_OBJ_OWNER.NEUTRAL;
        LogMaster.log(LogMaster.MAP_GENERATION_DEBUG, TYPE + " crystal at " + c);
        crystals.put(c, BF_OBJ_OWNER.NEUTRAL);
    }
    for (Coordinates c : Coordinates.getCoordinates(randomcrystals)) {
        TYPE = BF_OBJ_OWNER.RANDOM;
        LogMaster.log(LogMaster.MAP_GENERATION_DEBUG, TYPE + " crystal at " + c);
        crystals.put(c, BF_OBJ_OWNER.RANDOM);
    }
    for (int i = randomCrystals; i > 0; i--) {
        Coordinates c = new Coordinates(100 + i, 0);
        crystals.put(c, BF_OBJ_OWNER.RANDOM);
    }
}
Also used : Coordinates(main.game.bf.Coordinates)

Aggregations

Coordinates (main.game.bf.Coordinates)226 Unit (eidolons.entity.obj.unit.Unit)49 ObjType (main.entity.type.ObjType)30 ArrayList (java.util.ArrayList)29 Obj (main.entity.obj.Obj)28 DC_Obj (eidolons.entity.obj.DC_Obj)22 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)21 FACING_DIRECTION (main.game.bf.Coordinates.FACING_DIRECTION)21 DIRECTION (main.game.bf.Coordinates.DIRECTION)20 Ref (main.entity.Ref)15 MapBlock (eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)13 DC_Cell (eidolons.entity.obj.DC_Cell)12 Action (eidolons.game.battlecraft.ai.elements.actions.Action)11 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)9 BufferedImage (java.awt.image.BufferedImage)8 DequeImpl (main.system.datatypes.DequeImpl)8 Vector2 (com.badlogic.gdx.math.Vector2)7 DC_UnitAction (eidolons.entity.active.DC_UnitAction)7 ZCoordinates (main.game.bf.ZCoordinates)6 ObjAtCoordinate (main.entity.type.ObjAtCoordinate)5