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


Java MapProperties.containsKey方法代码示例

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


在下文中一共展示了MapProperties.containsKey方法的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: 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

示例5: 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

示例6: 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

示例7: setup

import com.badlogic.gdx.maps.MapProperties; //导入方法依赖的package包/类
/**
     * 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);
                        }
                    }
                }
            }
        }
    }
 
开发者ID:DaanVanYperen,项目名称:naturally-selected-2d,代码行数:25,代码来源:MapSystem.java

示例8: 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")) {
                        entityFactorySystem.createEntity((String)properties.get("entity"), tx * tileWidth, ty * tileHeight, properties);
                        layer.setCell(tx, ty, null);
                    }
                }
            }
        }
    }
}
 
开发者ID:DaanVanYperen,项目名称:artemis-odb-contrib,代码行数:20,代码来源:TiledMapSystem.java

示例9: initialize

import com.badlogic.gdx.maps.MapProperties; //导入方法依赖的package包/类
@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);
            }
        }
    }
}
 
开发者ID:DaanVanYperen,项目名称:odb-artax,代码行数:36,代码来源:MapSystem.java

示例10: getCollidingMapObject

import com.badlogic.gdx.maps.MapProperties; //导入方法依赖的package包/类
/**
 * This method returns the properties of an object in a collision layer by checking the player rectangle and object rectangle for an intersection
 * @param layerIndex the index of the layer in which to search for objects
 * @return the collided object
 */
protected MapObject getCollidingMapObject(int layerIndex) {
    MapObjects mapObjects = map.getLayers().get(layerIndex).getObjects();

    for (MapObject mapObject : mapObjects) {
        MapProperties mapProperties = mapObject.getProperties();

        float width, height, x, y;
        Rectangle objectRectangle = new Rectangle();
        Rectangle playerRectangle = new Rectangle();

        if (mapProperties.containsKey("width") && mapProperties.containsKey("height") && mapProperties.containsKey("x") && mapProperties.containsKey("y")) {
            width = (float) mapProperties.get("width");
            height = (float) mapProperties.get("height");
            x = (float) mapProperties.get("x");
            y = (float) mapProperties.get("y");
            objectRectangle.set(x, y, width, height);
        }

        playerRectangle.set(
                playScreen.getPlayer().getX() * MainGameClass.PPM,
                playScreen.getPlayer().getY() * MainGameClass.PPM,
                playScreen.getPlayer().getWidth() * MainGameClass.PPM,
                playScreen.getPlayer().getHeight() * MainGameClass.PPM
        );

        // If the player rectangle and the object rectangle is colliding, return the object
        if (Intersector.overlaps(objectRectangle, playerRectangle)) {
            return mapObject;
        }
    }

    // If no colliding object was found in that layer
    return null;
}
 
开发者ID:johannesmols,项目名称:GangsterSquirrel,代码行数:40,代码来源:InteractiveMapTileObject.java

示例11: findTileFrames

import com.badlogic.gdx.maps.MapProperties; //导入方法依赖的package包/类
private void findTileFrames() {
    for (TiledMapTileSet tileSet : tiledMap.getTileSets()) {
        for (TiledMapTile tile : tileSet) {
            final MapProperties tileProperties = tile.getProperties();
            if (tileProperties.containsKey(JRPG_TILE_ANIMATION_ID)
                    && tileProperties.get(JRPG_TILE_ANIMATION_ID).equals(id)) {
                tileFrames.put(tileProperties.get(JRPG_TILE_ANIMATION_INDEX, Integer.class), tile);
            }
        }
    }
}
 
开发者ID:JayStGelais,项目名称:jrpg-engine,代码行数:12,代码来源:TileAnimation.java

示例12: validateAndProcess

import com.badlogic.gdx.maps.MapProperties; //导入方法依赖的package包/类
public static void validateAndProcess(PropertyConfiguration configuration, String type,
                                      MapProperties mapProperties) {
    PropertyConfiguration.Properties properties = configuration.getProperties(type);
    if (properties == null) {
        throw new InvalidConfigException(type + ": Properties not set for type");
    }

    // Check that all required properties are set.
    for (String requiredProperty : properties.getRequiredProperties()) {
        if (!mapProperties.containsKey(requiredProperty)) {
            throw new InvalidConfigException(type + ": Required property '" + requiredProperty + "' missing");
        }
    }

    // Check that all properties are valid.
    Iterator<String> propertiesIter = mapProperties.getKeys();
    while (propertiesIter.hasNext()) {
        String property = propertiesIter.next();
        if (property.equals("gid") || property.equals("texture")) {
            continue;
        }

        if (!properties.propertyExists(property)) {
            throw new InvalidConfigException(type + ": Property '" + property + "' is not valid");
        }
    }

    // Fill in missing optional properties with defaults.
    for (String optionalProperty : properties.getOptionalProperties()) {
        String defaultVal = properties.getPropertyDefaultVal(optionalProperty);
        if (!mapProperties.containsKey(optionalProperty)) {
            mapProperties.put(optionalProperty, defaultVal);
        }
    }
}
 
开发者ID:alexschimpf,项目名称:joe,代码行数:36,代码来源:PropertyValidator.java

示例13: handleObjectLayer

import com.badlogic.gdx.maps.MapProperties; //导入方法依赖的package包/类
private void handleObjectLayer(int layerIndex, MapLayer layer, State state, TiledMapConfig config) {
   MapObjects mapObjects = layer.getObjects();
   for (int objectIndex = 0; objectIndex < mapObjects.getCount(); ++objectIndex) {
      MapObject mapObject = mapObjects.get(objectIndex);
      MapProperties objectProperties = mapObject.getProperties();
      GameObject gameObject = gameWorld.addObject();
      final float x = objectProperties.get(config.get(Constants.X), Float.class);
      final float y = objectProperties.get(config.get(Constants.Y), Float.class);
      final float w = objectProperties.get(config.get(Constants.WIDTH), Float.class);
      final float h = objectProperties.get(config.get(Constants.HEIGHT), Float.class);
      final float cellWidth = state.getCellWidth();
      final float cellHeight = state.getCellHeight();
      Object objectType = objectProperties.get(config.get(Constants.TYPE));
      boolean collision = objectProperties.get(config.get(Constants.COLLISION), true, Boolean.class);
      gameObject.setPosition(x, y);
      gameObject.setDimensions(IndexCalculator.calculateIndexedDimension(w, cellWidth),
            IndexCalculator.calculateIndexedDimension(h, cellHeight));
      gameObject.setLastPosition(x, y);
      gameObject.setColor(mapObject.getColor());
      gameObject.setType(objectType);
      gameObject.setAttribute(Constants.LAYER_INDEX, layerIndex);
      gameObject.setAttribute(MapProperties.class, objectProperties);
      if (objectProperties.containsKey(config.get(Constants.MOVEMENT))) {
         String className = objectProperties.get(config.get(Constants.MOVEMENT), String.class);
         RasteredMovementBehavior behavior = createMovementBehavior(className);
         if (behavior != null) {
            behaviorManager.apply(behavior, gameObject);
         }
      }
      CollisionCalculator.updateCollision(collision, x, y, layerIndex, state);
      IndexCalculator.calculateZIndex(gameObject, state, layerIndex);
      for (TiledMapListener listener : listeners) {
         listener.onLoadGameObject(gameObject, api);
      }
   }
}
 
开发者ID:bitbrain,项目名称:braingdx,代码行数:37,代码来源:StatePopulator.java

示例14: populateStateMap

import com.badlogic.gdx.maps.MapProperties; //导入方法依赖的package包/类
private void populateStateMap(int x, int y, State state, int layerIndex, TiledMapTileLayer layer,
      TiledMapConfig config) {
   Cell cell = layer.getCell(x, y);
   MapProperties layerProperties = layer.getProperties();
   boolean collisionLayer = Boolean
         .valueOf(layerProperties.get(config.get(Constants.COLLISION), "false", String.class));
   CellState cellState = state.getState(x, y, layerIndex);
   // Inherit the collision from the previous layer, if and only if
   // the current layer is non-collision by default
   if (layerIndex > 0 && !collisionLayer && state.getState(x, y, layerIndex - 1).isCollision()) {
      cellState.setCollision(true);
   } else if (cell != null) {
      TiledMapTile tile = cell.getTile();
      if (tile != null) {
         MapProperties properties = tile.getProperties();
         cellState.setProperties(properties);
         if (properties.containsKey(Constants.COLLISION)) {
            boolean collision = Boolean.valueOf(properties.get(Constants.COLLISION, String.class));
            cellState.setCollision(collision);
         } else {
            cellState.setCollision(DEFAULT_COLLISION);
         }
      } else {
         cellState.setCollision(DEFAULT_COLLISION);
      }
   } else {
      cellState.setCollision(DEFAULT_COLLISION);
   }
}
 
开发者ID:bitbrain,项目名称:braingdx,代码行数:30,代码来源:StatePopulator.java

示例15: prepareFromMap

import com.badlogic.gdx.maps.MapProperties; //导入方法依赖的package包/类
@Override
public List<Entity> prepareFromMap(int levelID, MapObject mapObj) {

	MapProperties props = mapObj.getProperties();
	
	float x = (float) props.get("x");
	float y = (float) props.get("y");
	
	//TODO: use this for area spawning
	float width = (float) props.get("width");
	float height = (float) props.get("height");
	
	Random rand = new Random();
	
	//default to main enemy team if no data
	int team = EntityData.TEAM_1;
	if (props.containsKey("team")) {
		team = (int) props.get("team");
	}
	
	int count = 1;
	
	if (props.containsKey("count")) {
		count = Integer.valueOf((String) props.get("count"));
	}
	
	List<Entity> listEnts = new ArrayList<>();
	
	for (int i = 0; i < count; i++) {
		listEnts.add(prepareFromData(levelID, x + rand.nextFloat() * width, y + rand.nextFloat() * height, team));
	}
	
	return listEnts;
}
 
开发者ID:Corosauce,项目名称:AI_TestBed_v3,代码行数:35,代码来源:SpawnableBaseNPC.java


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