WritePropertyBlock() public static method

public static WritePropertyBlock ( ContentWriter output, IEnumerable properties ) : void
output ContentWriter
properties IEnumerable
return void
Exemplo n.º 1
0
        private void WriteLayer(ContentWriter output, LevelContent content, Layer layer)
        {
            switch (GetLayerType(layer))
            {
            case LayerType.Tiles:
                output.Write("TILE");
                break;

            case LayerType.Objects:
                output.Write("OBJE");
                break;
            }

            output.Write(content.Translate(layer.Uid));
            output.Write(layer.Name);
            output.Write(layer.IsVisible);
            output.Write(layer.Opacity);
            output.Write((short)layer.RasterMode);

            Common.WritePropertyBlock(output, layer.PropertyManager.CustomProperties);

            switch (GetLayerType(layer))
            {
            case LayerType.Tiles:
                WriteTileLayer(output, content, layer as TileGridLayer);
                break;

            case LayerType.Objects:
                WriteObjectLayer(output, content, layer as ObjectLayer);
                break;
            }
        }
Exemplo n.º 2
0
        protected override void Write(ContentWriter output, Project value)
        {
            output.Write(value.Levels.Count);

            foreach (Level level in value.Levels)
            {
                output.Write(level.Uid.ToByteArray());
                output.Write(level.Name);

                Common.WritePropertyBlock(output, level.PropertyManager.CustomProperties);
            }
        }
Exemplo n.º 3
0
        protected override void Write(ContentWriter output, LevelContent value)
        {
            output.Write(value.Level.Name);
            output.Write(value.Level.OriginX);
            output.Write(value.Level.OriginY);
            output.Write(value.Level.Width);
            output.Write(value.Level.Height);

            Common.WritePropertyBlock(output, value.Level.PropertyManager.CustomProperties);

            WriteTileSets(output, value);
            WriteObjectSets(output, value);
            WriteLayers(output, value);
        }
Exemplo n.º 4
0
        private void WriteTileSet(ContentWriter output, LevelContent content, TilePool pool)
        {
            output.Write(content.Translate(pool.Uid));
            output.Write((short)pool.TileWidth);
            output.Write((short)pool.TileHeight);
            output.Write(content.AssetMap[pool.Uid]);

            Common.WritePropertyBlock(output, pool.PropertyManager.CustomProperties);

            output.Write(pool.Count);
            foreach (Tile tile in pool.Tiles)
            {
                TileCoord coord = pool.Tiles.GetTileLocation(tile.Uid);

                output.Write(content.Translate(tile.Uid));
                output.Write((short)coord.X);
                output.Write((short)coord.Y);

                Common.WritePropertyBlock(output, tile.PropertyManager.CustomProperties);
            }
        }
Exemplo n.º 5
0
        private void WriteObjectSet(ContentWriter output, LevelContent content, ObjectPool pool)
        {
            output.Write(content.Translate(pool.Uid));
            output.Write(content.AssetMap[pool.Uid]);

            Common.WritePropertyBlock(output, pool.PropertyManager.CustomProperties);

            output.Write(pool.Count);
            foreach (ObjectClass obj in pool.Objects)
            {
                Page page;
                Rect objRect = FindRectByName(content.AtlasPages, obj.Uid.ToString(), out page);
                if (objRect == null)
                {
                    continue;
                }

                output.Write(content.Translate(obj.Uid));
                output.Write(obj.Name);
                output.Write(obj.Origin.X);
                output.Write(obj.Origin.Y);
                output.Write(obj.MaskBounds.Left);
                output.Write(obj.MaskBounds.Top);
                output.Write(obj.MaskBounds.Width);
                output.Write(obj.MaskBounds.Height);

                output.Write(objRect.Rotated);
                output.Write(page.X + objRect.X);
                output.Write(page.Y + page.Height - objRect.Height - objRect.Y);
                output.Write(objRect.Image.Width);
                output.Write(objRect.Image.Height);
                output.Write(objRect.OriginalWidth);
                output.Write(objRect.OriginalHeight);
                output.Write(objRect.OffsetX);
                output.Write(objRect.OriginalHeight - objRect.Image.Height - objRect.OffsetY);
                //output.Write(objRect.Index);
                Common.WritePropertyBlock(output, obj.PropertyManager.CustomProperties);
            }
        }
Exemplo n.º 6
0
        private void WriteObjectLayer(ContentWriter output, LevelContent content, ObjectLayer layer)
        {
            int objCount = 0;

            foreach (ObjectInstance obj in layer.Objects)
            {
                objCount++;
            }

            output.Write(objCount);
            foreach (ObjectInstance obj in layer.Objects)
            {
                output.Write(content.Translate(obj.ObjectClass.Uid));
                output.Write(obj.Position.X);
                output.Write(obj.Position.Y);
                output.Write(obj.Rotation);
                output.Write(obj.ScaleX);
                output.Write(obj.ScaleY);

                Common.WritePropertyBlock(output, obj.PropertyManager.CustomProperties);
            }
        }