Java 类com.badlogic.gdx.maps.MapProperties 实例源码

项目:odb-artax    文件:PowerSystem.java   
@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);
                }
            }
        }
    }
}
项目:odb-artax    文件:PowerSystem.java   
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);
                }
            }
        }
    }
}
项目:odb-artax    文件:MapSystem.java   
/**
 * 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);
                    }
                }
            }
        }
    }
}
项目:KyperBox    文件:GameObject.java   
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);
    }

}
项目:KyperBox    文件:GameState.java   
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;
        }
    }
}
项目:KyperBox    文件:GameState.java   
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));
                }
            }
        }
    }
}
项目:KyperBox    文件:GameState.java   
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);
                }
            }
        }
    }
}
项目:GangsterSquirrel    文件:Box2DWorldCreator.java   
/**
 * 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;
        }
    }
}
项目:jrpg-engine    文件:TileAnimation.java   
@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);
                    }
                }
            }
        }
    }
}
项目:jrpg-engine    文件:MapScanningDoorGenerator.java   
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;
}
项目:jrpg-engine    文件:TiledUtil.java   
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;
}
项目:rbcgj-2016    文件:TooltipHandler.java   
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;
    }
}
项目:rbcgj-2016    文件:MapActionHandler.java   
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;
            }
        }
    }
}
项目:rbcgj-2016    文件:CrumbCollector.java   
@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);
        }
    }
}
项目:Mario-Libgdx    文件:TmxMap.java   
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);
}
项目:Mario-Libgdx    文件:TmxMap.java   
private void initMapObjects() {

    items = new ArrayList<AbstractItem>();
    enemies = new ArrayList<AbstractEnemy>();
    sfxSprites = new ArrayList<AbstractSfxSprite>();
    plateforms = new ArrayList<AbstractMetalPlateform>();

    MapObjects objects = objectsLayer.getObjects();
    for (MapObject mapObject : objects) {

        MapProperties objectProperty = mapObject.getProperties();                                   
        if (objectProperty.get("type").toString().equals("mario")) {
            mario = new Mario(mapObject);
        }
        initEnemies(mapObject, objectProperty);
        initItems(mapObject, objectProperty);
        initSfxSprites(mapObject, objectProperty);
    }
}
项目:Mario-Libgdx    文件:TmxMap.java   
private void initEnemies(MapObject mapObject, MapProperties objectProperty) {
    if (objectProperty.get("type").toString().equals("piranha")) {              
        enemies.add(new PiranhaPlant(mapObject, mario));
    }
    if (objectProperty.get("type").toString().equals("goomba")) {               
        enemies.add(new Goomba(mapObject, worldType));
    }
    if (objectProperty.get("type").toString().equals("koopa")) {                
        enemies.add(new Koopa(mapObject));
    }           
    if (objectProperty.get("type").toString().equals("redKoopa")) {             
        enemies.add(new RedKoopa(mapObject));
    }
    if (objectProperty.get("type").toString().equals("castleFirebar")) {
        enemies.add(new CastleFirebar(mapObject));      
    }           
    if (objectProperty.get("type").toString().equals("bowser")) {               
        enemies.add(new Bowser(mapObject));
    }
}
项目:Entitas-Java    文件:Box2DMapObjectParser.java   
/**
 * internal method for easier access of {@link MapProperties}
 *
 * @param properties   the {@link MapProperties} from which to get a property
 * @param property     the key of the desired property
 * @param defaultValue the default value to return in case the value of the given key cannot be returned
 * @return the property value associated with the given property key
 */
@SuppressWarnings("unchecked")
private <T> T getProperty(MapProperties properties, String property, T defaultValue) {
    if (properties.get(property) == null)
        return defaultValue;
    if (defaultValue.getClass() == Float.class)
        if (properties.get(property).getClass() == Integer.class)
            return (T) new Float(properties.get(property, Integer.class));
        else if (properties.get(property).getClass() == Float.class)
            return (T) new Float(properties.get(property, Float.class));
        else
            return (T) new Float(Float.parseFloat(properties.get(property, String.class)));
    else if (defaultValue.getClass() == Short.class)
        return (T) new Short(Short.parseShort(properties.get(property, String.class)));
    else if (defaultValue.getClass() == Boolean.class)
        return (T) new Boolean(Boolean.parseBoolean(properties.get(property, String.class)));
    else
        return (T) properties.get(property, defaultValue.getClass());
}
项目:libgdxcn    文件:TideMapLoader.java   
private void loadProperties (MapProperties properties, Element element) {
    if (element.getName().equals("Properties")) {
        for (Element property : element.getChildrenByName("Property")) {
            String key = property.getAttribute("Key", null);
            String type = property.getAttribute("Type", null);
            String value = property.getText();

            if (type.equals("Int32")) {
                properties.put(key, Integer.parseInt(value));
            } else if (type.equals("String")) {
                properties.put(key, value);
            } else if (type.equals("Boolean")) {
                properties.put(key, value.equalsIgnoreCase("true"));
            } else {
                properties.put(key, value);
            }
        }
    }
}
项目:mobius    文件:FadableLayer.java   
@Override
public void fromTiledProperties(MapProperties properties) {
    String prop = properties.get("minOpacity", null, String.class);

    if (prop != null) {
        float minOpacity = -1.0f;

        try {
            minOpacity = Float.parseFloat(prop);
        } catch (NumberFormatException nfe) {
            throw new IllegalArgumentException("Invalid value for opacity: " + prop);
        }

        this.minOpacity = minOpacity;

    } else {
        throw new IllegalArgumentException("Trying to load FadableLayer from layer with no minOpacity!");
    }
}
项目:mobius    文件:MovingLayer.java   
protected void tiledPropertiesHelper(MapProperties properties, String propertyString, boolean flipMax) {
    String prop = (String) properties.get(propertyString, null, String.class);

    if (prop != null) {
        int max = 0;

        try {
            max = Integer.parseInt(prop);
        } catch (NumberFormatException nfe) {
            throw new IllegalArgumentException("Parsing error when loading MovingLayer (" + propertyString
                    + "); no max found.");
        }

        direction = (flipMax ? -1 : 1) * Integer.signum(max);

        if (direction == 0) {
            throw new IllegalArgumentException("MovingLayer (" + propertyString
                    + "): No valid value for property found.");
        }

        maxDiff = Math.abs(max);
    } else {
        throw new IllegalArgumentException("Attempting to load MovingLayer (" + propertyString
                + ") from a layer with no valid property.");
    }
}
项目:naturally-selected-2d    文件:MapSystem.java   
/**
     * Spawn map entities.
     */
    protected void setup() {
        for (TiledMapTileLayer layer : layers) {

//            private HashMap<String, TiledMapTileLayer> layerIndex = new HashMap<String, TiledMapTileLayer>();
//            layerIndex.put(layer.getName(), layer);

            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")) {
                            entitySpawnerSystem.spawnEntity(tx * G.CELL_SIZE, ty * G.CELL_SIZE, properties);
                            layer.setCell(tx, ty, null);
                        }
                    }
                }
            }
        }
    }
项目:artemis-odb-contrib    文件:TerrainManager.java   
@Override
protected void setup(Entity e, Terrain terrain, TerrainAsset asset) {
    if (terrain.id == null ) {
        throw new RuntimeException("TerrainManager: terrain.id is null.");
    }
    asset.map = loader.load(terrain.id);
    asset.renderer = new OrthogonalTiledMapRenderer(asset.map);
    //asset.layers = map.getLayers().getByType(TiledMapTileLayer.class);
    final MapProperties properties = asset.map.getProperties();
    asset.width = properties.get("width", Integer.class);
    asset.height = properties.get("height", Integer.class);
    asset.tileWidth = properties.get("tilewidth", Integer.class);
    asset.tileHeight = properties.get("tileheight", Integer.class);

    // set unitialized size to asset.
    if (!mSize.has(e)) {
        mSize.create(e).set(asset.pixelWidth(), asset.pixelHeight());
    }
}
项目:artemis-odb-contrib    文件:TiledMapSystem.java   
/**
 * 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")) {
                        entityFactorySystem.createEntity((String)properties.get("entity"), tx * tileWidth, ty * tileHeight, properties);
                        layer.setCell(tx, ty, null);
                    }
                }
            }
        }
    }
}
项目:underkeep    文件:TiledMapSystem.java   
/**
 * 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")) {
                        entityFactorySystem.createEntity((String)properties.get("entity"), tx * tileWidth, ty * tileHeight, properties);
                        layer.setCell(tx, ty, null);
                    }
                }
            }
        }
    }
}
项目:DreamsLibGdx    文件:Box2DMapObjectParser.java   
/**
 * internal method for easier access of {@link MapProperties}
 *
 * @param properties   the {@link MapProperties} from which to get a property
 * @param property     the key of the desired property
 * @param defaultValue the default value to return in case the value of the given key cannot be returned
 * @return the property value associated with the given property key
 */
@SuppressWarnings("unchecked")
private <T> T getProperty(MapProperties properties, String property, T defaultValue) {
    if (properties.get(property) == null)
        return defaultValue;
    if (defaultValue.getClass() == Float.class)
        if (properties.get(property).getClass() == Integer.class)
            return (T) new Float(properties.get(property, Integer.class));
        else
            return (T) new Float(Float.parseFloat(properties.get(property, String.class)));
    else if (defaultValue.getClass() == Short.class)
        return (T) new Short(Short.parseShort(properties.get(property, String.class)));
    else if (defaultValue.getClass() == Boolean.class)
        return (T) new Boolean(Boolean.parseBoolean(properties.get(property, String.class)));
    else
        return (T) properties.get(property, defaultValue.getClass());
}
项目:DreamsLibGdx    文件:Box2dObjectFactory.java   
@SuppressWarnings("unchecked")
private <T> T getProperty(MapProperties properties, String property, T defaultValue) {
    if (properties.get(property) == null)
        return defaultValue;
    if (defaultValue.getClass() == Float.class)
        if (properties.get(property).getClass() == Integer.class)
            return (T) new Float(properties.get(property, Integer.class));
        else
            return (T) new Float(Float.parseFloat(properties.get(property, String.class)));
    else if (defaultValue.getClass() == Short.class)
        return (T) new Short(Short.parseShort(properties.get(property, String.class)));
    else if (defaultValue.getClass() == Boolean.class)
        return (T) new Boolean(Boolean.parseBoolean(properties.get(property, String.class)));
    else
        return (T) properties.get(property, defaultValue.getClass());
}
项目:Cypher-Sydekick    文件:MapActions.java   
private void doCheck(int x, int y, String actStr) {
    MapObject obj = actable.get(new Coord(x, y));
    if (obj == null) {
        return;
    }

    MapProperties props = obj.getProperties();
    if (!obj.isVisible()) {
        System.out.println("Ignoring because invisible!");
        return;
    }

    ActionAction[] acts = (ActionAction[]) props.get(actStr);
    if (acts != null) {
        System.out.println("At " + new Coord(x, y) + " there was a "
                + actStr + " event: " + Arrays.toString(acts));
        for (ActionAction act : acts) {
            if (act.remote) {
                sendRemoteMsg(act.targetId, act.act);
            } else {
                MapObject dest = objects.get(act.targetId);
                act.act.doit(dest);
            }
        }
    }
}
项目:Cypher-Sydekick    文件:MapActions.java   
private static boolean makeAction(MapProperties props, String propName) {
    String propstr = (String) props.get(propName);
    if (propstr == null) {
        return false;
    }

    String[] acts = propstr.split(",");
    ActionAction[] out = new ActionAction[acts.length];

    for (int i = 0; i < acts.length; i++) {
        String pp = acts[i];
        char location = pp.charAt(0);
        int colon = pp.indexOf(':');
        if (location != 'r' && location != 'l' || colon == -1) {
            throw new RuntimeException("Bad action string: " + pp);
        }

        out[i] = new ActionAction(location == 'r', pp.substring(1, colon),
                MapAction.valueOf(pp.substring(colon + 1)));
    }
    props.put(propName, out);

    return true;
}
项目:cocos2d-java    文件:TMXTiledMap.java   
private void _initProperties() {
 MapProperties ps = _tileMap.getProperties();
 Object temp = null;
 if((temp = ps.get("width")) != null) {
  _tileWidthCount = (int) temp;
 }
 if((temp = ps.get("height")) != null) {
  _tileHeightCount = (int) temp;
 }
 if((temp = ps.get("tilewidth")) != null) {
  _tileSize.width = (int) temp;
 }
 if((temp = ps.get("tileheight")) != null) {
  _tileSize.height = (int) temp;
 }
 if((temp = ps.get("orientation")) != null) {
  String orientation = (String) temp;
  switch(orientation) {
  case "isometric":
   _mapOrientation = TiledMapType.OrientationIso;
   break;
  case "orthogonal":
   _mapOrientation = TiledMapType.OrientationOrtho;
   break;
  default:
   CCLog.error("TMXTiledMap", "orientation type not found : " + temp);
  }
 }

 _mapSize.width = _tileWidthCount * _tileSize.width;
 _mapSize.height = _tileHeightCount * _tileSize.height;

}
项目:odb-artax    文件:MapSystem.java   
@Override
protected void initialize() {
    map = new TmxMapLoader().load("map" + G.level + ".tmx");

    layers = new Array<TiledMapTileLayer>();
    for (MapLayer rawLayer : map.getLayers()) {
        layers.add((TiledMapTileLayer) rawLayer);
    }
    width = layers.get(0).getWidth();
    height = layers.get(0).getHeight();

    // need to do this before we purge the indicators from the map.
    mapCollisionSystem.canHoverMask = getMask("canhover");
    mapCollisionSystem.deadlyMask = getMask("deadly");
    mapCollisionSystem.solidForRobotMask = getMask("solidforrobot");

    for (TiledMapTileSet tileSet : map.getTileSets()) {
        for (TiledMapTile tile : tileSet) {
            final MapProperties props = tile.getProperties();
            if (props.containsKey("entity")) {
                Animation<TextureRegion> anim = new Animation<>(10, tile.getTextureRegion());
                String id = (String) props.get("entity");
                if (props.containsKey("cable-type")) {
                    id = cableIdentifier(tile);
                } else if (props.containsKey("powered")) {
                    id = props.get("entity") + "_" + (((Boolean) props.get("powered")) ? "on" : "off");
                    if (props.containsKey("accept")) {
                        id = id + "_" + props.get("accept");
                    }
                }
                assetSystem.sprites.put(id, anim);
            }
        }
    }
}
项目:MMORPG_Prototype    文件:PlayState.java   
private void addSpawner(RectangleMapObject spawnerElement)
{
    MapProperties properties = spawnerElement.getProperties();
    String monsterIdentifier = (String) properties.get("MonsterType");
    @SuppressWarnings("unchecked")
    Class<? extends Monster> monsterType = (Class<? extends Monster>) ObjectsIdentifier
            .getObjectType(monsterIdentifier);
    float spawnInterval = (float) properties.get("spawnInterval");
    int maximumMonsterAmount = (int) properties.get("MaximumMonsterAmount");
    IntegerRectangle spawnArea = new IntegerRectangle(spawnerElement.getRectangle());
    MonsterSpawnerUnit spawnerUnit = new MonsterSpawnerUnit(monsterType, spawnArea, maximumMonsterAmount,
            spawnInterval);
    monsterSpawner.addSpawner(spawnerUnit);
}
项目:arcadelegends-gg    文件:Tile.java   
/**
 * Creates a {@link Tile} from a {@link TiledMapTile}.
 *
 * @param tiledMapTile the tiledMapTile from which to read from
 * @param x            coordinate
 * @param y            coordinate
 * @return the created Tile
 */
public static Tile fromTileMapTile(TiledMapTile tiledMapTile, int x, int y) {
    MapProperties mapProperties = tiledMapTile.getProperties();

    Tile tile = new Tile(x, y);

    if (mapProperties.get("untraversable") != null)
        tile.setTraversable(mapProperties.get("untraversable", Boolean.class));

    return tile;
}
项目:KyperBox    文件:PlatformerObject.java   
@Override
public void init(MapProperties properties) {
    super.init(properties);
    anim_controller = new AnimationController();
    platform_controller = new PlatformerController();
    addController(anim_controller);
    addController(platform_controller);
    anim_controller.setPlaySpeed(3f);

    // create animation
    createAnimations();
    anim_controller.setAnimation("player_walking");


}
项目:KyperBox    文件:TilemapLayerObject.java   
@Override
public void init(MapProperties properties) {
    super.init(properties);
    tile_pool = new Pool<TilemapLayerObject.MapTile>() {
        @Override
        protected MapTile newObject() {
            return new MapTile();
        }
    };
    tiles = (TiledMapTileLayer) getState().getMapData().getLayers().get(properties.get("tile_layer", String.class));
    setSize(tiles.getWidth() * tiles.getTileWidth(), tiles.getHeight() * tiles.getTileHeight());
    render = new TileLayerRenderer(this);
    cell_arrays = new Array<Array<MapTile>>();

}
项目:KyperBox    文件:GameLayer.java   
/**
 * used to add GameObjects to the layer and notify managers
 * @param object
 * @param properties
 */
public void addGameObject(GameObject object,MapProperties properties) {
    object.setGameLayer(this);
    addActor(object);
    object.init(properties);
    gameObjectAdded(object, null);
}
项目:KyperBox    文件:ScrollingBackground.java   
@Override
public void init(MapProperties properties) {
    super.init(properties);
    String image = properties.get("image", String.class);
    absolute = properties.get("absolute", false, boolean.class);
    scroll_x = properties.get("speed_horizontal", 0f, Float.class);
    scroll_y = properties.get("speed_vertical", 0f, Float.class);
    repeat_vertical = properties.get("repeat_vertical", false, Boolean.class);
    repeat_horizontal = properties.get("repeat_horizontal", false, Boolean.class);
    if (image == null || image.isEmpty())
        getState().error("background [" + getName() + "] image not set.");
    background = getGame().getAtlas(getState().getData().getString("map_atlas")).findRegion(image);
    size = 1;
    xoff = 0;
    yoff = 0;
    x_check = 0f;
    y_check = 0f;
    x = 0;
    y = 0;
    virtual_width = getGame().getView().getWorldWidth();
    virtual_height = getGame().getView().getWorldHeight();
    if (!absolute) {
        if (repeat_vertical) {
            yoff -= 1;
            size *= 3;
        }
        if (repeat_horizontal) {
            xoff -= 1;
            size *= 3;
        }
    }

    pos_x = 0;
    pos_y = 0;

}
项目:KyperBox    文件:GameState.java   
private void loadUi(MapLayer layer, TextureAtlas atlas) {
    MapObjects objects = layer.getObjects();
    Array<String> added = new Array<String>();
    for (MapObject o : objects) {
        MapProperties properties = o.getProperties();
        Actor ui_actor = getUiActor(added, o, properties, objects, atlas);
        if (ui_actor != null)
            uiground.addActor(ui_actor);

    }
}
项目:KyperBox    文件:QuadTree.java   
@Override
public void init(MapProperties properties) {
    // TODO: set boundaries here maybe????? using some underlying layer properties.
    // I dont know how to implement this
    // since layers at this moment dont have types so just adding properties seems
    // dirty.
    getLayer().getState().log("QuadTree: init");
}
项目:KyperBox    文件:ParticleSystem.java   
@Override
public void init(MapProperties properties) {
    effects = new ArrayMap<GameObject, ParticleEffectPool.PooledEffect>();
    pre_draws = new Array<ParticleEffectPool.PooledEffect>();
    post_draws = new Array<ParticleEffectPool.PooledEffect>();
    pos_check = new Vector2();
    cam = getLayer().getCamera();
    last_zoom = cam.getZoom();
    pcomp = new ParticleComparator();
}