Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private var textMesh:TextMesh;
- var textTime : String;
- private var startTime;
- private var restSeconds : int;
- private var roundedRestSeconds : int;
- private var displaySeconds : int;
- private var displayMinutes : int;
- var countDownSeconds : int;
- function Start() {
- startTime = Time.time;
- textMesh = GetComponent(TextMesh);
- }
- function Update () {
- var guiTime = Time.time - startTime;
- restSeconds = countDownSeconds - (guiTime);
- if (restSeconds == 0) {
- if(Time.timeScale == 1.0){
- Time.timeScale = 0.0;
- }
- }
- if (Time.timeScale == 0.0){
- if(Input.GetButtonDown("load")){
- Application.LoadLevel(0);
- Time.timeScale = 1.0;
- }
- }
- roundedRestSeconds = Mathf.CeilToInt(restSeconds);
- displaySeconds = roundedRestSeconds % 60;
- displayMinutes = roundedRestSeconds / 60;
- textTime = String.Format ("{0:00}:{1:00}", displayMinutes, displaySeconds);
- textMesh.text = textTime;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement