public static List <IRailwayPart> LocatePartConnections(IRailwayPart part) { var partConnections = new List <IRailwayPart>(); var tempList = new List <IRailwayPart>() { RailwayLocator.LocateUp(part), RailwayLocator.LocateUpRight(part), RailwayLocator.LocateRight(part), RailwayLocator.LocateDownRight(part), RailwayLocator.LocateDown(part), RailwayLocator.LocateDownLeft(part), RailwayLocator.LocateLeft(part), RailwayLocator.LocateUpLeft(part), }; foreach (var p in tempList) { if (p != null) { partConnections.Add(p); } } partConnections = partConnections.Distinct().ToList(); return(partConnections); }
public static ITrain BuildTrain(int id, string name, int maxSpeed, bool operated, IRailwayPart currentPosition) { return(new Train() { Id = id, Name = name, MaxSpeed = maxSpeed, Operated = operated, CurrentPart = currentPosition }); }
public void Move() { NextPart = CurrentPart; }