示例#1
0
        private void LocalVehicle_Finished(object sender, FinishedEventArgs e)
        {
            if (e.Type != RaceEndType.Finished)
            {
                return;
            }

            var finished = new SplitTime(_previousCheckpointTimes.LastOrDefault(), TimeSpan.FromMilliseconds(e.FinalTime), -1);

            _previousCheckpointTimes.Add(finished);

            if ((bool)Settings["SaveTimes"])
            {
                if (_bestTime == TimeSpan.Zero || finished.Total < _bestTime)
                {
                    WriteTimes("pb.txt");
                }
                if ((bool)Settings["SaveAllTimes"])
                {
                    WriteTimes(finished.RenderFilename());
                }
            }

            _previousCheckpointTimes.Clear();
        }
示例#2
0
 public void SetTimeBarText(SplitTime previousBest, float delay)
 {
     if (previousBest.Rounded.Total < Rounded.Total)
     {
         LocalVehicle.Screen.SetTimeBarText("+" + Render(Rounded.Total - previousBest.Rounded.Total, 2, ':') + "  ", "#FF0000", delay);
     }
     else if (previousBest.Rounded.Total > Rounded.Total)
     {
         LocalVehicle.Screen.SetTimeBarText("-" + Render(previousBest.Rounded.Total - Rounded.Total, 2, ':') + " ", "#00FF00", delay);
     }
     else
     {
         SetTimeBarText(delay);
     }
 }
示例#3
0
        public SplitTime(SplitTime oldTime, TimeSpan newTime, int checkpointId)
        {
            _old        = oldTime.Total;
            _new        = newTime;
            _checkpoint = checkpointId;

            if (_old == TimeSpan.Zero)
            {
                _lastCheckpoint = -1;
            }
            else
            {
                _lastCheckpoint = oldTime.CheckpointId;
            }
        }
示例#4
0
        public string RenderHud(SplitTime previousBest)
        {
            var output = new System.Text.StringBuilder();

            output.Append("<size=25>");

            if (previousBest.Rounded.Total < Rounded.Total)
            {
                output.Append("<color=#de6262ff>");
            }
            else if (previousBest.Rounded.Total > Rounded.Total)
            {
                output.Append("<color=#6be584ff>");
            }

            output.Append(Render(Total));

            if (previousBest.Rounded.Total != Rounded.Total)
            {
                output.Append("</color>");
            }

            output.Append("</size>  ");

            if (LastCheckpointId == previousBest.LastCheckpointId)
            {
                if (previousBest.Rounded.Split < Rounded.Split)
                {
                    output.Append("<color=#de6262ff>");
                }
                else if (previousBest.Rounded.Split > Rounded.Split)
                {
                    output.Append("<color=#6be584ff>");
                }
            }

            output.Append(Render(Split));

            if (LastCheckpointId == previousBest.LastCheckpointId && previousBest.Rounded.Split != Rounded.Split)
            {
                output.Append("</color>");
            }

            return(output.ToString());
        }
示例#5
0
        private void LocalVehicle_CheckpointPassed(object sender, CheckpointHitEventArgs e)
        {
            var now = new SplitTime(_previousCheckpointTimes.LastOrDefault(), Race.ElapsedTime, e.CheckpointIndex);

            _previousCheckpointTimes.Add(now);

            if (_bestCheckpointTimes.ContainsKey(e.CheckpointIndex))
            {
                now.SetTimeBarText(_bestCheckpointTimes[e.CheckpointIndex], 1.25f);
            }
            else
            {
                now.SetTimeBarText(1.25f);
            }

            var times = GetTimeStrings();

            times.Insert(0, "<size=57><color=#6be584ff>Regenerating</color></size>");
            HudLinesDownward(2.0f, times);
        }
示例#6
0
        private Dictionary <int, SplitTime> ReadTimes(string filename)
        {
            var output = new Dictionary <int, SplitTime>();

            try
            {
                if (File.Exists(Path.Combine(FileSystem.DirectoryPath, Path.Combine(_trackFolder, filename))))
                {
                    using (var sr = new StreamReader(Path.Combine(FileSystem.DirectoryPath, Path.Combine(_trackFolder, filename))))
                    {
                        string[] line;
                        var      oldCheckpoint = -1;

                        while ((line = sr.ReadLine()?.Split('\t')) != null)
                        {
                            var total      = TimeSpan.Parse("00:" + line[0]);
                            var split      = TimeSpan.Parse("00:" + line[1]);
                            var checkpoint = -1;
                            if (line.Length == 3)
                            {
                                checkpoint = int.Parse(line[2]);
                            }

                            output[checkpoint] = new SplitTime(total - split, total, checkpoint, oldCheckpoint);

                            oldCheckpoint = checkpoint;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"SplitTimes: Couldn't load times. Exception below:\n{ex}");
            }

            return(output);
        }