public void AddProperty(string name, string value) { var a = new ShadowFileElement(); a.name = name; a.value = value; a.isBlock = false; this.properties.Add(a.name, a); }
public static void WriteFile(ShadowFileElement root, string path) { StreamWriter writer = new StreamWriter(path); writer.WriteLine("ShadowFileFormat_1_0_0"); int depth = 0; WriteElement(writer, root, ref depth); writer.Close(); }
public static void WriteElement(StreamWriter w, ShadowFileElement e, ref int depth) { string head = (e.name + (e.isBlock ? ":{" : ":")); head = head.PadLeft(depth + head.Length, '\t'); w.Write(head); if (e.isBlock) { depth += 1; w.WriteLine(); foreach (var property in e.properties) { WriteElement(w, property.Value, ref depth); } w.WriteLine(("}").PadLeft(depth, '\t')); depth -= 1; } else { w.WriteLine(e.value + ","); } }
static bool ConvertMap(string name) { Console.WriteLine("Converting map:\t" + name); var importMap = new TiledSharp.TmxMap(name); ShadowFileElement map = new ShadowFileElement(); map.isBlock = true; map.name = "ASDASD"; map.AddProperty("Width", importMap.Width.ToString()); map.AddProperty("Height", importMap.Height.ToString()); map.AddProperty("TileWidth", importMap.TileWidth.ToString()); map.AddProperty("TileHeight", importMap.TileHeight.ToString()); ShadowFileElement layers = new ShadowFileElement(); layers.name = "Layers"; layers.isBlock = true; foreach (var layer in importMap.Layers) { ShadowFileElement layerElement = new ShadowFileElement(); layerElement.isBlock = true; layerElement.name = layer.Name; layerElement.AddProperty("Visible", layer.Visible.ToString()); if (layer is TmxLayer tilelayer) { string data = ""; for (int i = 0; i < tilelayer.Tiles.Count; i++) { data += tilelayer.Tiles[i].Gid; if (i != tilelayer.Tiles.Count - 1) { data += "."; } } layerElement.AddProperty("map", data); } layers.AddProperty(layerElement); } map.AddProperty(layers); string destFile = name; destFile = destFile.Replace(".tmx", ".sef"); destFile = destFile.Replace(oldValue: ".tmx", newValue: ".sef"); ShadowFileFormat.WriteFile(map, destFile); return(true); }
public void AddProperty(ShadowFileElement element) { this.isBlock = true; //TODO: I think this is correct but i didn't touch this code in a long while :/ this.properties.Add(element.name, element); }