Search in sources :

Example 1 with ZCoordinates

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

the class MapBlock method addObject.

public void addObject(Unit obj, Coordinates c) {
    if (map.containsKey(c)) {
        ZCoordinates coordinates = new ZCoordinates(c.x, c.y, new Random().nextInt());
        map.put(coordinates, obj);
    } else {
        getMap().put(c, obj);
    }
    getObjects().add(obj);
}
Also used : ZCoordinates(main.game.bf.ZCoordinates) Random(java.util.Random)

Example 2 with ZCoordinates

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

the class MapBlock method resetObjects.

public void resetObjects() {
    setObjects(getObjectsByCoordinates());
    map.clear();
    for (Coordinates c : getCoordinates()) {
        for (Unit obj : DC_Game.game.getObjectsOnCoordinate(c)) {
            if (map.containsKey(c)) {
                ZCoordinates coordinates = new ZCoordinates(c.x, c.y, new Random().nextInt());
                map.put(coordinates, obj);
            } else {
                map.put(c, obj);
            }
        }
    // for (Unit obj : DC_Game.game.getOverlayingObjects(c)) {
    // if (map.containsKey(c)) {
    // ZCoordinates coordinates = new ZCoordinates(c.x, c.y, new Random().nextInt());
    // map.put(coordinates, obj);
    // } else {
    // map.put(c, obj);
    // }
    // }
    }
}
Also used : ZCoordinates(main.game.bf.ZCoordinates) Random(java.util.Random) ZCoordinates(main.game.bf.ZCoordinates) Coordinates(main.game.bf.Coordinates) Unit(eidolons.entity.obj.unit.Unit)

Example 3 with ZCoordinates

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

the class DC_ObjInitializer method processUnitDataStringToMap.

public static Map<Coordinates, MicroObj> processUnitDataStringToMap(Player owner, String objData, DC_Game game, boolean alt) {
    if (objData == null || objData.equals("")) {
        return null;
    }
    String[] items = objData.split(getObjSeparator(alt));
    Map<Coordinates, MicroObj> map = new HashMap<>();
    int i = 0;
    boolean first = true;
    boolean creeps = false;
    List<Coordinates> excludedCoordinates = new ArrayList<>();
    Boolean last = null;
    for (int indx = 0; indx < items.length; indx++) {
        String item = items[indx];
        boolean excludeCoordinate = false;
        if (mapBlockMode) {
            if (item.contains("%")) {
                Integer chance = StringMaster.getInteger(VariableManager.getVarPart(item).replace("%", " "));
                if (chance < 0) {
                    chance = -chance;
                    excludeCoordinate = true;
                }
                if (RandomWizard.chance(chance)) {
                    continue;
                }
            }
        }
        Coordinates c = null;
        if (item.contains("(") || item.contains("-")) {
            if (!item.contains("null=")) {
                c = getCoordinatesFromObjString(item, alt);
            }
        }
        String typeName = getNameFromObjString(item, alt);
        i++;
        if (i == items.length) {
            last = true;
        }
        int level = 0;
        if (typeName.contains(UnitGroupMaster.TYPE_LEVEL_SEPARATOR)) {
            level = StringMaster.getInteger(StringMaster.getLastPart(typeName, UnitGroupMaster.TYPE_LEVEL_SEPARATOR));
        }
        ObjType type = DataManager.getType(typeName, C_OBJ_TYPE.BF_OBJ);
        if (type == null) {
            type = DataManager.getType(typeName, C_OBJ_TYPE.ITEMS);
            if (type != null)
                createItem(type, c);
            continue;
        }
        if (type.getOBJ_TYPE_ENUM() == DC_TYPE.BF_OBJ)
            owner = DC_Player.NEUTRAL;
        else if (level == 0) {
            if (!owner.isMe())
                if (owner.isAi()) {
                    level = game.getDungeonMaster().getSpawner().getMinLevel(typeName);
                }
        }
        if (type == null) {
            type = DataManager.getType(typeName, DC_TYPE.ENCOUNTERS);
        }
        if (type == null) {
            main.system.auxiliary.log.LogMaster.log(1, "ERROR: Type not found - " + typeName);
            continue;
        }
        if (level != 0) {
            type = new UnitLevelManager().getLeveledType(type, level);
        }
        // UnitGroupMaster.getCurrentGroupHeight();
        int height = UnitGroupMaster.getGroupSizeY(owner);
        int width = UnitGroupMaster.getGroupSizeX(owner);
        if (UnitGroupMaster.getFlip() == FLIP.CW90) {
            int buffer = c.x;
            c.setX(c.y);
            c.setY(buffer);
        } else if (UnitGroupMaster.getFlip() == FLIP.CCW90) {
            int buffer = width - c.x;
            c.setX(height - c.y);
            c.setY(buffer);
        }
        if (UnitGroupMaster.isMirror()) {
            if (UnitGroupMaster.getFlip() == FLIP.CW90 || UnitGroupMaster.getFlip() == FLIP.CCW90) {
                c.setX(width - c.x);
            } else {
                c.setY(height - c.y);
            }
        // TODO c.setX(width - c.x);
        }
        if (offset != null) {
            c.setX(c.x + offset.x);
            c.setY(c.y + offset.y);
            if (!DC_Game.game.getRules().getStackingRule().canBeMovedOnto(type, c)) {
                // TODO tactics?
                // direction
                c = Positioner.adjustCoordinate(type, c, FacingMaster.getRandomFacing());
            // preference?
            }
        }
        if (mapBlockMode) {
            if (excludedCoordinates.contains(c)) {
                continue;
            }
            if (type.getOBJ_TYPE_ENUM() == DC_TYPE.ENCOUNTERS) {
                if (!game.isSimulation()) {
                    game.getBattleMaster().getSpawner().addDungeonEncounter(c_dungeon, block, c, type);
                }
                continue;
            }
            if (!CoreEngine.isLevelEditor() && C_OBJ_TYPE.UNITS_CHARS.equals(type.getOBJ_TYPE_ENUM())) {
                owner = game.getPlayer(false);
            } else {
                owner = DC_Player.NEUTRAL;
            }
            if (C_OBJ_TYPE.ITEMS.equals(type.getOBJ_TYPE_ENUM())) {
            // TODO 'treasure'?
            }
        }
        if (excludeCoordinate) {
            excludedCoordinates.add(c);
        }
        if (type == null) {
            continue;
        }
        if (data != null) {
        // data.addType(type, owner.isMe());
        }
        if (game.isDebugMode()) {
            if (owner.isMe()) {
                try {
                    TestMasterContent.addTestItems(type, last);
                } catch (Exception e) {
                    main.system.ExceptionMaster.printStackTrace(e);
                }
            }
        }
        last = false;
        // todo optimize create unit func it too slow
        BattleFieldObject unit = (BattleFieldObject) game.createUnit(type, c, owner);
        if (unit == null) {
            continue;
        }
        if (FAST_DC.isRunning()) {
            if (!owner.isMe()) {
                creeps = true;
            } else {
                try {
                    Unit hero = (Unit) unit;
                    if (first) {
                        PartyHelper.newParty(hero);
                    } else {
                        PartyHelper.addMember(hero);
                    }
                } catch (Exception e) {
                    main.system.ExceptionMaster.printStackTrace(e);
                }
            }
        }
        first = false;
        if (map.containsKey(c)) {
            ZCoordinates coordinates = new ZCoordinates(c.x, c.y, new Random().nextInt());
            map.put(coordinates, unit);
        } else {
            map.put(c, unit);
        }
        if (!CoreEngine.isLevelEditor()) {
            if (unit.getOBJ_TYPE_ENUM() == DC_TYPE.UNITS) {
                // if (!owner.isMe() || game.isDebugMode()) TODO why
                // not?
                // todo optimize train func it too slow
                UnitTrainingMaster.train((Unit) unit);
            }
        }
    }
    // PartyManager.addCreepParty(DataManager.convertToTypeList(list));
    return map;
}
Also used : MicroObj(main.entity.obj.MicroObj) ZCoordinates(main.game.bf.ZCoordinates) Coordinates(main.game.bf.Coordinates) Unit(eidolons.entity.obj.unit.Unit) ZCoordinates(main.game.bf.ZCoordinates) UnitLevelManager(eidolons.client.cc.logic.UnitLevelManager) ObjType(main.entity.type.ObjType) BattleFieldObject(eidolons.entity.obj.BattleFieldObject)

Example 4 with ZCoordinates

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

the class TrapMaster method getTrapsToDisarm.

public static List<Trap> getTrapsToDisarm(Unit unit) {
    List<Trap> list = new ArrayList<>();
    Set<Trap> set = trapMap.get(new ZCoordinates(unit.getCoordinates().x, unit.getCoordinates().y, unit.getZ()));
    if (set == null) {
        return list;
    }
    for (Trap trap : set) {
        // if (t) //visible, disarmable
        list.add(trap);
    }
    return list;
}
Also used : ZCoordinates(main.game.bf.ZCoordinates)

Aggregations

ZCoordinates (main.game.bf.ZCoordinates)4 Unit (eidolons.entity.obj.unit.Unit)2 Random (java.util.Random)2 Coordinates (main.game.bf.Coordinates)2 UnitLevelManager (eidolons.client.cc.logic.UnitLevelManager)1 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)1 MicroObj (main.entity.obj.MicroObj)1 ObjType (main.entity.type.ObjType)1