private static XElement GetPlatformDataXml(PlatformData platformData) { XElement platformElement = new XElement("platform"); if (platformData.Id >= 0) { platformElement.Add(new XAttribute("id", platformData.Id)); } platformElement.Add(new XAttribute("x", platformData.X)); platformElement.Add(new XAttribute("y", platformData.Y)); platformElement.Add(new XAttribute("type", platformData.Type)); if (platformData.MovementData != null) { XElement movementElement = GetPlatformMovementDataXml(platformData.MovementData); platformElement.Add(movementElement); } if (platformData.FeaturesData != null) { XElement featuresElement = GetPlatformFeaturesDataXml(platformData.FeaturesData); platformElement.Add(featuresElement); } return platformElement; }
private static PlatformData GetPlatformData(XElement platformElement) { int id = platformElement.GetInt("id", -1); double x = platformElement.GetDouble("x"); double y = platformElement.GetDouble("y"); PlatformType type = platformElement.GetEnum<PlatformType>("type"); XElement movementElement = platformElement.Element("movement"); PlatformMovementBaseData movementData = GetPlatformMovementData(movementElement); XElement featuresElement = platformElement.Element("features"); List<PlatformFeatureBaseData> featuresData = GetPlatformFeaturesData(featuresElement); PlatformData platformData = new PlatformData(id, x, y, type, movementData, featuresData); return platformData; }
public PlatformWrapper(PlatformData platformData) { PlatformData = platformData; ImageSource = GetImageSource(); }