use of com.b3dgs.lionengine.game.feature.tile.TileRef in project lionengine by b3dgs.
the class CircuitsConfig method importTiles.
/**
* Import all tiles from their nodes.
*
* @param nodesTileRef The tiles nodes (must not be <code>null</code>).
* @return The imported tiles ref.
*/
private static Collection<TileRef> importTiles(Collection<Xml> nodesTileRef) {
final Collection<TileRef> tilesRef = new HashSet<>(nodesTileRef.size());
for (final Xml nodeTileRef : nodesTileRef) {
final TileRef tileRef = TileConfig.imports(nodeTileRef);
tilesRef.add(tileRef);
}
return tilesRef;
}
use of com.b3dgs.lionengine.game.feature.tile.TileRef in project lionengine by b3dgs.
the class MapTileGroupModel method changeGroup.
@Override
public void changeGroup(Tile tile, String group) {
final TileRef ref = new TileRef(tile);
final String oldGroup = getGroup(tile);
if (groupTiles.containsKey(oldGroup)) {
groupTiles.get(oldGroup).remove(ref);
}
if (group != null) {
tilesGroup.put(ref, group);
if (!groupTiles.containsKey(group)) {
groupTiles.put(group, new HashSet<TileRef>());
}
groupTiles.get(group).add(ref);
} else {
tilesGroup.remove(ref);
}
}
use of com.b3dgs.lionengine.game.feature.tile.TileRef in project lionengine by b3dgs.
the class Minimap method computeSheet.
/**
* Compute the current sheet.
*
* @param colors The colors data.
* @param sheet The sheet number.
*/
private void computeSheet(Map<TileRef, ColorRgba> colors, Integer sheet) {
final SpriteTiled tiles = map.getSheet(sheet);
final ImageBuffer tilesSurface = tiles.getSurface();
final int tw = map.getTileWidth();
final int th = map.getTileHeight();
int number = 0;
for (int i = 0; i < tilesSurface.getWidth(); i += tw) {
for (int j = 0; j < tilesSurface.getHeight(); j += th) {
final int h = number * tw % tiles.getWidth();
final int v = number / tiles.getTilesHorizontal() * th;
final ColorRgba color = UtilColor.getWeightedColor(tilesSurface, h, v, tw, th);
if (!(NO_TILE.equals(color) || color.getAlpha() == 0)) {
colors.put(new TileRef(sheet, number), color);
}
number++;
}
}
}
use of com.b3dgs.lionengine.game.feature.tile.TileRef in project lionengine by b3dgs.
the class MinimapConfig method exports.
/**
* Export tiles colors data to configuration media.
*
* @param configMinimap The configuration media output (must not be <code>null</code>).
* @param tiles The tiles data (must not be <code>null</code>).
* @throws LionEngineException If error on writing.
*/
public static void exports(Media configMinimap, Map<TileRef, ColorRgba> tiles) {
Check.notNull(configMinimap);
Check.notNull(tiles);
final Map<ColorRgba, Collection<TileRef>> colors = convertToColorKey(tiles);
final Xml nodeMinimap = new Xml(NODE_MINIMAP);
for (final Map.Entry<ColorRgba, Collection<TileRef>> entry : colors.entrySet()) {
final ColorRgba color = entry.getKey();
final Xml nodeColor = nodeMinimap.createChild(NODE_COLOR);
nodeColor.writeInteger(ATT_COLOR_RED, color.getRed());
nodeColor.writeInteger(ATT_COLOR_GREEN, color.getGreen());
nodeColor.writeInteger(ATT_COLOR_BLUE, color.getBlue());
for (final TileRef tileRef : entry.getValue()) {
final Xml nodeTileRef = TileConfig.exports(tileRef);
nodeColor.add(nodeTileRef);
}
}
nodeMinimap.save(configMinimap);
}
use of com.b3dgs.lionengine.game.feature.tile.TileRef in project lionengine by b3dgs.
the class TransitionsConfig method importTiles.
/**
* Import all tiles from their nodes.
*
* @param nodesTileRef The tiles nodes (must not be <code>null</code>).
* @return The imported tiles ref.
*/
private static Collection<TileRef> importTiles(Collection<Xml> nodesTileRef) {
final Collection<TileRef> tilesRef = new HashSet<>(nodesTileRef.size());
for (final Xml nodeTileRef : nodesTileRef) {
final TileRef tileRef = TileConfig.imports(nodeTileRef);
tilesRef.add(tileRef);
}
return tilesRef;
}
Aggregations