Exemplo n.º 1
0
        public void AddTraficLight()
        {
            TrafficLights.State currStateLight;
            if (rnd.Next(0, 2) == 1)
            {
                currStateLight = TrafficLights.State.Red;
            }
            else
            {
                currStateLight = TrafficLights.State.Green;
            }
            TrafficLights t = new TrafficLights(currStateLight);

            Lights.Add(t);
            double onePiece = Width / (Lights.Count + 1);
            int    i        = 1;

            foreach (var l in Lights.ToArray())
            {
                l.setLocation(new Point(onePiece * i - 80, 18));
                i++;
            }
            UpdateTrafficLightCar();
            t.Notify += ChangeColorTrafficLight;
        }
Exemplo n.º 2
0
 public Walker(int height, Point currCoord, TrafficLights tr)
 {
     BeginPoint     = currCoord;
     State          = false;
     trafficLight   = tr.CurrState;
     this.Height    = height;
     this.CurrCoord = currCoord;
     Velocity       = rnd.NextDouble() * (1 - 0.7) + 0.7;
     LastVelocity   = Velocity;
     this.tr        = tr;
     tr.Notify     += ChangeColor;
     t = new Thread(new ThreadStart(Go));
     t.Start();
 }
Exemplo n.º 3
0
 public void setTrafficLight(TrafficLights newTr)
 {
     tr = newTr;
 }