private void LoadLine() { if (tt.Stations.Count != 0) { return; } if (info.Timetable.Type == TimetableType.Network) { throw new Exception("Streckendateien können bei Netzwerk-Fahrplänen nicht geladen werden!"); } IImport timport = new XMLImport(); IImport simport = new NonDefaultFiletypes.XMLStationsImport(); using (var ofd = new OpenFileDialog()) { ofd.AddLegacyFilter(timport.Filter, simport.Filter); if (ofd.ShowDialog(this) == DialogResult.Ok) { IImport import = Path.GetExtension(ofd.FileName) == ".fpl" ? timport : simport; var ntt = import.Import(ofd.FileName, info); foreach (var station in ntt.Stations) { tt.AddStation(station, Timetable.LINEAR_ROUTE_ID); } // ntt will be destroyed by decoupling stations, do not use afterwards! } } UpdateStations(); }
private static void GeneralOvertakeTest(Stream s) { var tt = new XMLImport().Import(s, new DummyPluginInterface()); var analyzer = new IntersectionAnalyzer(tt); var station = tt.Stations.Single(st => st.SName == "B"); // Overlap at end { var probeTrain = tt.Trains.Single(t => t.TName == "P-overlap-end"); var crossingWith = analyzer.OvertakeAtStation(probeTrain, station).ToArray(); Assert.AreEqual(1, crossingWith.Length); Assert.AreEqual("C-overlap-end", crossingWith[0].TName); Assert.AreEqual(probeTrain, analyzer.OvertakeAtStation(crossingWith[0], station).Single()); } // Overlap at begin { var probeTrain = tt.Trains.Single(t => t.TName == "P-overlap-begin"); var crossingWith = analyzer.OvertakeAtStation(probeTrain, station).ToArray(); Assert.AreEqual(1, crossingWith.Length); Assert.AreEqual("C-overlap-begin", crossingWith[0].TName); Assert.AreEqual(probeTrain, analyzer.OvertakeAtStation(crossingWith[0], station).Single()); } // Overlap in the middle { var probeTrain = tt.Trains.Single(t => t.TName == "P-overlap-middle"); var crossingWith = analyzer.OvertakeAtStation(probeTrain, station).ToArray(); Assert.AreEqual(1, crossingWith.Length); Assert.AreEqual("C-overlap-middle", crossingWith[0].TName); Assert.AreEqual(probeTrain, analyzer.OvertakeAtStation(crossingWith[0], station).Single()); } // Second train with no stop time { var probeTrain = tt.Trains.Single(t => t.TName == "P-no-minutes"); var crossingWith = analyzer.OvertakeAtStation(probeTrain, station).ToArray(); Assert.AreEqual(1, crossingWith.Length); Assert.AreEqual("C-no-minutes", crossingWith[0].TName); Assert.AreEqual(probeTrain, analyzer.OvertakeAtStation(crossingWith[0], station).Single()); } // Second train with no stop time (two trains) { var probeTrain = tt.Trains.Single(t => t.TName == "P-no-minutes-double"); var crossingWith = analyzer.OvertakeAtStation(probeTrain, station).ToArray(); Assert.AreEqual(2, crossingWith.Length); Assert.AreEqual("C-no-minutes-double1", crossingWith[0].TName); Assert.AreEqual("C-no-minutes-double2", crossingWith[1].TName); } }
static void Main(string[] args) { JSONImport.ImportTowns(); XMLImport.ImportCinemas(); XMLImport.ImportAuditoriums(); JSONImport.ImportCategories(); XMLImport.ImportMovies(); JSONImport.ImportActors(); JSONImport.ImportScreenings(); JSONImport.ImportSeats(); }
// No ComplexNetworkOvertakeTest with test_overtake2.fpl as overtaking can only happen on the same route. private static void GeneralTrapezTest(Stream s) { var tt = new XMLImport().Import(s, new DummyPluginInterface()); var analyzer = new IntersectionAnalyzer(tt); var station = tt.Stations.Single(st => st.SName == "B"); // Normal { var probeTrain = tt.Trains.Single(t => t.TName == "P-normal"); var trapez0 = analyzer.TrapezAtStation(probeTrain, station); Assert.AreEqual(0, trapez0.IntersectingTrainsStopping.Length); Assert.IsTrue(trapez0.IsStopping); Assert.AreEqual(Days.Parse("1111100"), trapez0.StopDays); } // Normal (reverse) { var probeTrain = tt.Trains.Single(t => t.TName == "C-normal"); var trapez1 = analyzer.TrapezAtStation(probeTrain, station); Assert.AreEqual(1, trapez1.IntersectingTrainsStopping.Length); Assert.AreEqual("P-normal", trapez1.IntersectingTrainsStopping[0].TName); Assert.IsFalse(trapez1.IsStopping); Assert.AreEqual(Days.Parse("1111100"), trapez1.StopDays); } // Single train { var probeTrain = tt.Trains.Single(t => t.TName == "P-single"); var trapez0 = analyzer.TrapezAtStation(probeTrain, station); Assert.AreEqual(0, trapez0.IntersectingTrainsStopping.Length); Assert.IsTrue(trapez0.IsStopping); Assert.AreEqual("1111100", trapez0.StopDays.ToBinString()); } // Multiple { var probeTrain = tt.Trains.Single(t => t.TName == "P-multiple"); var trapez0 = analyzer.TrapezAtStation(probeTrain, station); Assert.AreEqual(1, trapez0.IntersectingTrainsStopping.Length); Assert.AreEqual("C-multiple", trapez0.IntersectingTrainsStopping[0].TName); Assert.IsTrue(trapez0.IsStopping); Assert.AreEqual(Days.Parse("1111100"), trapez0.StopDays); var trapez1 = analyzer.TrapezAtStation(trapez0.IntersectingTrainsStopping[0], station); Assert.AreEqual(2, trapez1.IntersectingTrainsStopping.Length); Assert.AreEqual("P-multiple", trapez1.IntersectingTrainsStopping[0].TName); Assert.IsTrue(trapez1.IsStopping); Assert.AreEqual(Days.Parse("1111100"), trapez1.StopDays); } }
//Start level //Keep screen Black //Load in level //Reset Start Position //Fade to regular //GameLoop //End Level //Fade to black //Return to start of this. private void Start() { countDownTimer.SetActive(false); audioSource = GetComponent <AudioSource>(); mainCamera = Camera.main; levelImporter = GetComponent <XMLImport>(); StartLevelProcess(); if (backgroundMusic != null) { audioSource.clip = backgroundMusic; audioSource.Play(); } }
public void AmbiguousRoutesTest() { var text = Load("test_ambiguous_routes.fpl"); using (var s = PrepareTemp(text)) { var pi = new DummyPluginInterface(); pi.Registry.Register <ITimetableInitAction>(new BugFixInitAction()); var tt = new XMLImport().Import(s, pi); Assert.IsNotNull(tt); Assert.IsTrue(pi.HadWarning("enthält zusammengfefallene Strecken") > 0); } }
public void DuplicateStationIdTest() { var text = Load("test_duplicate_ids.fpl"); using (var s = PrepareTemp(text)) { var pi = new DummyPluginInterface(); pi.Registry.Register <ITimetableInitAction>(new BugFixInitAction()); var tt = new XMLImport().Import(s, pi); Assert.IsNotNull(tt); Assert.IsTrue(pi.HadWarning("Verknüpfungen zu Folgezügen aufgehoben werden") > 0); Assert.AreEqual(1, tt.Transitions.Count); Assert.AreEqual(null, tt.GetTransition("10")); // Transitions got removed. Assert.AreEqual("69724", tt.GetTrainById(12).TName); // One id got changed. Assert.AreEqual(5, tt.Trains.Count); // We still have 5 trains. Assert.AreEqual(5, tt.Trains.Select(t => t.Id).Distinct().Count()); // We have 5 different IDs now. } }
public ImportEngine() { this.jsonImport = new JSONImport(); this.xmlImport = new XMLImport(); }