/// <summary> /// The main simulate method /// </summary> public void Simulate() { Thread.Sleep(5000); // Wait for world to be loaded, improving performance running = true; // Fetch airplane Airplane a = w.GetAirplanes()[0]; // Fetch robots List <Robot> robots = w.GetRobots(); // Kickstart program FetchAllSuitcases(robots); while (running) { if (transportSuitcasesCount == 4) { timesFetchedSuitcases++; int toAdd = 0; if (timesFetchedSuitcases % 2 == 0) { toAdd = 4; } // Load into airplane List <Coordinate> occupationList = w.GetOccupationList(); for (int i = 0; i < 4; i++) { Coordinate c = occupationList[i + toAdd]; Suitcase s = c.GetSuitcase(); s.Move(100, 100, 100); } // Airplane liftoff a.AddTask(new AirplaneMove(new Coordinate(70, 4.3, -15), true)); // point 3 a.AddTask(new AirplaneMove(new Coordinate(125, 59, -15), true, true)); // point 4 a.AddTask(new AirplaneMove(new Coordinate(-50, 4.3, -15), false, true)); // point 1 a.AddTask(new AirplaneMove(new Coordinate(15, 4.3, -15))); // point 2 transportSuitcasesCount = 0; } if (a.GetLanded()) { timesLanded++; // Move suitcases to A List <Coordinate> occupationList = w.GetOccupationList(); int toAdd = 0; if (timesFetchedSuitcases % 2 == 0) { toAdd = 4; } else { this.startAt = 4; } for (int i = 0; i < 4; i++) { Coordinate c = occupationList[i + toAdd]; Suitcase s = c.GetSuitcase(); s.Move(15, 0, 5); // Move to A } PlaceAllSuitcases(robots, true, toAdd); a.SetLanded(false); if (timesLanded == 2) { // Redo simulation FetchAllSuitcases(robots); timesLanded = 0; } } if (this.startAt == 4) { FetchAllSuitcases(robots, startAt); startAt = 0; } UpdateFrame(); } }