private void ProcessTileProperties() { TileMapPropertyFinder finder = new TileMapPropertyFinder (currentLevel); foreach (var propertyLocation in finder.GetPropertyLocations()) { var properties = propertyLocation.Properties; if (properties.ContainsKey ("EntityType")) { float worldX = propertyLocation.WorldX; float worldY = propertyLocation.WorldY; if (properties.ContainsKey ("YOffset")) { string yOffsetAsString = properties ["YOffset"]; float yOffset = 0; float.TryParse (yOffsetAsString, out yOffset); worldY += yOffset; } bool created = TryCreateEntity (properties ["EntityType"], worldX, worldY); if (created) { propertyLocation.Layer.RemoveTile (propertyLocation.TileCoordinates); } } else if (properties.ContainsKey ("RemoveMe")) { propertyLocation.Layer.RemoveTile (propertyLocation.TileCoordinates); } } touchScreen = new TouchScreenInput(gameplayLayer); }
private void ProcessTileProperties() { TileMapPropertyFinder finder = new TileMapPropertyFinder (currentLevel); //遍历每一个瓦片 foreach (var propertyLocation in finder.GetPropertyLocations()) { var properties = propertyLocation.Properties; if (properties.ContainsKey ("EntityType")) { float worldX = propertyLocation.WorldX; float worldY = propertyLocation.WorldY; //加上offset if (properties.ContainsKey ("YOffset")) { string yOffsetAsString = properties ["YOffset"]; float yOffset = 0; float.TryParse (yOffsetAsString, out yOffset); worldY += yOffset; } //如果这个瓦片是entity,则添加到游戏layer bool created = TryCreateEntity (properties ["EntityType"], worldX, worldY); if (created) { //如果这个瓦片是entity,且在layer中添加成功的话,在这个layer中移除这个瓦片 propertyLocation.Layer.RemoveTile (propertyLocation.TileCoordinates); } } else if (properties.ContainsKey ("RemoveMe")) { propertyLocation.Layer.RemoveTile (propertyLocation.TileCoordinates); } } //相当于玩家可以开始操作 input = new TouchScreenInput(gameplayLayer); }