/// <summary> /// Checks if this Rail is safe to enter for specific train. /// </summary> /// <returns>true if Rail is safe</returns> public bool IsClear() { bool clear = true; if (trains.Count > 0) { clear = false; if (station != null) { if (station.CentralStation()) { clear = true; } } } if (wagons.Count > 0) { clear = false; Rail rail = wagons[0].Gettrain().GetRail(); if (rail.GetStation() != null) { if (rail.GetStation().CentralStation()) { clear = true; } } } return(clear); }
/// <summary> /// this train has arrived on a station /// </summary> public void Arrive() { inStation = true; SetNextDestination(); rail.GetStation().AddTrain(this); }