// Method to handle how the Total Time is printed

        string printLap(Lap thisSector, float thisSectorTime, bool sectorValid, bool sectorGreen, Lap bestSector, List <Lap> lapList)
        {
            string text = " |";

            if (lapList.Count == 1) // If there's only one lap, color it white
            {
                text += FormatLapTime(thisSectorTime);
            }
            else if (thisSector == bestSector) // Purple
            {
                text += "<color=#ff00ffff>" + FormatLapTime(thisSectorTime) + " </color>";
            }
            else if (sectorGreen == true) // Green
            {
                text += "<color=#008000ff>" + FormatLapTime(thisSectorTime) + " </color>";
            }
            else // White
            {
                text += FormatLapTime(thisSectorTime);
            }
            if (sectorValid == false)
            {
                text += "*";
            }
            text += "\n";
            return(text);
        }
Exemple #2
0
        // Method to handle how the sectors are printed

        string getSectorString(Lap thisSector, float thisSectorTime, bool sectorValid, bool sectorGreen, Lap bestSector)
        {
            string text = " | ";

            if (thisSector == bestSector) // Purple
            {
                text += "<color=#ff00ffff>" + FormatSectorTime(thisSectorTime) + " </color>";
            }
            else if (sectorGreen == true) // Green
            {
                text += "<color=#008000ff>" + FormatSectorTime(thisSectorTime) + " </color>";
            }
            else // White
            {
                text += FormatSectorTime(thisSectorTime);
            }
            if (sectorValid == false)
            {
                text += "*";
            }
            return(text);
        }
Exemple #3
0
        // Method to update the last 10 values in the lap table with a given list of laps

        void UpdateLapTable(List <Lap> lapList)
        {
            // List of last ten laps
            List <Lap> lastTenLaps = new List <Lap>();

            foreach (Lap lap in lapList.Skip(Math.Max(0, lapList.Count) - 10))
            {
                lastTenLaps.Add(lap);
            }

            // Pointers to the laps which have the best times

            Lap bestSec1Time  = null;
            Lap bestSec2Time  = null;
            Lap bestSec3Time  = null;
            Lap bestTotalTime = null;

            // Finds the best sector/lap times and assigns them before we print them

            foreach (Lap lap in m_laps)
            {
                // If there is no best for this time
                if (bestTotalTime == null)
                {
                    // If this time is valid
                    if (lap.LapIsValid == true)
                    {
                        // This time is now the best time
                        bestTotalTime = lap;
                    }
                }
                else
                {
                    // If this time is less than the best AND its valid (or if there is no best and this lap is valid)
                    if (lap.TotalLapTime < bestTotalTime.TotalLapTime && lap.LapIsValid == true || bestTotalTime == null && lap.LapIsValid == true)
                    {
                        // If pointer is not null
                        if (bestTotalTime != null)
                        {
                            bestTotalTime.TotalIsGreen = true;
                        }
                        // Set the best lap to green and then set this lap as the best lap
                        bestTotalTime = lap;
                    }
                }

                if (bestSec1Time == null)
                {
                    if (lap.Sector1IsValid == true)
                    {
                        bestSec1Time = lap;
                    }
                }
                else
                {
                    if (lap.Sector1 < bestSec1Time.Sector1 && lap.Sector1IsValid == true || bestSec1Time == null && lap.Sector1IsValid == true)
                    {
                        if (bestSec1Time != null)
                        {
                            bestSec1Time.Sec1IsGreen = true;
                        }
                        bestSec1Time = lap;
                    }
                }
                if (bestSec2Time == null)
                {
                    if (lap.Sector2IsValid == true)
                    {
                        bestSec2Time = lap;
                    }
                }
                else
                {
                    if (lap.Sector2 < bestSec2Time.Sector2 && lap.Sector2IsValid == true || bestSec2Time == null && lap.Sector2IsValid == true)
                    {
                        if (bestSec2Time != null)
                        {
                            bestSec2Time.Sec2IsGreen = true;
                        }
                        bestSec2Time = lap;
                    }
                }
                if (bestSec3Time == null)
                {
                    if (lap.Sector3IsValid == true)
                    {
                        bestSec3Time = lap;
                    }
                }
                else
                {
                    if (lap.Sector3 < bestSec3Time.Sector3 && lap.Sector3IsValid == true || bestSec3Time == null && lap.Sector3IsValid == true)
                    {
                        if (bestSec3Time != null)
                        {
                            bestSec3Time.Sec3IsGreen = true;
                        }
                        bestSec3Time = lap;
                    }
                }
            }

            // String to store table's text values

            m_text = " Lap Number | Sector 1 | Sector 2 | Sector 3 | Total Time\n";

            // Prints the last ten laps in the m_laps dictionary

            foreach (Lap lap in lastTenLaps)
            {
                m_text += ("   Lap " + lap.LapNum).PadRight(11, ' ');

                // Sector 1
                m_text += getSectorString(lap, lap.Sector1, lap.Sector1IsValid, lap.Sec1IsGreen, bestSec1Time).PadRight(11, ' ');

                // Sector 2
                m_text += getSectorString(lap, lap.Sector2, lap.Sector2IsValid, lap.Sec2IsGreen, bestSec2Time).PadRight(11, ' ');

                // Sector 3
                m_text += getSectorString(lap, lap.Sector3, lap.Sector3IsValid, lap.Sec3IsGreen, bestSec3Time).PadRight(11, ' ');

                // LapTime
                if (lap == bestTotalTime)
                {
                    m_text += " |<color=#ff00ffff>" + FormatLapTime(lap.TotalLapTime) + "</color>";
                }
                else if (lap.TotalIsGreen == true)
                {
                    m_text += " |<color=#008000ff>" + FormatLapTime(lap.TotalLapTime) + "</color>";
                }
                else
                {
                    m_text += " |" + FormatLapTime(lap.TotalLapTime);
                }

                // Adds stars to indicate if the lap is invalid
                if (lap.LapIsValid == false)
                {
                    m_text += "**";
                }
                m_text += "\n";
            }

            // Prints the best lap as the last table entry

            m_text += "\n Best Lap   |  " +
                      FormatSectorTime(m_bestLapSector1) + " |  " +
                      FormatSectorTime(m_bestLapSector2) + " |  " +
                      FormatSectorTime(m_bestLapSector3) + " |" +
                      FormatLapTime(m_bestLap) + "\n";
        }