/// <summary>
        /// Initializes a new instance of the <see cref="PedestrianIntersection"/> class.
        /// </summary>
        /// <param name="image">The <see cref="System.Drawing.Image"/>
        /// that will be used for drawing the <see cref="PedestrianIntersection"/></param>
        /// <param name="position">The <see cref="Point"/> that represents the <see cref="BaseIntersection.Position"/>
        /// of the <see cref="PedestrianIntersection"/></param>
        /// <param name="id">The ID of the <see cref="PedestrianIntersection"/>.</param>
        public PedestrianIntersection(Image image, Point position, int id) :
            base(image, position, id)
        {
            this.Pedestrians = new List<Pedestrian>();

            this.PedestrianTrafficLights = new List<PedestrianLight>();
            for (var i = 1; i <= AMOUNTPEDESTRIANLIGHTS; i++)
            {
                this.PedestrianTrafficLights.Add(new PedestrianLight(i, this));
            }

            this.RightZebra = new RightZebra(this, this.PedestrianTrafficLights[1]);
            this.LeftZebra = new LeftZebra(this, this.PedestrianTrafficLights[0]);
            this.Zebras = new List<Zebra>() {this.RightZebra, this.LeftZebra};

            this.HasPedestrianSensors = false;
            this.HasPedestrians = false;
            UI.TrafficTimer.Timer.Elapsed += (s, e) => this.CheckPedestrians();
        }
示例#2
0
 /// <summary>
 /// Scans a <see cref="Zebra"/> and checks if there are any <see cref="Pedestrian"/>.
 /// </summary>
 /// <param name="z">The <see cref="Zebra"/> to be scanned.</param>
 /// <returns><c>True</c> if there is at least 1 <see cref="Pedestrian"/> in the scanned <see cref="Zebra"/>.
 /// <c>False</c> otherwise</returns>
 public bool ScanZebra(Zebra z) => z.Pedestrians.Count > 0;