Exemple #1
0
        /// <summary>
        /// Initializes a new map with 3 layers !
        /// </summary>
        /// <param name="mapWidth">Width of map</param>
        /// <param name="mapHeight">Height of Map</param>
        public TileMap(int mapWidth, int mapHeight)
        {
            TileMap.mapWidth = mapWidth;
            TileMap.mapHeight = mapHeight;

            for (int l = 0; l < layercount; l++)
            {
                TileMapLayer layer = new TileMapLayer(mapWidth, mapHeight);
                for (int y = 0; y < mapHeight; y++)
                    for (int x = 0; x < mapWidth; x++)
                        layer.SetTile(x, y, -1);

                layers.Add(layer);
            }
            //Initialize a new tilemap with 3 layers !
        }
Exemple #2
0
        private void LoadLayer(XmlNode layerNode, TileMapLayer layer)
        {
            int rowCount = 0;

            foreach (XmlNode node in layerNode)
            {
                if (node.Name == "Row")
                {
                    string row = node.InnerText;
                    row.Trim();
                    string[] cells = row.Split(' ');
                    for (int i = 0; i < mapWidth; i++)
                        layer.SetTile(i, rowCount, Int32.Parse(cells[i]));
                    rowCount++;
                }
            }
        }