//------------------------------------------------------------------ private static Car GetRandomCarOnLane(Lane lane) { var carID = Lane.Random.Next (lane.CarsQuantity); // If Lane hasn't append cars yet if (carID >= lane.Cars.Count) carID = lane.Cars.Count - 1; return lane.Cars[carID]; }
//------------------------------------------------------------------ private static Car GetRandomCarOnLane(Lane lane) { var carID = Lane.Random.Next(lane.CarsQuantity); // If Lane hasn't append cars yet if (carID >= lane.Cars.Count) { carID = lane.Cars.Count - 1; } return(lane.Cars[carID]); }
//------------------------------------------------------------------ private void CreateLanes() { lanes = new List <Lane>(); Lane left = null; foreach (var index in Enumerable.Range(0, LanesQuantity)) { Lane lane = new Lane(this, index); lane.CarsQuantity = Lane.Random.Next(Lane.MinimumCars, Lane.MaximumCars); // Set Lane's neiborhoods if (index != 0 && left != null) { lane.Left = left; lane.Left.Right = lane; } Add(lane); lanes.Add(lane); left = lane; } }
//------------------------------------------------------------------ private void CreateLanes() { lanes = new List <Lane>(); Lane left = null; foreach (var index in Enumerable.Range (0, LanesQuantity)) { Lane lane = new Lane (this, index); lane.CarsQuantity = Lane.Random.Next (Lane.MinimumCars, Lane.MaximumCars); // Set Lane's neiborhoods if (index != 0 && left != null) { lane.Left = left; lane.Left.Right = lane; } Add (lane); lanes.Add (lane); left = lane; } }