private void ReadElement(XmlElement element) { switch (element.Name) { case LOAD_IMAGE_AS_TILE: LoadImageAsTileReader imageTileReader = new LoadImageAsTileReader(element); imageTileReader.read(); addTile = new SpriteSheet.Tile(currentTileID, imageTileReader.Tile); if (!TileGroups.ContainsKey(imageTileReader.TileGroup)) { TileGroups.Add(imageTileReader.TileGroup, new Dictionary<string, SpriteSheet.Tile>()); } if (!CurrentFrame.ContainsKey(imageTileReader.TileGroup)) { CurrentFrame.Add(imageTileReader.TileGroup, 0); } TileGroups[imageTileReader.TileGroup].Add(imageTileReader.TileGroup + CurrentFrame[imageTileReader.TileGroup], addTile); Textures.Add(imageTileReader.Texture); CurrentFrame[imageTileReader.TileGroup]++; currentTileID++; break; case LOAD_SHEET: LoadSheetReader sheetReader = new LoadSheetReader(element); sheetReader.read(); foreach (KeyValuePair<string, List<Rectangle>> group in sheetReader.GroupTiles) { if (!TileGroups.ContainsKey(group.Key)) { TileGroups.Add(group.Key, new Dictionary<string, SpriteSheet.Tile>()); CurrentFrame.Add(group.Key, 0); } foreach (Rectangle tile in group.Value) { addTile = new SpriteSheet.Tile(currentTileID, tile); TileGroups[group.Key].Add(group.Key + CurrentFrame[group.Key], addTile); CurrentFrame[group.Key]++; } } Textures.Add(sheetReader.Texture); currentTileID++; break; case LOAD_DIRECTORY: LoadDirectoryReader directoryReader = new LoadDirectoryReader(element); directoryReader.read(); if (!TileGroups.ContainsKey(directoryReader.GroupName)) { TileGroups.Add(directoryReader.GroupName, new Dictionary<string, SpriteSheet.Tile>()); CurrentFrame.Add(directoryReader.GroupName, 0); } foreach (var key in directoryReader.Tiles.Keys) { addTile = new SpriteSheet.Tile(currentTileID, directoryReader.Tiles[key]); TileGroups[directoryReader.GroupName].Add(directoryReader.GroupName + CurrentFrame[directoryReader.GroupName], addTile); Textures.Add(directoryReader.Textures[key]); CurrentFrame[directoryReader.GroupName]++; currentTileID++; } break; case LOAD_DIRECTORY_FULL: LoadDirectoryFullReader directoryFullReader = new LoadDirectoryFullReader(element); directoryFullReader.Read(); if (!TileGroups.ContainsKey(directoryFullReader.GroupName)) { TileGroups.Add(directoryFullReader.GroupName, new Dictionary<string, SpriteSheet.Tile>()); CurrentFrame.Add(directoryFullReader.GroupName, 0); } foreach (var key in directoryFullReader.Tiles.Keys) { addTile = new SpriteSheet.Tile(currentTileID, directoryFullReader.Tiles[key]); TileGroups[directoryFullReader.GroupName].Add(directoryFullReader.GroupName + CurrentFrame[directoryFullReader.GroupName], addTile); Textures.Add(directoryFullReader.Textures[key]); CurrentFrame[directoryFullReader.GroupName]++; currentTileID++; } break; default: break; } }
private void ReadElement(XmlElement element) { switch (element.Name) { case LOAD_IMAGE_AS_TILE: LoadImageAsTileReader imageTileReader = new LoadImageAsTileReader(element); imageTileReader.read(); addTile = new SpriteSheet.Tile(currentTileID, imageTileReader.Tile); if (!TileGroups.ContainsKey(imageTileReader.TileGroup)) { TileGroups.Add(imageTileReader.TileGroup, new Dictionary <string, SpriteSheet.Tile>()); } if (!CurrentFrame.ContainsKey(imageTileReader.TileGroup)) { CurrentFrame.Add(imageTileReader.TileGroup, 0); } TileGroups[imageTileReader.TileGroup].Add(imageTileReader.TileGroup + CurrentFrame[imageTileReader.TileGroup], addTile); Textures.Add(imageTileReader.Texture); CurrentFrame[imageTileReader.TileGroup]++; currentTileID++; break; case LOAD_SHEET: LoadSheetReader sheetReader = new LoadSheetReader(element); sheetReader.read(); foreach (KeyValuePair <string, List <Rectangle> > group in sheetReader.GroupTiles) { if (!TileGroups.ContainsKey(group.Key)) { TileGroups.Add(group.Key, new Dictionary <string, SpriteSheet.Tile>()); CurrentFrame.Add(group.Key, 0); } foreach (Rectangle tile in group.Value) { addTile = new SpriteSheet.Tile(currentTileID, tile); TileGroups[group.Key].Add(group.Key + CurrentFrame[group.Key], addTile); CurrentFrame[group.Key]++; } } Textures.Add(sheetReader.Texture); currentTileID++; break; case LOAD_DIRECTORY: LoadDirectoryReader directoryReader = new LoadDirectoryReader(element); directoryReader.read(); if (!TileGroups.ContainsKey(directoryReader.GroupName)) { TileGroups.Add(directoryReader.GroupName, new Dictionary <string, SpriteSheet.Tile>()); CurrentFrame.Add(directoryReader.GroupName, 0); } foreach (var key in directoryReader.Tiles.Keys) { addTile = new SpriteSheet.Tile(currentTileID, directoryReader.Tiles[key]); TileGroups[directoryReader.GroupName].Add(directoryReader.GroupName + CurrentFrame[directoryReader.GroupName], addTile); Textures.Add(directoryReader.Textures[key]); CurrentFrame[directoryReader.GroupName]++; currentTileID++; } break; case LOAD_DIRECTORY_FULL: LoadDirectoryFullReader directoryFullReader = new LoadDirectoryFullReader(element); directoryFullReader.Read(); if (!TileGroups.ContainsKey(directoryFullReader.GroupName)) { TileGroups.Add(directoryFullReader.GroupName, new Dictionary <string, SpriteSheet.Tile>()); CurrentFrame.Add(directoryFullReader.GroupName, 0); } foreach (var key in directoryFullReader.Tiles.Keys) { addTile = new SpriteSheet.Tile(currentTileID, directoryFullReader.Tiles[key]); TileGroups[directoryFullReader.GroupName].Add(directoryFullReader.GroupName + CurrentFrame[directoryFullReader.GroupName], addTile); Textures.Add(directoryFullReader.Textures[key]); CurrentFrame[directoryFullReader.GroupName]++; currentTileID++; } break; default: break; } }