예제 #1
0
        //------------------------------------------------------------------
        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]);
        }
예제 #3
0
파일: Road.cs 프로젝트: damian-666/Escape
        //------------------------------------------------------------------
        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;
            }
        }
예제 #4
0
        //------------------------------------------------------------------
        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;
            }
        }