Пример #1
0
        protected override void ProcessResource( SpriteCollection aSprites )
        {
            if ( !aSprites.Any() )
            return;

              OnCategoryProcessing( ResourceTypes.Sprites );
              Directory.CreateDirectory( IO.Path.Combine( Directories.Sprites, Directories.Images ) );
              var previous = SetCurrentDirectory( Directories.Sprites );

              foreach ( var sprite in aSprites ) {
            var fileName = SafeResourceFilename( sprite );
            var subimages = new XElement( "Subimages" );

            for ( int i = 0; i < sprite.Subimages.Count; i++ ) {
              var subimage = sprite.Subimages[i];
              var subimageFilename = AddImageExtension( fileName + " [" + i + "]" );

              SaveImage( IO.Path.Combine( Directories.Images, subimageFilename ), subimage.Bitmap, subimage.Width, subimage.Height );
              subimages.Add( new XElement( "BitmapPath", IO.Path.Combine( Directories.Images, subimageFilename ) ) );
            }

            var document =
              new XElement( "Sprite",
            CreateIndexedResourceNodes( sprite ),
            new XElement( "OriginX", sprite.OriginX ),
            new XElement( "OriginY", sprite.OriginY ),
            subimages,
            new XElement( "CollisionMaskShape", sprite.CollisionMaskShape ),
            new XElement( "CollisionMaskAlphaTolerance", sprite.CollisionMaskAlphaTolerance ),
            new XElement( "SeperateCollisionMasks", sprite.SeperateCollisionMasks ),
            new XElement( "BoundingBox",
              new XElement( "Type", sprite.BoundingBoxType ),
              new XElement( "Left", sprite.BoundingBoxLeft ),
              new XElement( "Right", sprite.BoundingBoxRight ),
              new XElement( "Bottom", sprite.BoundingBoxBottom ),
              new XElement( "Top", sprite.BoundingBoxTop )
            )
              );

            SaveDocument( document, fileName + ".xml" );
            OnResourceProcessed( sprite.Name );
              }

              OnCategoryProcessed( ResourceTypes.Sprites );
              SetCurrentDirectory( previous );
        }