private void loadTilesets(ContentManager Content) { //Load tile properties tileProperties = new Dictionary <int, TileModsTuple>(); foreach (dynamic tilesetData in mapData.json["tilesets"]) { Console.WriteLine("Loading tileset: " + tilesetData.name); TilesetData data = new TilesetData(); data.firstgid = tilesetData.firstgid; data.columns = tilesetData.columns; data.imageHeight = tilesetData.imageheight; data.imageWidth = tilesetData.imagewidth; data.margin = tilesetData.margin; data.name = tilesetData.name; data.spacing = tilesetData.spacing; data.tileCount = tilesetData.tilecount; data.texture = Content.Load <Texture2D>(data.name); data.tileHeight = tilesetData.tileheight; data.tileWidth = tilesetData.tilewidth; data.type = tilesetData.type; Tileset tileset = new Tileset(data); tilesets.Add(data.name, tileset); //Add baseline properties for every tile int tileCount = data.tileCount; Console.WriteLine("tile count {0}", tileCount); for (int i = 0; i < tileCount; i++) { TileModsTuple properties = new TileModsTuple(); properties.tileset = tileset; properties.tileNum = i + data.firstgid; properties.tilesetNum = i; tileProperties.Add(properties.tileNum, properties); Console.WriteLine("added tileset data '{1}' to tile: {0} ", properties.tileNum, tileset.data.name); } if (tilesetData["tileproperties"] != null) { foreach (dynamic tile in tilesetData["tileproperties"]) { int tileNum; int.TryParse(tile.Name, out tileNum); tileNum += data.firstgid; Console.WriteLine("Added property {0} for tilenum {1}", tile.Value, tileNum); addProperties(tileNum, tile.Value); } } } }
public Tileset(TilesetData data) { this.data = data; }