/// <summary> /// Reads a single frame into memory. /// </summary> private void ReadFrame( Tile tile, XmlTextReader xtr) { // Grab the sequence int seq = Int32.Parse(xtr["sequence"]); TileFrame frame = null; try { frame = tile.Frames[seq]; } catch (Exception) { return; } // Try to read in the rest of the optional elements if (!String.IsNullOrEmpty(xtr["delay-ms"])) { frame.Delay = Int32.Parse(xtr["delay-ms"]); } if (!String.IsNullOrEmpty(xtr["next-frame"])) { frame.NextFrame = Int32.Parse(xtr["next-frame"]); } if (!String.IsNullOrEmpty(xtr["random"])) { frame.Random = Boolean.Parse(xtr["random"]); } }
/// <summary> /// Constructs the tile drawable object. /// </summary> public TileDrawable( Tile tile, IDrawable drawable) { this.tile = tile; this.drawable = drawable; }
/// <summary> /// Reads a single tile into memory. /// </summary> private Tile ReadTile( DirectoryInfo baseDir, XmlTextReader xtr) { // Grab the attributes Tile t = new Tile(); t.ID = xtr["id"]; t.File = new FileInfo(Path.Combine(baseDir.FullName, xtr["file"])); // Try to read in the rest of the optional elements if (!String.IsNullOrEmpty(xtr["columns"])) { t.Columns = t.Count = Int32.Parse(xtr["columns"]); } if (!String.IsNullOrEmpty(xtr["count"])) { t.Count = Int32.Parse(xtr["count"]); } if (!String.IsNullOrEmpty(xtr["delay-ms"])) { t.Delay = Int32.Parse(xtr["delay-ms"]); } // Check for empty if (xtr.IsEmptyElement) { return t; } // Loop through the reader and load things while (xtr.Read()) { // Check for stop if (xtr.NodeType == XmlNodeType.EndElement && xtr.LocalName == "tile") { break; } // Check for new elements if (xtr.NodeType == XmlNodeType.Element) { // Check the name if (xtr.LocalName == "frame") { ReadFrame(t, xtr); } } } // Return it return t; }