using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml.Serialization; namespace TransportGame.Model.Road { /// /// Road node /// [XmlRoot("node")] public class RoadNode { /// /// Gets or sets a unique identifier for this node /// [XmlAttribute("id")] public int Id { get; set; } /// /// Gets or sets the X coordinate of the node /// [XmlAttribute("x")] public float X { get; set; } /// /// Gets or sets the Y coordinate of the node /// [XmlAttribute("y")] public float Y { get; set; } /// /// Gets or sets the adjacent articulation segment IDs /// [XmlArray("articulationSegments")] [XmlArrayItem("id")] public List ArticulationSegmentIds { get; set; } /// /// Gets or sets the adjacent articulation segment IDs /// [XmlArray("intersectionSegments")] [XmlArrayItem("id")] public List IntersectionSegmentIds { get; set; } /// /// Gets or sets the parent network /// [XmlIgnore] public RoadNetwork ParentNetwork { get; set; } /// /// Gets the adjacent articulation segments /// [XmlIgnore] public IEnumerable ArticulationSegments { get { return ArticulationSegmentIds.Select(id => ParentNetwork.ArticulationSegments[id]); } } /// /// Gets the adjacent setments /// [XmlIgnore] public IEnumerable Segments { get { return IntersectionSegmentIds.Select(id => ParentNetwork.ArticulationSegments[id]); } } /// /// Initializes the node /// public RoadNode() { ArticulationSegmentIds = new List(); IntersectionSegmentIds = new List(); } } }