private void SpawnRandomTraffic() { int randomNumber = Random.Range(0, 100); if (randomNumber < 50) //Car { TrafficObject trafficObject = CarPrefabs[Random.Range(0, CarPrefabs.Length)]; Lane lane = RegularLanes[Random.Range(0, RegularLanes.Length)]; if (!lane.QueueFull()) { lane.AddTraffic(trafficObject); } } else if (randomNumber < 60) //Bus { TrafficObject trafficObject = BusPrefabs[Random.Range(0, BusPrefabs.Length)]; Lane lane = BusLanes[Random.Range(0, BusLanes.Length)]; if (!lane.QueueFull()) { lane.AddTraffic(trafficObject); } } else if (randomNumber < 80) //Bicycle { TrafficObject trafficObject = BicyclePrefabs[Random.Range(0, BicyclePrefabs.Length)]; Lane lane = BicycleLanes[Random.Range(0, BicycleLanes.Length)]; if (!lane.QueueFull()) { lane.AddTraffic(trafficObject); } } else //Pedestrian { TrafficObject trafficObject = PedestrianPrefabs[Random.Range(0, PedestrianPrefabs.Length)]; Lane lane = PedestrianLanes[Random.Range(0, PedestrianLanes.Length)]; if (!lane.QueueFull()) { lane.AddTraffic(trafficObject); } } }