public static string fromMapToString(TileMap map) { return ""; }
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; } }
public void setMap(TileMap map, int maxHeight) { this.map = map; this.maxHeight = maxHeight; this.pathfinder = new AStarPathFinder(map); }