예제 #1
0
 public static string fromMapToString(TileMap map)
 {
     return "";
 }
예제 #2
0
        public static TileMap fromStringToMap(string mapData)
        {
            TileMap map;
            try
            {
                int[,] _map;
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(Regex.Replace(mapData, @"\p{C}+", ""));
                XmlElement root = doc.DocumentElement;

                int length = Int32.Parse(root.SelectSingleNode("length").InnerText);

                _map = new int[length,length];

                XmlNode terrain = root.SelectSingleNode("terrain");
                foreach (XmlNode child in terrain.ChildNodes)
                {
                    int x = Int32.Parse(child.SelectSingleNode("x").InnerText);
                    int y = Int32.Parse(child.SelectSingleNode("y").InnerText);
                    int z = Int32.Parse(child.SelectSingleNode("type").InnerText);
                    _map[x, y] = z;
                }

                map = new TileMap(_map);
                return map;
            }
            catch (Exception e)
            {
                //map = new TileMap();
                return map;
            }
        }
예제 #3
0
 public void setMap(TileMap map, int maxHeight)
 {
     this.map = map;
     this.maxHeight = maxHeight;
     this.pathfinder = new AStarPathFinder(map);
 }