/* * Finds out if the time it has recieved is better than the previous best time, * it also figures out which level the time belongs to. */ public void setTime(int t) { time = t; switch (level) { case 1: if (time < bestTime1) { bestTime1 = time; headerText.newBestTime("Best! : " + bestTime1.ToString()); info.setInfoText("New best time on level " + level); } break; case 2: if (time < bestTime2) { bestTime2 = time; headerText.newBestTime("Best! : " + bestTime2.ToString()); info.setInfoText("New best time on level " + level); } break; case 3: if (time < bestTime3) { bestTime3 = time; headerText.newBestTime("Best! : " + bestTime3.ToString()); info.setInfoText("New best time on level " + level); } break; case 4: if (time < bestTime4) { bestTime4 = time; headerText.newBestTime("Best! : " + bestTime4.ToString()); info.setInfoText("New best time on level " + level); GameObject player = GameObject.Find("Player"); player.transform.position = new Vector3(2.73f, 0.3f, 9.71f); player.transform.rotation = Quaternion.Euler(360, 170, 0); } break; default: break; } }
// Update is called once per frame void Update() { if (timerStarted) { time = time + Time.deltaTime; headerText.displayTime((int)time); info.setInfoText("Timer started, get to the finish line as quickly as possible"); } }