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; }
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(); }
public void setTrafficLight(TrafficLights newTr) { tr = newTr; }