city-generation/Game/Assets/Scripts/Model/Road/RoadSegment.cs

93 lines
2.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
namespace TransportGame.Model.Road
{
/// <summary>
/// Represents a road segment
/// </summary>
[XmlRoot("segment")]
public class RoadSegment
{
/// <summary>
/// Gets or sets the id
/// </summary>
[XmlAttribute("id")]
public int Id { get; set; }
/// <summary>
/// Gets or sets the parent network
/// </summary>
[XmlIgnore]
public RoadNetwork ParentNetwork { get; set; }
/// <summary>
/// Gets or sets the id of the first terminal
/// </summary>
[XmlAttribute("term1")]
public int Terminal1Id { get; set; }
/// <summary>
/// Gets or sets the id of the second terminal
/// </summary>
[XmlAttribute("term2")]
public int Terminal2Id { get; set; }
/// <summary>
/// Gets or sets the first terminal
/// </summary>
[XmlIgnore]
public RoadNode Terminal1
{
get
{
return ParentNetwork.Nodes[Terminal1Id];
}
set
{
Terminal1Id = value.Id;
}
}
/// <summary>
/// Gets or sets the second terminal
/// </summary>
[XmlIgnore]
public RoadNode Terminal2
{
get
{
return ParentNetwork.Nodes[Terminal2Id];
}
set
{
Terminal2Id = value.Id;
}
}
/// <summary>
/// Gets or sets the number of lanes going from terminal 1 to terminal 2
/// </summary>
[XmlAttribute("lanesTo2")]
public int LanesTo2 { get; set; }
/// <summary>
/// Gets or sets the number of lanes going form terminal 2 to terminal 1
/// </summary>
[XmlAttribute("lanesTo1")]
public int LanesTo1 { get; set; }
/// <summary>
/// Initializes road segment
/// </summary>
public RoadSegment()
{
LanesTo1 = 1;
LanesTo2 = 1;
}
}
}