Esempio n. 1
0
 private void ResetLeaderBoard()
 {
     LeaderBoard.Clear();
     foreach (var driver in Drivers)
     {
         var racer = new RaceStats()
         {
             Driver = driver
         };
         LeaderBoard.Add(racer);
     }
 }
Esempio n. 2
0
        private bool Racing(RaceStats driver)
        {
            var response = false;

            int progress = 0;;

            switch (driver.Driver.Ability)
            {
            case Driver.DrivingAbility.Novice:
                progress = rand.Next(10, 50);
                break;

            case Driver.DrivingAbility.Intermediate:
                progress = rand.Next(30, 80);
                break;

            case Driver.DrivingAbility.Advanced:
                progress = rand.Next(50, 120);
                break;

            case Driver.DrivingAbility.Expert:
                progress = rand.Next(100, 250);
                break;

            default:
                break;
            }
            if (!driver.Started)
            {
                driver.Started  = true;
                driver.LapStart = DateTime.Now;
            }
            driver.LapProgress = driver.LapProgress + progress;

            if (driver.LapProgress >= 1000)
            {
                driver.Laps++;
                driver.LapTimes.Add(DateTime.Now - driver.LapStart);
                driver.LapStart    = DateTime.Now;
                driver.LapProgress = driver.LapProgress - 100;
            }

            if (driver.Laps > FinalLap)
            {
                driver.TotalTime = DateTime.Now - Start;
                driver.Finished  = true;
                response         = true;
            }

            return(response);
        }