public void AddLayer(MapLayer layer)
        {
            if (layer.Width != mapWidth || layer.Height != mapHeight)
                throw new Exception("Map layer size exception");

            mapLayers.Add(layer);
        }
        public static MapLayer LoadTmx(string xmlFile)
        {
            XmlTextReader reader = new XmlTextReader(xmlFile);

            MapLayer map = null;

            while (reader.Read())
            {
                if (reader.Name.Equals("layer"))
                {
                    map = new MapLayer(Int32.Parse(reader.GetAttribute("width")), Int32.Parse(reader.GetAttribute("height")));
                    for (int i = 0; i < map.Height; i++)
                    {
                        for (int j = 0; j < map.Width; j++)
                        {
                            while (reader.Read())
                            {
                                if (reader.Name.Equals("tile"))
                                    break;
                            }
                            reader.MoveToContent();
                            map.SetTile(j, i, new Tile(Int32.Parse(reader.GetAttribute("gid")) - 1, 0));
                        }
                    }

                    break;
                }
            }

            reader.Close();

            return map;
        }
        public TileMap(Tileset tileset, MapLayer layer)
        {
            tilesets = new List<Tileset>();
            tilesets.Add(tileset);

            mapLayers = new List<MapLayer>();
            mapLayers.Add(layer);

            mapWidth = mapLayers[0].Width;
            mapHeight = mapLayers[0].Height;
        }