public void Load(string aFilePath) { int ButtonsToLoad = 0; using (XmlReader xmlReader = XmlReader.Create(aFilePath)) { while (xmlReader.Read()) { switch (xmlReader.NodeType) { case XmlNodeType.Element: ButtonsToLoad++; break; case XmlNodeType.Text: ButtonsToLoad--; break; } } ButtonsToLoad--; xmlReader.Close(); } using (XmlReader xmlReader = XmlReader.Create(aFilePath)) { xmlReader.MoveToContent(); xmlReader.ReadStartElement("Data"); string rawData; string[] organizedData; string[] xData; string[] yData; string[] zData; for (int loop = 0; loop < ButtonsToLoad; loop++) { xmlReader.ReadStartElement("Button"); Tile temporaryTile = new Tile(); // temporaryTile.FilePathToBorder = xmlReader.ReadElementContentAsString("Border", ""); temporaryTile.FilePathToGraphic = xmlReader.ReadElementContentAsString("Graphic", ""); rawData = xmlReader.ReadElementContentAsString("Position", ""); organizedData = rawData.Split(' '); xData = organizedData[0].Split(':'); yData = organizedData[1].Split(':'); yData[1] = yData[1].TrimEnd(); // Glitch: This is not working. C# has failed me : ( yData[1] = yData[1].Replace('}', ' '); // This is another method of doing it. Rather not use it tho for the sake of consistency. temporaryTile.WorldPosition = new Vector2((float)Convert.ToDouble(xData[1]), (float)Convert.ToDouble(yData[1])); rawData = xmlReader.ReadElementContentAsString("IsCollidable", ""); if (rawData == "True") { temporaryTile.IsCollidable = true; } else { temporaryTile.IsCollidable = false; } rawData = xmlReader.ReadElementContentAsString("Color", ""); organizedData = rawData.Split(' '); xData = organizedData[0].Split(':'); yData = organizedData[1].Split(':'); zData = organizedData[2].Split(':'); zData[1] = zData[1].TrimEnd(); // See. It works here. What the heck? temporaryTile.Color = new Color((float)Convert.ToDouble(xData[1]), (float)Convert.ToDouble(yData[1]), (float)Convert.ToDouble(zData[1])); temporaryTile.Rotation = xmlReader.ReadElementContentAsFloat("Rotation", ""); temporaryTile.Scale = xmlReader.ReadElementContentAsFloat("Scale", ""); switch (xmlReader.ReadElementContentAsString("SpriteEffects", "")) { case "FlipVertically": temporaryTile.SpriteEffects = SpriteEffects.FlipVertically; break; case "FlipHorizontally": temporaryTile.SpriteEffects = SpriteEffects.FlipHorizontally; break; case "None": temporaryTile.SpriteEffects = SpriteEffects.None; break; default: break; } temporaryTile.Rotation = xmlReader.ReadElementContentAsFloat("LayerDepth", ""); xmlReader.ReadEndElement(); Add(temporaryTile); } } }
public override void Create(Vector2 aCoordinate) { Tile newTile = new Tile(aCoordinate); newTile.FilePathToGraphic = "Metal"; newTile.IsCollidable = true; }
public override void Generate(Vector2 aCoordinate) { Tile newTile = new Tile(aCoordinate); }
public override void Create(Vector2 aCoordinate) { Tile newTile = new Tile(aCoordinate); newTile.FilePathToGraphic = "WoodenFloor"; newTile.IsCollidable = false; }