public static Grid Load(XmlDocument xmlDocument, XmlNode rootNode) { int xSize = Convert.ToInt32(rootNode.Attributes["xSize"].Value); int zSize = Convert.ToInt32(rootNode.Attributes["zSize"].Value); string textureName = rootNode.Attributes["texture"].Value; Grid NewGrid = new Grid(xSize, zSize, "Textures/red"); NewGrid._grid = new GridSquare[xSize, zSize]; XmlNodeList gridSquareList = rootNode.ChildNodes; foreach (XmlNode node in gridSquareList) { int xIndex = Convert.ToInt32(node.Attributes["xIndex"].Value); int zIndex = Convert.ToInt32(node.Attributes["zIndex"].Value); bool isWalkable = Convert.ToBoolean(node["IsWalkable"].InnerText); float height = (float)Convert.ToDouble(node["Height"].InnerText); Vector3 topUp = (new Vector3()).GetFromString(node["TopUp"].InnerText); float topAngle = (float)Convert.ToDouble(node["TopAngle"].InnerText); GridSquare curGS = new GridSquare(xIndex, zIndex, height); NewGrid._grid[xIndex, zIndex] = curGS; curGS.IsWalkable = isWalkable; curGS.Height = height; curGS.TopUp = topUp; curGS.TopAngle = topAngle; curGS.CompileVertices(); } NewGrid.initializeGraphics(textureName); NewGrid.compileVertices(); return(NewGrid); }