Esempio n. 1
0
        //Methods
        public trafficlight(double aredlength, double ayellowlength, double agreenlength,
                            double atime, road aroadon,
                            double ax, double ay, int apointpointedto, double adt)
        {
            redlength    = aredlength;
            yellowlength = ayellowlength;
            greenlength  = agreenlength;
            colour       = trafficlightcolour.Green; //just to have any start-up colour
            timer        = atime;
            roadon       = aroadon;

            pointpointedto = apointpointedto;
            if (pointpointedto == 0)
            {
                pointnotpointedto = 1;
            }
            else
            {
                pointnotpointedto = 0;
            }
            location           = new point(0, 0);
            graphlocation      = new point(0, 0);
            graphblacklocation = new point(0, 0);

            calcdirectionlocation(ax, ay);

            dt          = adt;
            highlighted = false;
            //resettimer();
        }
Esempio n. 2
0
 public void update()
 {
     timer += dt;
     if (timer <= greenlength)
     {
         colour = trafficlightcolour.Green;
     }
     else if (timer > greenlength && timer <= greenlength + yellowlength)
     {
         colour = trafficlightcolour.Yellow;
     }
     else if (timer > greenlength + yellowlength && timer <= greenlength + yellowlength + redlength)
     {
         colour = trafficlightcolour.Red;
     }
     else if (timer > greenlength + yellowlength + redlength)
     {
         colour = trafficlightcolour.Green;
         resettimer();
     }
 }