Advertisement
Guest User

Untitled

a guest
Nov 1st, 2014
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. public GUIText scoreText;
  2. public GUIText timerText;
  3. private int score;
  4. public float seconds = 0f;
  5. public float minutes = 0f;
  6. public float moreSeconds = 0f;
  7.  
  8.  
  9. void Start()
  10. {
  11. score = 0;
  12. UpdateScore ();
  13. moreSeconds = Time.realtimeSinceStartup;
  14. }
  15.  
  16. void Update()
  17. {
  18. seconds = Time.realtimeSinceStartup - moreSeconds;
  19. if (seconds > 60)
  20. {
  21. seconds = 0;
  22. moreSeconds = Time.realtimeSinceStartup;
  23. minutes = minutes + 1;
  24. }
  25.  
  26. if (seconds < 10)
  27. {
  28. timerText.text = "Time: " + (int)minutes + " : 0" + (int)seconds;
  29. }
  30. else
  31. {
  32. timerText.text = "Time: " + (int)minutes + " : " + (int)seconds;
  33. }
  34. }
  35.  
  36. public void AddScore(int scoreInc)
  37. {
  38. score += scoreInc;
  39. UpdateScore ();
  40. }
  41.  
  42. void UpdateScore()
  43. {
  44. scoreText.text = "" + score;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement