Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public GUIText scoreText;
- public GUIText timerText;
- private int score;
- public float seconds = 0f;
- public float minutes = 0f;
- public float moreSeconds = 0f;
- void Start()
- {
- score = 0;
- UpdateScore ();
- moreSeconds = Time.realtimeSinceStartup;
- }
- void Update()
- {
- seconds = Time.realtimeSinceStartup - moreSeconds;
- if (seconds > 60)
- {
- seconds = 0;
- moreSeconds = Time.realtimeSinceStartup;
- minutes = minutes + 1;
- }
- if (seconds < 10)
- {
- timerText.text = "Time: " + (int)minutes + " : 0" + (int)seconds;
- }
- else
- {
- timerText.text = "Time: " + (int)minutes + " : " + (int)seconds;
- }
- }
- public void AddScore(int scoreInc)
- {
- score += scoreInc;
- UpdateScore ();
- }
- void UpdateScore()
- {
- scoreText.text = "" + score;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement