Beispiel #1
0
        internal TileSet(ContentReader reader)
            : this()
        {
            _manager = reader.ContentManager;

            //int version = reader.ReadInt16();
            int id = reader.ReadInt32();

            TileWidth = reader.ReadInt16();
            TileHeight = reader.ReadInt16();
            string texAsset = reader.ReadString();

            Properties = new PropertyCollection(reader);

            int tileCount = reader.ReadInt32();
            for (int i = 0; i < tileCount; i++) {
                int tileId = reader.ReadInt32();
                int tileX = reader.ReadInt16();
                int tileY = reader.ReadInt16();

                Tile tile = new Tile(tileId, this, tileX, tileY)
                {
                    Properties = new PropertyCollection(reader),
                };
                _tiles.Add(tileId, tile);
            }

            _texture = _manager.Load<Texture2D>(texAsset);
        }
Beispiel #2
0
        internal TileLayer(ContentReader reader, TileRegistry registry)
            : base(reader)
        {
            _registry = registry;

            TileWidth = reader.ReadInt16();
            TileHeight = reader.ReadInt16();
            Width = reader.ReadInt16();
            Height = reader.ReadInt16();

            _tiles = new TileGrid(Width, Height);

            int stackCount = reader.ReadInt32();
            for (int i = 0; i < stackCount; i++) {
                int dx = reader.ReadInt16();
                int dy = reader.ReadInt16();

                int tcount = reader.ReadInt16();
                Tile[] st = new Tile[tcount];

                for (int j = 0; j < tcount; j++) {
                    st[j] = _registry[reader.ReadInt16()];
                }

                _tiles[dx, dy] = new TileStack(st);
            }
        }
Beispiel #3
0
        internal ObjectPool(ContentReader reader)
            : this()
        {
            _manager = reader.ContentManager;

            int version = reader.ReadInt16();
            int id = reader.ReadInt16();

            Properties = new PropertyCollection(reader);

            int objCount = reader.ReadInt16();
            for (int i = 0; i < objCount; i++) {
                int objId = reader.ReadInt16();
                string name = reader.ReadString();

                ObjectClass objClass = new ObjectClass(this, objId, name);
                _objects.Add(objId, objClass);
            }
        }
Beispiel #4
0
        internal Layer(ContentReader reader)
        {
            ScaleX = 1f;
            ScaleY = 1f;

            Id = reader.ReadInt16();
            Name = reader.ReadString();
            Visible = reader.ReadBoolean();
            Opacity = reader.ReadSingle();
            Properties = new PropertyCollection(reader);
        }
Beispiel #5
0
        internal ObjectLayer(ContentReader reader, ObjectRegistry registry)
            : base(reader)
        {
            _registry = registry;
            _objects = new List<ObjectInstance>();

            int objCount = reader.ReadInt32();
            for (int i = 0; i < objCount; i++) {
                int dx = reader.ReadInt32();
                int dy = reader.ReadInt32();
                int id = reader.ReadInt16();

                _objects.Add(new ObjectInstance(_registry.GetObjectPool(id), id, dx, dy));
            }
        }
Beispiel #6
0
        internal Level(ContentReader reader)
            : this()
        {
            int version = reader.ReadInt16();

            int tileWidth = reader.ReadInt16();
            int tileHeight = reader.ReadInt16();
            int width = reader.ReadInt16();
            int height = reader.ReadInt16();

            Width = tileWidth * width;
            Height = tileHeight * height;

            Properties = new PropertyCollection(reader);

            int tilesetCount = reader.ReadInt32();
            for (int i = 0; i < tilesetCount; i++) {
                string asset = reader.ReadString();
                Tileset tileset = reader.ContentManager.Load<Tileset>(asset);

                _tileRegistry.Add(tileset);
            }

            int objectPoolCount = reader.ReadInt32();
            for (int i = 0; i < objectPoolCount; i++) {
                string asset = reader.ReadString();
                ObjectPool pool = reader.ContentManager.Load<ObjectPool>(asset);

                _objectRegistry.Add(pool);
            }

            int layerCount = reader.ReadInt16();
            for (int i = 0; i < layerCount; i++) {
                string type = reader.ReadString();

                switch (type) {
                    case "TILE":
                        _layers.Add(new TileLayer(reader, _tileRegistry));
                        break;
                    case "OBJE":
                        _layers.Add(new ObjectLayer(reader, _objectRegistry));
                        break;
                }
            }
        }
Beispiel #7
0
 protected internal override short Read(ContentReader input, short existingInstance)
 {
     return(input.ReadInt16());
 }