public void RequestCarTest(double gX, double gY, double eX, double eY, DirectionCar direction) { var road = new Road(new Vector(0, 50), new Vector(100, 50), 10, 100); var garage1 = new Garage(new Vector(80, 20), 10); var garage2 = new Garage(new Vector(20, 80), 10); var building = new Building(new Vector(gX, gY), 1); var city = new CityBuilder() .Road(road) .Building(garage1) .Building(garage2) .Building(building) .Build(); var group = new CustomerGroup(1, building, building); GPSSystem.RequestCar(new Destination { Road = road, Location = building.Location }, group); Assert.IsNotEmpty(city.Cars); var car = city.Cars[0]; Assert.AreEqual(eX, car.Location.X, 0.5); Assert.AreEqual(eY, car.Location.Y, 0.5); Assert.AreEqual(direction, car.Direction); }
public void Update() { var buitenRange = Group.Customers.Any(c => MathUtil.Distance(c.Location, Group.Location) > GroupRadius); if (RequestedCar) { var car = City.Instance.Cars.Find(c => MathUtil.Distance(c.Location, Group.Location) < 20); if (car == null || car.Passengers.Count > 0) { return; } Group.Customers.ForEach(customer => customer.Controller.Destroy()); MainScreen.AILoop.Unsubscribe(Update); car.Passengers.AddRange(Group.Customers); var destination = Group.Destination.Location; App.Console.Print($"Passengers entered car {car.Id} with destination {destination}", Colors.Blue); car.Destination = new Destination { Location = destination, Road = GPSSystem.NearestRoad(destination) }; car.Controller.PassengersReady(); return; } if (buitenRange) { return; } var road = GPSSystem.NearestRoad(Group.Destination.Location); GPSSystem.RequestCar(new CarSystem.Destination { Location = Group.Destination.Location, Road = road }, Group); RequestedCar = true; }