timing finish line etc
This commit is contained in:
1 parent
ccd1a3e3a3
commit
8eec2aaf45
48 files changed
+4465
-5830
No files matched your search
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
public class StartFinishLine : MonoBehaviour {
|
||||
ShipControls ship;
|
||||
|
||||
// timing...
|
||||
|
||||
List<double> lapTimes;
|
||||
List<double> sectorTimes;
|
||||
double lapStart;
|
||||
|
||||
void Awake() {
|
||||
Debug.LogError("SpaceRace!");
|
||||
Debug.LogError("WSAD - Strafe");
|
||||
Debug.LogError("Mouse 1 - Thrust");
|
||||
Debug.LogError("Mouse 2 - Decelerate");
|
||||
Debug.LogError("Space - Respawn");
|
||||
Debug.LogError("F10 - Exit");
|
||||
|
||||
ship = GetComponent<ShipControls>();
|
||||
lapTimes = new List<double>();
|
||||
sectorTimes = new List<double>();
|
||||
}
|
||||
|
||||
void OnTriggerEnter(Collider other) {
|
||||
// our timer is not running
|
||||
// either because we haven't started racing yet
|
||||
// or we respawned
|
||||
if (lapStart == 0)
|
||||
return;
|
||||
|
||||
// we are completing a lap
|
||||
Debug.LogError("Lap Complete " + other.gameObject.name);
|
||||
double lapTime = Time.timeAsDouble - lapStart;
|
||||
lapTimes.Add(lapTime);
|
||||
|
||||
TimeSpan lapSpan = TimeSpan.FromSeconds(lapTime);
|
||||
Debug.LogError("Time " + lapSpan.ToString("c"));
|
||||
}
|
||||
|
||||
void OnTriggerExit(Collider other) {
|
||||
Debug.LogError("Starting Lap " + other.gameObject.name);
|
||||
lapStart = Time.timeAsDouble;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user