Exemple #1
0
 public void stopCars(int lengthOfTrafficLight, int offsetTrafficLight)  //смещение светофора относительно формы и mainpictureBox
 {
     foreach (StripeDrawing sd in stripeDrawings)
     {
         foreach (CarDrawing cd in sd.carsDrawings)
         {
             if (cd.car.speed < 0)
             {
                 if ((cd.X < TrafficLightDrawing.getTrafficLightDrawing().COORDINATS.First.Value[1].X - offsetTrafficLight) &&
                     (cd.X + Math.Abs(cd.car.speed) >= TrafficLightDrawing.getTrafficLightDrawing().COORDINATS.First.Value[1].X - offsetTrafficLight))
                 {
                     cd.car.speed = 0;
                     cd.car.stayByTrafficLight = true;
                     cd.X = TrafficLightDrawing.getTrafficLightDrawing().COORDINATS.First.Value[1].X - offsetTrafficLight - 50;
                 }
             }
             else
             {
                 if ((cd.X > TrafficLightDrawing.getTrafficLightDrawing().COORDINATS.First.Value[0].X + lengthOfTrafficLight - offsetTrafficLight) &&
                     (cd.X - cd.car.speed <= TrafficLightDrawing.getTrafficLightDrawing().COORDINATS.First.Value[0].X + lengthOfTrafficLight - offsetTrafficLight))
                 {
                     cd.car.speed = 0;
                     cd.car.stayByTrafficLight = true;
                     cd.X = TrafficLightDrawing.getTrafficLightDrawing().COORDINATS.First.Value[0].X + lengthOfTrafficLight - offsetTrafficLight;
                 }
             }
         }
     }
 }
Exemple #2
0
 public static TrafficLightDrawing getTrafficLightDrawing()
 {
     if (trafficLightDrawing == null)
     {
         trafficLightDrawing = new TrafficLightDrawing();
     }
     return(trafficLightDrawing);
 }
Exemple #3
0
 public void clearRoadDrawing(Graphics g)
 {
     lineDrawings.Clear();
     signDrawings.Clear();
     foreach (StripeDrawing sd in stripeDrawings)
     {
         sd.carsDrawings.Clear();
     }
     TrafficLightDrawing.getTrafficLightDrawing().COORDINATS.Clear();
     stripeDrawings.Clear();
     g.Clear(Color.WhiteSmoke);
 }