Exemplo n.º 1
0
        public void Run(bool mapTrack, bool positionTrigger)
        {
            bool running = false;

            int countdown = 4000;
            int safety    = 200;

            float lastTime = graphics.SessionTimeLeft;

            while (true)
            {
                physics    = ReadPhysics();
                graphics   = ReadGraphics();
                staticInfo = ReadStaticInfo();
                cars       = ReadCars();

                bool wait = true;

                if (mapTrack)
                {
                    if (!writeCoordinates())
                    {
                        break;
                    }
                }
                else if (positionTrigger)
                {
                    checkCoordinates();
                }
                else
                {
                    if (!running)
                    {
                        running = ((lastTime != graphics.SessionTimeLeft) || (countdown-- <= 0) || (physics.SpeedKmh >= 200));
                    }

                    if (running)
                    {
                        if (physics.SpeedKmh > 120)
                        {
                            safety = 200;
                        }

                        if ((safety-- <= 0) && (waitYellowFlagState > 0))
                        {
                            running = false;
                        }
                    }
                    else if ((safety <= 0) && (physics.SpeedKmh > 120))
                    {
                        running = true;
                        safety  = 200;
                    }

                    if (running)
                    {
                        if ((graphics.Status == AC_STATUS.AC_LIVE) && (graphics.IsInPit == 0) && (graphics.IsInPitLane == 0))
                        {
                            if (!checkFlagState() && !checkPositions())
                            {
                                wait = !checkPitWindow();
                            }
                            else
                            {
                                wait = false;
                            }
                        }
                        else
                        {
                            longitudinalRearDistance = 5;

                            lastSituation     = CLEAR;
                            carBehind         = false;
                            carBehindLeft     = false;
                            carBehindRight    = false;
                            carBehindReported = false;

                            lastFlagState = 0;
                        }
                    }
                }

                if (positionTrigger)
                {
                    Thread.Sleep(10);
                }
                else if (wait)
                {
                    Thread.Sleep(50);
                }
            }

            Close();
        }
Exemplo n.º 2
0
 public CarsEventArgs(Cars cars)
 {
     this.Cars = cars;
 }