Search in sources :

Example 61 with Coordinates

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

the class ArenaPositioner method getAdjacentCoordinateInRow.

private Coordinates getAdjacentCoordinateInRow(Coordinates c) {
    boolean clockwise = RandomWizard.random();
    Coordinates adjacentCoordinate = c.getAdjacentCoordinate(DirectionMaster.rotate90(side.getDirection(), clockwise));
    if (checkCanPlaceUnitOnCoordinate(adjacentCoordinate, null)) {
        return adjacentCoordinate;
    }
    adjacentCoordinate = c.getAdjacentCoordinate(DirectionMaster.rotate90(side.getDirection(), !clockwise));
    if (checkCanPlaceUnitOnCoordinate(adjacentCoordinate, null)) {
        return adjacentCoordinate;
    }
    return null;
}
Also used : Coordinates(main.game.bf.Coordinates)

Example 62 with Coordinates

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

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

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

the class ArenaPositioner method getPartyCoordinates.

@Unimplemented
public List<Coordinates> getPartyCoordinates(Coordinates origin, Boolean me, List<String> partyTypes) {
    List<Coordinates> list = new ArrayList<>();
    // TODO
    if (CoreEngine.isArcaneVault() || CoreEngine.isLevelEditor()) {
        origin = new Coordinates(PositionMaster.getMiddleIndex(false), PositionMaster.getMiddleIndex(true));
    } else {
        FACING_DIRECTION side = ArenaPositioner.DEFAULT_PLAYER_SIDE;
        // if ( getSpawningSide() != null) {
        // side =   getSpawningSide();
        // }
        unitGroups.put(side, new LinkedHashMap<>());
    }
    return list;
}
Also used : FACING_DIRECTION(main.game.bf.Coordinates.FACING_DIRECTION) Coordinates(main.game.bf.Coordinates) Unimplemented(main.system.util.Unimplemented)

Example 65 with Coordinates

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

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