当前位置: 首页>>代码示例>>Java>>正文


Java MapProperties类代码示例

本文整理汇总了Java中com.badlogic.gdx.maps.MapProperties的典型用法代码示例。如果您正苦于以下问题:Java MapProperties类的具体用法?Java MapProperties怎么用?Java MapProperties使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MapProperties类属于com.badlogic.gdx.maps包,在下文中一共展示了MapProperties类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initialize

import com.badlogic.gdx.maps.MapProperties; //导入依赖的package包/类
@Override
protected void initialize() {
    super.initialize();
    cableMask = mapSystem.getMask("cable-type");

    for (TiledMapTileSet tileSet : mapSystem.map.getTileSets()) {
        for (TiledMapTile tile : tileSet) {
            MapProperties properties = tile.getProperties();
            if (properties.containsKey("cable-type")) {
                if ((Boolean) properties.get("cable-state")) {
                    tilesOn.put((Integer) properties.get("cable-type"), tile);
                } else {
                    tilesOff.put((Integer) properties.get("cable-type"), tile);
                }
            }
        }
    }
}
 
开发者ID:DaanVanYperen,项目名称:odb-artax,代码行数:19,代码来源:PowerSystem.java

示例2: powerMapCoords

import com.badlogic.gdx.maps.MapProperties; //导入依赖的package包/类
public void powerMapCoords(int x, int y, boolean enable) {
    if (cableMask.atGrid(x, y, false)) {
        TiledMapTileLayer cableLayer = (TiledMapTileLayer) mapSystem.map.getLayers().get("cables");
        final TiledMapTileLayer.Cell cell = cableLayer.getCell(x, y);
        if (cell != null) {
            MapProperties properties = cell.getTile().getProperties();
            if (properties.containsKey("cable-state")) {
                if ((Boolean) properties.get("cable-state") != enable) {
                    cell.setTile(enable ?
                            tilesOn.get((Integer) properties.get("cable-type")) :
                            tilesOff.get((Integer) properties.get("cable-type")));
                    powerMapCoordsAround(x, y, enable);
                }
            }
        }
    }
}
 
开发者ID:DaanVanYperen,项目名称:odb-artax,代码行数:18,代码来源:PowerSystem.java

示例3: setup

import com.badlogic.gdx.maps.MapProperties; //导入依赖的package包/类
/**
 * Spawn map entities.
 */
protected void setup() {
    for (TiledMapTileLayer layer : layers) {
        for (int ty = 0; ty < height; ty++) {
            for (int tx = 0; tx < width; tx++) {
                final TiledMapTileLayer.Cell cell = layer.getCell(tx, ty);
                if (cell != null) {
                    final MapProperties properties = cell.getTile().getProperties();
                    if (properties.containsKey("entity")) {
                        if (entitySpawnerSystem.spawnEntity(tx * G.CELL_SIZE, ty * G.CELL_SIZE, properties)) {
                            layer.setCell(tx, ty, null);
                        }
                    }
                    if (properties.containsKey("invisible")) {
                        layer.setCell(tx, ty, null);
                    }
                }
            }
        }
    }
}
 
开发者ID:DaanVanYperen,项目名称:odb-artax,代码行数:24,代码来源:MapSystem.java

示例4: init

import com.badlogic.gdx.maps.MapProperties; //导入依赖的package包/类
public void init(MapProperties properties) {
	setOrigin(Align.center);
	this.properties = properties;
	bounds = new Rectangle(0, 0, getWidth(), getHeight());
	ret_bounds = new Rectangle(bounds);
	if (getChildren().size > 0)
		for (int i = 0; i < getChildren().size; i++) {
			GameObject child = (GameObject) getChildren().get(i);
			child.setGameLayer(layer);
			init(properties);
		}
	for (int i = 0; i < controllers.size; i++) {
		controllers.get(i).init(this);
	}

}
 
开发者ID:kyperbelt,项目名称:KyperBox,代码行数:17,代码来源:GameObject.java

示例5: loadFonts

import com.badlogic.gdx.maps.MapProperties; //导入依赖的package包/类
private void loadFonts(TiledMap data, String atlasname) {
	MapObjects objects = data.getLayers().get("preload").getObjects();
	String ffcheck = "Font";
	for (MapObject o : objects) {
		String name = o.getName();
		BitmapFont font = null;
		MapProperties properties = o.getProperties();
		String type = properties.get("type", String.class);
		String fontfile = properties.get("font_file", String.class);
		if (fontfile != null && type != null && type.equals(ffcheck)) {
			boolean markup = properties.get("markup", false, boolean.class);
			game.loadFont(fontfile, atlasname);
			game.getAssetManager().finishLoading();
			font = game.getFont(fontfile);
			fonts.put(name, font);
			font.getData().markupEnabled = markup;
		}
	}
}
 
开发者ID:kyperbelt,项目名称:KyperBox,代码行数:20,代码来源:GameState.java

示例6: loadParticleEffects

import com.badlogic.gdx.maps.MapProperties; //导入依赖的package包/类
private void loadParticleEffects(TiledMap data, String atlasname) {
	MapObjects objects = data.getLayers().get("preload").getObjects();
	String ppcheck = "Particle";
	for (MapObject o : objects) {
		String name = o.getName();
		MapProperties properties = o.getProperties();
		String type = properties.get("type", String.class);
		if (type != null && type.equals(ppcheck)) {
			String file = properties.get("particle_file", String.class);
			if (file != null) {
				game.loadParticleEffect(file, atlasname);
				game.getAssetManager().finishLoading();
				if (!particle_effects.containsKey(name)) {
					ParticleEffect pe = game.getParticleEffect(file);
					pe.setEmittersCleanUpBlendFunction(false);
					pvalues.add(KyperBoxGame.PARTICLE_FOLDER + KyperBoxGame.FILE_SEPARATOR + file);
					particle_effects.put(name, new ParticleEffectPool(pe, 12, 48));
				}
			}
		}
	}
}
 
开发者ID:kyperbelt,项目名称:KyperBox,代码行数:23,代码来源:GameState.java

示例7: loadShaders

import com.badlogic.gdx.maps.MapProperties; //导入依赖的package包/类
private void loadShaders(TiledMap data) {
	MapObjects objects = data.getLayers().get("preload").getObjects();
	String scheck = "Shader";
	for (MapObject o : objects) {
		String name = o.getName();
		MapProperties properties = o.getProperties();
		String type = properties.get("type", String.class);
		if (type != null && type.equals(scheck)) {
			String file = properties.get("shader_name", String.class);
			if (file != null) {
				game.loadShader(file);
				game.getAssetManager().finishLoading();
				if (!shaders.containsKey(name)) {
					ShaderProgram sp = game.getShader(file);
					shaders.put(name, sp);
					svalues.add(KyperBoxGame.SHADER_FOLDER + KyperBoxGame.FILE_SEPARATOR + file);
				}
			}
		}
	}
}
 
开发者ID:kyperbelt,项目名称:KyperBox,代码行数:22,代码来源:GameState.java

示例8: addEnemy

import com.badlogic.gdx.maps.MapProperties; //导入依赖的package包/类
/**
 * Reads the enemy type and spawn position out of an enemy object on the map and then spawns it in the current level
 * @param object the map object that has been read in the map file
 * @param rectangle the rectangular shape of the object, contains position used for selecting the spawn position
 */
private void addEnemy(MapObject object, Rectangle rectangle) {

    MapProperties properties = object.getProperties();

    if (properties != null && properties.containsKey("enemy_type")) {
        String enemyType = properties.get("enemy_type", String.class);

        switch (enemyType) {
            case "Frog":
                playScreen.spawnEnemy(FrogEnemy.class, (int) (rectangle.getX() / MainGameClass.TILE_PIXEL_SIZE), (int) (rectangle.getY() / MainGameClass.TILE_PIXEL_SIZE));
                break;
            case "Monkey":
                playScreen.spawnEnemy(MonkeyEnemy.class, (int) (rectangle.getX() / MainGameClass.TILE_PIXEL_SIZE), (int) (rectangle.getY() / MainGameClass.TILE_PIXEL_SIZE));
                break;
            case "Boss":
                playScreen.spawnEnemy(BossEnemy.class, (int) (rectangle.getX() / MainGameClass.TILE_PIXEL_SIZE), (int) (rectangle.getY() / MainGameClass.TILE_PIXEL_SIZE));
                break;
            default:
                break;
        }
    }
}
 
开发者ID:johannesmols,项目名称:GangsterSquirrel,代码行数:28,代码来源:Box2DWorldCreator.java

示例9: update

import com.badlogic.gdx.maps.MapProperties; //导入依赖的package包/类
@Override
public void update(final long elapsedTime) {
    timeInAnimation = (timeInAnimation + elapsedTime) % getTotalAnimationTimeMs();
    final int frameIndex = (int) (timeInAnimation / timePerFrameMs);
    TiledMapTile currentTile = tileFrames.get(indexOrder[frameIndex]);
    for (MapLayer layer : tiledMap.getLayers()) {
        TiledMapTileLayer tiledMapLayer = (TiledMapTileLayer) layer;
        for (int x = 0; x < tiledMapLayer.getWidth(); x++) {
            for (int y = 0; y < tiledMapLayer.getHeight(); y++) {
                final TiledMapTileLayer.Cell cell = tiledMapLayer.getCell(x, y);
                if (cell != null) {
                    TiledMapTile tile = cell.getTile();
                    final MapProperties tileProperties = tile.getProperties();
                    if (tileProperties.containsKey(JRPG_TILE_ANIMATION_ID)
                            && tileProperties.get(JRPG_TILE_ANIMATION_ID).equals(id)) {
                        cell.setTile(currentTile);
                    }
                }
            }
        }
    }
}
 
开发者ID:JayStGelais,项目名称:jrpg-engine,代码行数:23,代码来源:TileAnimation.java

示例10: buildDoorAnimations

import com.badlogic.gdx.maps.MapProperties; //导入依赖的package包/类
private Map<String, TiledMapTile[]> buildDoorAnimations(final GameMap map, final List<String> animationIds) {
    final Map<String, Map<Integer, TiledMapTile>> animationTiles = new HashMap<>();
    map.getTiledMap().getTileSets().forEach(tileSet -> {
        tileSet.forEach((TiledMapTile tile) -> {
            final MapProperties tileProperties = tile.getProperties();
            final String animationId = tileProperties.get(TileAnimation.JRPG_TILE_ANIMATION_ID, String.class);
            if (animationIds.contains(animationId)) {
                int animationIndex = tileProperties.get(TileAnimation.JRPG_TILE_ANIMATION_INDEX, Integer.class);
                animationTiles.computeIfAbsent(animationId, key -> new TreeMap<>()).put(animationIndex, tile);
            }
        });
    });

    final Map<String, TiledMapTile[]> animations = new HashMap<>();
    animationTiles.keySet().forEach(animationId -> {
        animations.put(animationId, animationTiles.get(animationId).values().toArray(new TiledMapTile[0]));
    });

    return animations;
}
 
开发者ID:JayStGelais,项目名称:jrpg-engine,代码行数:21,代码来源:MapScanningDoorGenerator.java

示例11: getCellPropertyFromTopMostTile

import com.badlogic.gdx.maps.MapProperties; //导入依赖的package包/类
public static <T> T getCellPropertyFromTopMostTile(final TiledMap tiledMap, final TileCoordinate coordinate,
                                                   final String propertyName, final Class<T> clazz) {
    T value = null;
    for (MapLayer mapLayer : tiledMap.getLayers()) {
        if (mapLayer instanceof TiledMapTileLayer
                && matchProperty(mapLayer, GameMap.MAP_LAYER_PROP_MAP_LAYER, coordinate.getMapLayer())) {
            TiledMapTileLayer tiledMapTileLayer = (TiledMapTileLayer) mapLayer;
            TiledMapTileLayer.Cell cell = tiledMapTileLayer.getCell(coordinate.getX(), coordinate.getY());
            if (cell != null) {
                final MapProperties cellProps = cell.getTile().getProperties();
                value = (cellProps.get(propertyName, clazz) != null) ? cellProps.get(propertyName, clazz) : value;
            }
        }
    }

    return value;
}
 
开发者ID:JayStGelais,项目名称:jrpg-engine,代码行数:18,代码来源:TiledUtil.java

示例12: extractText

import com.badlogic.gdx.maps.MapProperties; //导入依赖的package包/类
private String extractText(MapProperties p, String key, String text) {
    if (p.containsKey(key) || p.containsKey(text)) {
        if (p.containsKey(key)) {
            try {
                return Bundle.general.get((String) p.get(key));
            } catch (MissingResourceException e) {
                if (p.containsKey(text)) {
                    return (String) p.get(text);
                } else {
                    // Nothing to do here. Flee, you fools!
                    return null;
                }
            }
        } else {
           return (String) p.get(text);
        }
    } else {
        return null;
    }
}
 
开发者ID:bitbrain,项目名称:rbcgj-2016,代码行数:21,代码来源:TooltipHandler.java

示例13: load

import com.badlogic.gdx.maps.MapProperties; //导入依赖的package包/类
public void load(TiledMap map) {
    MapProperties properties = map.getProperties();
    width = (Integer) properties.get(Tmx.WIDTH);
    height = (Integer) properties.get(Tmx.HEIGHT);
    objects = new MapObject[width][height];
    portals.clear();

    for (MapLayer layer : map.getLayers()) {
        for (MapObject object : layer.getObjects()) {
            if (object.getProperties().get("portal-id") != null) {
                portals.put((String) object.getProperties().get("portal-id"), object);
            }
            MapProperties objectProperties = object.getProperties();
            float x = (Float) objectProperties.get("x");
            float y = (Float) objectProperties.get("y");
            int indexX = (int) Math.floor(x / GameConfig.CELL_SCALE);
            int indexY = (int) Math.floor(y / GameConfig.CELL_SCALE);
            if (indexX >= 0 && indexY >= 0 && indexX < width && indexY < height) {
                objects[indexX][indexY] = object;
            }
        }
    }
}
 
开发者ID:bitbrain,项目名称:rbcgj-2016,代码行数:24,代码来源:MapActionHandler.java

示例14: onObjectEnter

import com.badlogic.gdx.maps.MapProperties; //导入依赖的package包/类
@Override
public void onObjectEnter(GameObject object, MapProperties properties, MapActionHandler.MapAPI api) {
    int indexX = (int)Math.floor(object.getLeft() / GameConfig.CELL_SCALE);
    int indexY = (int)Math.floor(object.getTop() / GameConfig.CELL_SCALE);
    MapObject o = api.getObjectAt(indexX, indexY);
    if (o != null) {
        GameObject gameObject = levelManager.getGameObjectByMapObject(o);
        if (gameObject != null) {
            playerManager.addCollectible(GameObjectType.CRUMB);
            api.removeObjectAt(indexX, indexY);
            world.remove(gameObject);
            AssetManager.getSound(Assets.Sounds.COLLECT_NUT).play();
            Tooltip.getInstance().create(object.getLeft() + object.getWidth() * 2f, object.getTop() + object.getHeight() * 3f, Styles.STORY, "nom..", Colors.INFO, null);
        }
    }
}
 
开发者ID:bitbrain,项目名称:rbcgj-2016,代码行数:17,代码来源:CrumbCollector.java

示例15: TmxMap

import com.badlogic.gdx.maps.MapProperties; //导入依赖的package包/类
public TmxMap(String levelName) {
	
	map = new TmxMapLoader().load(levelName);
	tileLayer = (TiledMapTileLayer) map.getLayers().get(0);
	objectsLayer = map.getLayers().get(1);
	MapProperties properties = tileLayer.getProperties();				
	worldType = WorldTypeEnum.valueOf(((String)properties.get(TilemapPropertiesConstants.WORLD)).toUpperCase());
	musicTheme = ((String)properties.get("music")).toUpperCase();
	String sScrollableTo = (String)properties.get("scrollableTo");
	scrollMaxValue = sScrollableTo!=null && !sScrollableTo.equals("") ? Float.parseFloat(sScrollableTo) : 1000;
	String sCastle = (String)properties.get("castle");
	endLevelCastleType = worldType !=WorldTypeEnum.CASTLE ? sCastle!=null && !sCastle.equals("") ? CastleTypeEnum.valueOf(sCastle.toUpperCase()) : CastleTypeEnum.SMALL : null;		
		initBlocks(worldType);		
	initMapObjects();		
	initBackgrounds(properties);
}
 
开发者ID:provenza24,项目名称:Mario-Libgdx,代码行数:17,代码来源:TmxMap.java


注:本文中的com.badlogic.gdx.maps.MapProperties类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。