Exemple #1
0
        public void ParseLayer(XmlNode layerNode)
        {
            int width  = Convert.ToInt32(layerNode.Attributes["width"].Value);
            int height = Convert.ToInt32(layerNode.Attributes["height"].Value);

            _map._tiles = new Tile[width, height];

            MapLayer newLayer = new MapLayer(width, height);

            for (int i = 0; i < layerNode.FirstChild.ChildNodes.Count; i++)
            {
                XmlNode tileNode = layerNode.FirstChild.ChildNodes[i];

                string sGid = tileNode.Attributes["gid"].Value;
                if (sGid != "0")
                {
                    int  gid     = Convert.ToInt32(sGid);
                    Tile newTile = new Tile(gid);
                    newLayer.AddTile(i % width, i / width, newTile);
                }
            }

            _map.AddLayer(newLayer);
        }
Exemple #2
0
 public void AddLayer(MapLayer newLayer)
 {
     _layers.Add(newLayer);
 }