Search in sources :

Example 66 with Unit

use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.

the class LE_ObjMaster method addObj.

public Unit addObj(ObjType type, boolean stack, Coordinates... coordinates) {
    Unit obj = null;
    for (Coordinates c : coordinates) {
        List<Unit> list = LevelEditor.getSimulation().getObjectsOnCoordinate(c);
        if (!StackingRule.checkCanPlace(c, type, list)) {
            // replace cases? if 1 coordinate, prompt...
            if (LevelEditor.getCurrentLevel().isInitialized()) {
                SoundMaster.playStandardSound(STD_SOUNDS.DIS__BLOCKED);
            // DialogMaster.inform(type +
            // " cannot be placed onto wall - " + c);
            }
            continue;
        }
        obj = getObject(type, c);
        List<Unit> objects = LevelEditor.getSimulation().getUnitMap().get(c);
        if (objects == null) {
            objects = new ArrayList<>();
            LevelEditor.getSimulation().getUnitMap().put(c, objects);
        }
        objects.add(obj);
        LevelEditor.getCurrentLevel().addObj(obj, c, stack);
        if (obj.isOverlaying()) {
            LE_ObjMaster.setDirection(obj, c);
        }
        try {
            if (LE_MapViewComp.isMinimapMode()) {
                LevelEditor.getMainPanel().getMiniGrid().refreshComp(null, c);
            } else {
                SwingUtilities.invokeLater(new Runnable() {

                    @Override
                    public void run() {
                        LevelEditor.getGrid().refresh();
                    }
                });
            }
        // LevelEditor.getGrid().repaintComp(c);
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        }
    }
    // preCheck wall ?
    return obj;
}
Also used : Coordinates(main.game.bf.Coordinates) Unit(eidolons.entity.obj.unit.Unit)

Example 67 with Unit

use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.

the class LE_ObjMaster method getObject.

public static Unit getObject(ObjType type, Coordinates c) {
    Unit obj = null;
    if (type.checkProperty(G_PROPS.BF_OBJECT_GROUP, BfObjEnums.BF_OBJECT_GROUP.ENTRANCE.toString())) {
    // obj = new Entrance(c.x, c.y, type, LevelEditor.getCurrentLevel().getDungeon(), null);
    } else {
        obj = getObjCache().get(type);
        if (obj == null) {
            obj = new Unit(type, c.x, c.y, DC_Player.NEUTRAL, LevelEditor.getSimulation(), new Ref());
        }
    }
    getObjCache().put(type, obj);
    return obj;
}
Also used : Ref(main.entity.Ref) Unit(eidolons.entity.obj.unit.Unit)

Example 68 with Unit

use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.

the class LE_ObjMaster method replace.

public static void replace(ObjType type, ObjType type2, List<Coordinates> coordinates) {
    cache();
    for (Coordinates coordinate : coordinates) {
        List<Unit> objects = LevelEditor.getSimulation().getUnitMap().get(coordinate);
        // .getObjects();
        if (objects != null) {
            for (Unit obj : new ArrayList<>(objects)) {
                if (obj.getType().equals(type)) {
                    objects.remove(obj);
                    objects.add(getObject(type2, coordinate));
                }
            }
        }
    }
    LevelEditor.getMainPanel().getMapViewComp().getGrid().refresh();
}
Also used : Coordinates(main.game.bf.Coordinates) Unit(eidolons.entity.obj.unit.Unit)

Example 69 with Unit

use of eidolons.entity.obj.unit.Unit 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 70 with Unit

use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.

the class Spawner method spawnUnitGroup.

protected List<Unit> spawnUnitGroup(boolean me, String filePath) {
    String data = UnitGroupMaster.readGroupFile(filePath);
    boolean mirror = me;
    if (UnitGroupMaster.isFactionMode()) {
        if (UnitGroupMaster.factionLeaderRequired) {
            data += UnitGroupMaster.getHeroData(me);
        }
        mirror = !mirror;
    }
    UnitGroupMaster.setMirror(mirror);
    int width = UnitGroupMaster.maxX;
    int height = UnitGroupMaster.maxY;
    Coordinates offset_coordinate;
    Coordinates spawnCoordinates;
    int offsetX = -width / 2;
    int offsetY = -height / 2;
    if (!UnitGroupMaster.isFactionMode()) {
        UnitGroupMaster.setCurrentGroupHeight(MathMaster.getMaxY(data));
        UnitGroupMaster.setCurrentGroupWidth(MathMaster.getMaxX(data));
        width = 1 + UnitGroupMaster.getCurrentGroupWidth();
        height = 2 * UnitGroupMaster.getCurrentGroupHeight();
        offsetX = -width / 2;
        offsetY = -height / 2;
    } else {
        if (UnitGroupMaster.isMirror()) {
            offsetY -= 1;
        }
    }
    spawnCoordinates = (me) ? getPositioner().getPlayerSpawnCoordinates() : getPositioner().getEnemySpawningCoordinates();
    offset_coordinate = spawnCoordinates.getOffsetByX(offsetX).getOffsetByY(offsetY);
    List<MicroObj> units = DC_ObjInitializer.createUnits(game.getPlayer(me), data, offset_coordinate);
    LogMaster.logToFile("spawnCoordinates=" + spawnCoordinates + " ;offset_coordinate=" + offset_coordinate + ";height=" + height + "; width=" + width);
    LogMaster.log(1, "spawnCoordinates=" + spawnCoordinates + " ;offset_coordinate=" + offset_coordinate + ";height=" + height + "; width=" + width);
    List<Unit> list = new ArrayList<>();
    units.stream().forEach(unit -> list.add((Unit) unit));
    return list;
}
Also used : MicroObj(main.entity.obj.MicroObj) Coordinates(main.game.bf.Coordinates) ArrayList(java.util.ArrayList) Unit(eidolons.entity.obj.unit.Unit)

Aggregations

Unit (eidolons.entity.obj.unit.Unit)258 Coordinates (main.game.bf.Coordinates)53 Ref (main.entity.Ref)33 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)30 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)26 DC_Obj (eidolons.entity.obj.DC_Obj)26 ArrayList (java.util.ArrayList)26 Obj (main.entity.obj.Obj)26 ObjType (main.entity.type.ObjType)23 DC_SpellObj (eidolons.entity.active.DC_SpellObj)13 DC_Cell (eidolons.entity.obj.DC_Cell)11 Event (main.game.logic.event.Event)11 DC_UnitAction (eidolons.entity.active.DC_UnitAction)10 List (java.util.List)10 DC_Game (eidolons.game.core.game.DC_Game)9 Action (eidolons.game.battlecraft.ai.elements.actions.Action)8 DequeImpl (main.system.datatypes.DequeImpl)8 OUTLINE_TYPE (main.content.enums.rules.VisionEnums.OUTLINE_TYPE)7 Entity (main.entity.Entity)7 DIRECTION (main.game.bf.Coordinates.DIRECTION)7