Ejemplo n.º 1
0
        private void playPreLightsMessage(GameStateData currentGameState, int maxNumberToPlay)
        {
            playedPreLightsMessage = true;

            /* if ((CrewChief.gameDefinition.gameEnum == GameEnum.PCARS_NETWORK || CrewChief.gameDefinition.gameEnum == GameEnum.PCARS_64BIT ||
             *   CrewChief.gameDefinition.gameEnum == GameEnum.PCARS_32BIT) && currentGameState.SessionData.SessionNumberOfLaps <= 0 &&
             *   !playPreRaceMessagesUntilCancelled)
             * {
             *   // don't play pre-lights messages in PCars if the race is a fixed time, rather than number of laps
             *   return;
             * }*/
            CrewChiefV4.GameState.Conditions.ConditionsSample currentConditions = currentGameState.Conditions.getMostRecentConditions();
            List <QueuedMessage> possibleMessages = new List <QueuedMessage>();

            if (currentConditions != null)
            {
                Console.WriteLine("pre-start message for track temp");
                possibleMessages.Add(new QueuedMessage("trackTemp", MessageContents(ConditionsMonitor.folderTrackTempIs,
                                                                                    convertTemp(currentConditions.TrackTemperature), getTempUnit()), 0, this));
                Console.WriteLine("pre-start message for air temp");
                possibleMessages.Add(new QueuedMessage("air_temp", MessageContents(ConditionsMonitor.folderAirTempIs,
                                                                                   convertTemp(currentConditions.AmbientTemperature), getTempUnit()), 0, this));
            }
            if (currentGameState.PitData.HasMandatoryPitStop && CrewChief.gameDefinition.gameEnum != GameEnum.RF1 && CrewChief.gameDefinition.gameEnum != GameEnum.RF2_64BIT)
            {
                if (currentGameState.SessionData.SessionHasFixedTime)
                {
                    Console.WriteLine("pre-start message for mandatory stop time");
                    possibleMessages.Add(new QueuedMessage("pit_window_time", MessageContents(MandatoryPitStops.folderMandatoryPitStopsPitWindowOpensAfter,
                                                                                              TimeSpan.FromMinutes(currentGameState.PitData.PitWindowStart)), 0, this));
                }
                else
                {
                    Console.WriteLine("pre-start message for mandatory stop lap");
                    possibleMessages.Add(new QueuedMessage("pit_window_lap", MessageContents(MandatoryPitStops.folderMandatoryPitStopsPitWindowOpensOnLap,
                                                                                             currentGameState.PitData.PitWindowStart), 0, this));
                }
            }
            if (currentGameState.SessionData.Position == 1)
            {
                Console.WriteLine("pre-start message for pole");
                if (SoundCache.availableSounds.Contains(Position.folderDriverPositionIntro))
                {
                    possibleMessages.Add(new QueuedMessage("position", MessageContents(Position.folderDriverPositionIntro, Position.folderPole), 0, this));
                }
                else
                {
                    possibleMessages.Add(new QueuedMessage("position", MessageContents(Pause(200), Position.folderPole), 0, this));
                }
            }
            else
            {
                Console.WriteLine("pre-start message for P " + currentGameState.SessionData.Position);
                if (SoundCache.availableSounds.Contains(Position.folderDriverPositionIntro))
                {
                    possibleMessages.Add(new QueuedMessage("position", MessageContents(Position.folderDriverPositionIntro,
                                                                                       Position.folderStub + currentGameState.SessionData.Position), 0, this));
                }
                else
                {
                    possibleMessages.Add(new QueuedMessage("position", MessageContents(Pause(200), Position.folderStub + currentGameState.SessionData.Position), 0, this));
                }
            }
            if (currentGameState.SessionData.SessionNumberOfLaps > 0)
            {
                // check how long the race is
                if (currentGameState.SessionData.Position > 3 && currentGameState.SessionData.TrackDefinition.trackLength * currentGameState.SessionData.SessionNumberOfLaps < 20000)
                {
                    // anything less than 20000 metres worth of racing (e.g. 10 laps of Brands Indy) should have a 'make them count'
                    Console.WriteLine("pre-start message for race laps + get on with it");
                    possibleMessages.Add(new QueuedMessage("race_distance", MessageContents(currentGameState.SessionData.SessionNumberOfLaps, folderLapsMakeThemCount), 0, this));
                }
                else
                {
                    Console.WriteLine("pre-start message for race laps");

                    // TODO: need to add a "laps..." message here otherwise it just plays the number. Add the "make them count" message until this is available
                    possibleMessages.Add(new QueuedMessage("race_distance", MessageContents(currentGameState.SessionData.SessionNumberOfLaps, folderLapsMakeThemCount), 0, this));
                }
            }
            else if (currentGameState.SessionData.SessionHasFixedTime && currentGameState.SessionData.SessionTotalRunTime > 0 && currentGameState.SessionData.SessionTotalRunTime < 1800)
            {
                int minutes = (int)currentGameState.SessionData.SessionTotalRunTime / 60;
                if (currentGameState.SessionData.Position > 3 && minutes < 20)
                {
                    Console.WriteLine("pre-start message for race time + get on with it");
                    possibleMessages.Add(new QueuedMessage("race_time", MessageContents(minutes, folderMinutesYouNeedToGetOnWithIt), 0, this));
                }
                else
                {
                    Console.WriteLine("pre-start message for race time");
                    possibleMessages.Add(new QueuedMessage("race_time", MessageContents(minutes), 0, this));
                }
            }
            // now pick a random selection
            if (possibleMessages.Count > 0)
            {
                int played   = 0;
                var shuffled = possibleMessages.OrderBy(item => rand.Next());
                foreach (var message in shuffled)
                {
                    played++;
                    if (played > maxNumberToPlay)
                    {
                        break;
                    }
                    audioPlayer.playMessage(message);
                }
            }
            // TODO: in the countdown / pre-lights phase, we don't know how long the race is going to be so we can't use the 'get on with it' messages :(
        }
Ejemplo n.º 2
0
        private void playPreLightsMessage(GameStateData currentGameState, int maxNumberToPlay)
        {
            playedPreLightsMessage = true;
            if ((CrewChief.gameDefinition.gameEnum == GameEnum.PCARS_NETWORK || CrewChief.gameDefinition.gameEnum == GameEnum.PCARS_64BIT ||
                 CrewChief.gameDefinition.gameEnum == GameEnum.PCARS_32BIT) && currentGameState.SessionData.SessionNumberOfLaps <= 0)
            {
                // don't play pre-lights messages in PCars if the race is a fixed time, rather than number of laps
                return;
            }
            CrewChiefV4.GameState.Conditions.ConditionsSample currentConditions = currentGameState.Conditions.getMostRecentConditions();
            List <QueuedMessage> possibleMessages = new List <QueuedMessage>();

            if (currentConditions != null)
            {
                possibleMessages.Add(new QueuedMessage("trackTemp", MessageContents(ConditionsMonitor.folderTrackTempIs,
                                                                                    convertTemp(currentConditions.TrackTemperature), getTempUnit()), 0, null));
                possibleMessages.Add(new QueuedMessage("air_temp", MessageContents(ConditionsMonitor.folderAirTempIs,
                                                                                   convertTemp(currentConditions.AmbientTemperature), getTempUnit()), 0, null));
            }
            if (currentGameState.PitData.HasMandatoryPitStop)
            {
                if (currentGameState.SessionData.SessionHasFixedTime)
                {
                    possibleMessages.Add(new QueuedMessage("pit_window_time", MessageContents(MandatoryPitStops.folderMandatoryPitStopsPitWindowOpensAfter,
                                                                                              TimeSpan.FromMinutes(currentGameState.PitData.PitWindowStart)), 0, this));
                }
                else
                {
                    possibleMessages.Add(new QueuedMessage("pit_window_lap", MessageContents(MandatoryPitStops.folderMandatoryPitStopsPitWindowOpensOnLap,
                                                                                             currentGameState.PitData.PitWindowStart), 0, this));
                }
            }
            if (currentGameState.SessionData.Position == 1)
            {
                possibleMessages.Add(new QueuedMessage(Position.folderPole, 0, this));
            }
            else
            {
                Console.WriteLine("pre-start message for P " + currentGameState.SessionData.Position);
                possibleMessages.Add(new QueuedMessage(Position.folderStub + currentGameState.SessionData.Position, 0, this));
            }
            if (currentGameState.SessionData.SessionNumberOfLaps > 0)
            {
                possibleMessages.Add(new QueuedMessage("race_distance", MessageContents(
                                                           currentGameState.SessionData.SessionNumberOfLaps, folderLapsMakeThemCount), 0, this));
            }
            else if (currentGameState.SessionData.SessionHasFixedTime && currentGameState.SessionData.SessionTotalRunTime > 0 && currentGameState.SessionData.SessionTotalRunTime < 1800 &&
                     currentGameState.SessionData.Position > 3)
            {
                int minutes = (int)currentGameState.SessionData.SessionTotalRunTime / 60;
                possibleMessages.Add(new QueuedMessage("race_time", MessageContents(
                                                           minutes, folderMinutesYouNeedToGetOnWithIt), 0, this));
            }
            // now pick a random selection
            if (possibleMessages.Count > 0)
            {
                int played   = 0;
                var shuffled = possibleMessages.OrderBy(item => rand.Next());
                foreach (var message in shuffled)
                {
                    played++;
                    if (played > maxNumberToPlay)
                    {
                        break;
                    }
                    audioPlayer.playMessage(message);
                }
            }
            // TODO: in the countdown / pre-lights phase, we don't know how long the race is going to be so we can't use the 'get on with it' messages :(
        }