Ejemplo n.º 1
0
        static CarDetails ChangeCarForCamera(DataSample data, CarDetails driver)
        {
            if (driver == null)
                return null;

            var car = driver.Car(data);

            var otherCar = data.Telemetry.Cars.FirstOrDefault(c => c.Position == car.Position - 1);
            if( otherCar == null)
                return null;

            return otherCar.Details;
        }
Ejemplo n.º 2
0
        void SwitchToBattle(DataSample data, CarDetails newFollower, bool establishingShot = false)
        {
            if (establishingShot)
                TraceInfo.WriteLine("{0} New Battle started - Searching for a LookingAtCar camera", data.Telemetry.SessionTimeSpan);

            var cameraTypes = establishingShot ? new[] { CameraAngle.LookingAtCar } : new[] { CameraAngle.LookingInfrontOfCar, CameraAngle.LookingBehindCar, CameraAngle.LookingAtCar };

            var newFollowerPosition = newFollower.Car(data).Position;
            battleLeader = data.Telemetry.Cars.First(c => c.Position == newFollowerPosition - 1).Details;
            battleFollower = newFollower;

            car = newFollower;
            camera = cameraControl.FindACamera(cameraTypes, adjustedCamera, 2);
            if (establishingShot)
                adjustedCamera = camera;
            else
                adjustedCamera = null;

            if (camera.CameraAngle == CameraAngle.LookingBehindCar)
            {
                TraceInfo.WriteLine("{0} Changing to forward car, with reverse camera", data.Telemetry.SessionTimeSpan);
                car = battleLeader;
            }

            TraceInfo.WriteLine("{0} Changing camera to driver: {1}; camera: {2}; within {3}",
                data.Telemetry.SessionTimeSpan, 
                car.UserName, 
                camera.CameraName, 
                battleGap);
            
            cameraControl.CameraOnDriver(car.CarNumberRaw, camera.CameraNumber);
        }
        private static int? GetPositionFor(DataSample data, CarDetails carDetails)
        {
            var car = carDetails.Car(data);

            if (data.Telemetry.RaceDistance > 1.10)
                return car.Position;

            var session = data.SessionData.SessionInfo.Sessions.Qualifying();
            if (session == null || session.ResultsPositions == null)
                return null;

            var qualifyingResult = session.ResultsPositions.FirstOrDefault(p => p.CarIdx == car.CarIdx);
            if (qualifyingResult == null)
                return null;

            return (int)qualifyingResult.Position;
        }
Ejemplo n.º 4
0
        internal static bool IsInBattle(DataSample data, TimeSpan battleGap, CarDetails follower, CarDetails leader)
        {
            var leaderCar = leader.Car(data);
            var followerCar = follower.Car(data);

            if (Settings.Default.FocusOnPreferedDriver)
            {
                if (!(preferredCarIdxs.Contains(leaderCar.CarIdx) || preferredCarIdxs.Contains(followerCar.CarIdx)))
                {
                    Trace.WriteLine("Current race battle does not include drivers within preferred list");
                    return false;
                }
            }

            if (leaderCar.Position == followerCar.Position + 1)
                return false;

            var timeGap = (leaderCar.TotalDistance - followerCar.TotalDistance) * data.Telemetry.Session.ResultsAverageLapTime;
            return timeGap < battleGap.TotalSeconds;
        }
        void SwitchToBattle(DataSample data, CarDetails newFollower)
        {
            var newFollowerPosition = newFollower.Car(data).Position;
            battleLeader = data.Telemetry.Cars.First(c => c.Position == newFollowerPosition - 1).Details;
            battleFollower = newFollower;

            car = newFollower; //.Car(data).Details;
            camera = cameraControl.FindACamera(CameraAngle.LookingInfrontOfCar, CameraAngle.LookingBehindCar,  CameraAngle.LookingAtCar);
            if (camera.CameraAngle == CameraAngle.LookingBehindCar)
            {
                TraceInfo.WriteLine("{0} Changing to forward car, with reverse camera", data.Telemetry.SessionTimeSpan);
                car = battleLeader;
            }

            TraceInfo.WriteLine("{0} Changing camera to driver: {1}; camera: {2}; within {3}",
                data.Telemetry.SessionTimeSpan, 
                car.UserName, 
                camera.CameraName, 
                battleGap);
            
            cameraControl.CameraOnDriver(car.CarNumberRaw, camera.CameraNumber);
        }