public void LapFinished() { if (bestLapFloat >= 0) { splitFloat = Mathf.Abs(bestLapFloat - lapTimer.TimerValue); elapsedMinutes = (int)splitFloat / 60; elapsedSeconds = (int)splitFloat % 60; fraction = splitFloat * 1000; fraction = (fraction % 1000); if (lapTimer.TimerValue <= bestLapFloat) { CurrentSplit = "-" + string.Format("{0:0}:{1:00}.{2:000}", elapsedMinutes, elapsedSeconds, fraction); } else { CurrentSplit = "+" + string.Format("{0:0}:{1:00}.{2:000}", elapsedMinutes, elapsedSeconds, fraction); } } if (lapTimer.TimerValue <= bestLapFloat || bestLapFloat <= 0) { bestLapFloat = lapTimer.TimerValue; elapsedMinutes = (int)bestLapFloat / 60; elapsedSeconds = (int)bestLapFloat % 60; fraction = bestLapFloat * 1000; fraction = (fraction % 1000); BestLap = string.Format("{0:0}:{1:00}.{2:000}", elapsedMinutes, elapsedSeconds, fraction); } UpdateBestLapAndSplit(); lapTimer.ResetTimer(); gc.ResetAllGates(); }
public void StartLap() { numberOfGates = 0; lapController.LapStarted = false; lapTimer.ResetTimer(); cc = FindObjectOfType <CarController>(); if (cc != null) { Destroy(cc.gameObject); } playerClone = Instantiate(PlayerCar, PlayerSpawnLocation.position, PlayerSpawnLocation.rotation) as GameObject; timingGates = FindObjectsOfType <TimingGate>(); ResetAllGates(); }
private void OnTriggerEnter2D(Collider2D collision) { if (playerKart.CheckCheckpoints()) { playerKart.ResetCheckpoints(); currentLap++; lapText.text = currentLap + " Laps"; lapTextShadow.text = currentLap + " Laps"; //this.currentLap++; //this.lapText.text = ("Laps: " + currentLap); //var myLap = storyIndex.GetCurrentLap(this.currentLap); storyManager.DisplayText(); lapTimer.ResetTimer(); Unlocks(); } else { return; } }