Search in sources :

Example 1 with DungeonRoomTiledMapLoader

use of util.DungeonRoomTiledMapLoader in project ultimate-java by pantinor.

the class DungeonScreen method enterRoom.

public void enterRoom(RoomLocater loc, Direction entryDir) {
    if (loc == null) {
        return;
    }
    Maps contextMap = Maps.get(dngMap.getId());
    TiledMap tiledMap = new DungeonRoomTiledMapLoader(loc.room, entryDir, Ultima4.standardAtlas).load();
    BaseMap baseMap = new BaseMap();
    baseMap.setTiles(loc.room.tiles);
    baseMap.setWidth(11);
    baseMap.setHeight(11);
    baseMap.setType(MapType.dungeon);
    baseMap.setPortals(dngMap.getMap().getPortals(loc.x, loc.y, loc.z));
    CombatScreen sc = new CombatScreen(this, context, contextMap, baseMap, tiledMap, null, Ultima4.creatures, Ultima4.standardAtlas);
    if (loc.room.hasAltar) {
        sc.log("The Altar Room of " + loc.room.altarRoomVirtue.toString());
    }
    MapLayer mLayer = tiledMap.getLayers().get("Monster Positions");
    Iterator<MapObject> iter = mLayer.getObjects().iterator();
    while (iter.hasNext()) {
        MapObject obj = iter.next();
        int tile = (Integer) obj.getProperties().get("tile");
        int startX = (Integer) obj.getProperties().get("startX");
        int startY = (Integer) obj.getProperties().get("startY");
        if (tile == 0) {
            continue;
        }
        Tile t = Ultima4.baseTileSet.getTileByIndex(tile);
        Creature c = Ultima4.creatures.getInstance(CreatureType.get(t.getName()), Ultima4.standardAtlas);
        c.currentX = startX;
        c.currentY = startY;
        c.currentPos = sc.getMapPixelCoords(startX, startY);
        baseMap.addCreature(c);
    }
    mainGame.setScreen(sc);
}
Also used : DungeonRoomTiledMapLoader(util.DungeonRoomTiledMapLoader) Creature(objects.Creature) MapLayer(com.badlogic.gdx.maps.MapLayer) Tile(objects.Tile) TiledMap(com.badlogic.gdx.maps.tiled.TiledMap) MapObject(com.badlogic.gdx.maps.MapObject) BaseMap(objects.BaseMap)

Aggregations

MapLayer (com.badlogic.gdx.maps.MapLayer)1 MapObject (com.badlogic.gdx.maps.MapObject)1 TiledMap (com.badlogic.gdx.maps.tiled.TiledMap)1 BaseMap (objects.BaseMap)1 Creature (objects.Creature)1 Tile (objects.Tile)1 DungeonRoomTiledMapLoader (util.DungeonRoomTiledMapLoader)1