public static void Write(string path, XmlLevel level) { XmlSerializer serializer = new XmlSerializer(typeof(XmlLevel)); using (StreamWriter writer = new StreamWriter(path)) serializer.Serialize(writer, level); }
public static void Save(XmlLevel level) { Write(string.Format("Content/levels/{0}.xml", level.number), level); }
public void Save() { List<XmlEntity> xmlentities = new List<XmlEntity>(); XmlLevel xmllevel = new XmlLevel(name, id, xmlentities); for (int i = 0; i < entities.Count; i++) { Entity entity = entities[i]; XmlEntity xmlentity = new XmlEntity(); xmlentity.position = entity.position; xmlentity.rotation = entity.rotation; xmlentity.size = entity.size; if (entity is StaticModelEntity) { StaticModelEntity modelentity = entity as StaticModelEntity; xmlentity.asset = Resources.GetName(modelentity.GetModel()); xmlentity.type = "static_model"; } if (entity is AnimatedModelEntity) { AnimatedModelEntity modelentity = entity as AnimatedModelEntity; xmlentity.asset = Resources.GetName(modelentity.GetModel()); xmlentity.type = "animated_model"; } if (entity is WallModelEntity) { WallModelEntity wallentity = entity as WallModelEntity; xmlentity.asset = Resources.GetName(wallentity.GetModel()); xmlentity.type = "wall_model"; } if (entity is Billboard) { Billboard billboard = entity as Billboard; xmlentity.asset = Resources.GetName(billboard.region.texture); xmlentity.type = "billboard"; xmlentity.color = billboard.color; } xmlentities.Add(xmlentity); } XmlHelper.Save(xmllevel); }