private Vehicle GenerateVehicleWithDriver(int roadwayNumber) { var direction = roadwayNumber < Configuration.TunnelConfiguration.RoadwaysConfiguration.Count / 2 ? TravelDirection.RIGHT_TO_LEFT : TravelDirection.LEFT_TO_RIGHT; var vehicle = VehicleConfigurationToVehicleConverter.Convert(GetVehicleConfiguration(), direction); vehicle.Driver = PersonConfigurationToPersonConverter.Convert(GetPersonConfiguration()); vehicle.X = direction == TravelDirection.LEFT_TO_RIGHT ? -vehicle.Icon.Width : SceneRenderer.ContextWidth; vehicle.Y = roadwayWidth * roadwayNumber + halfRoadwayWidth;// - vehicle.Icon.Height / 2; return(vehicle); }
private void PeopeleLeaveTheVehicle(Vehicle vehicle) { if (vehicle.PassengersNumber != 0) { var driver = vehicle.Driver; driver.IsInVehicle = false; driver.X = vehicle.X; driver.Y = vehicle.Y - vehicle.Icon.Height / 2; // driver will be dead by default // scene.Tunnel.People.Add(driver); for (int i = 0, delta = 10; i < vehicle.PassengersNumber - 1; i++, delta += 10) { var person = PersonConfigurationToPersonConverter.Convert(GetPersonConfiguration()); person.X = vehicle.X + delta; person.Y = vehicle.Y - vehicle.Icon.Height / 2; scene.Tunnel.People.Add(person); } vehicle.PassengersNumber = 0; } }