コード例 #1
0
    /// <summary>
    /// Create a new split and add it to the list of splits
    /// </summary>
    /// <returns>The split that was created</returns>
    public TimerSplit?CreateSplit()
    {
        if (IsStopped)
        {
            Debug.LogWarning("Stopwatch isn't running, not creating new split");
            return(null);
        }

        TimerSplit newSplit = GetCurrentSplit();

        if (newSplit.splitTime == new System.TimeSpan(0))
        {
            Debug.LogWarning(string.Format("Stopwatch split time is: {0}, not creating new split", newSplit.splitTime.val.ToString()));
            return(null);
        }

        if (splits.Count == 0 || (System.TimeSpan)newSplit.splitTime < splits[fastestSplitIndex].splitTime)
        {
            fastestSplitIndex = splits.Count;
        }
        if (splits.Count == 0 || (System.TimeSpan)newSplit.splitTime > splits[slowestSplitIndex].splitTime)
        {
            slowestSplitIndex = splits.Count;
        }

        splits.Add(newSplit);

        return(newSplit);
    }
コード例 #2
0
    /// <summary>
    /// Get the current split that hasn't been created yet
    /// </summary>
    public TimerSplit GetCurrentSplit()
    {
        System.TimeSpan start = new System.TimeSpan(0);
        if (splits.Count > 0)
        {
            start = splits[splits.Count - 1].splitFinish;
        }

        TimerSplit newSplit = new TimerSplit(start, currentTime);

        return(newSplit);
    }
コード例 #3
0
    /// <summary>
    /// Create a split (specific to the <see cref="Stopwatch"/> timer
    /// </summary>
    private void CreateSplit()
    {
        TimerSplit?newSplit = stopwatchTimer.CreateSplit();

        if (newSplit.HasValue && splitInformation != null)
        {
            lastSplit             = newSplit.Value;
            splitInformation.text = "";

            splitInformation.text += "Split Time: " + lastSplit.splitTime.val.ToString(@"dd\.hh\:mm\:ss\.ffff") + "\n";
            splitInformation.text += "Split Start: " + lastSplit.splitStart.val.ToString(@"dd\.hh\:mm\:ss\.ffff") + "\n";
            splitInformation.text += "Split Finish: " + lastSplit.splitFinish.val.ToString(@"dd\.hh\:mm\:ss\.ffff") + "\n";
        }
    }
コード例 #4
0
 /// <summary>
 /// Delete a specific split from the split list
 /// </summary>
 public bool DeleteSplit(TimerSplit split)
 {
     return(splits.Remove(split));
 }