Advertisement
Guest User

Untitled

a guest
Apr 5th, 2012
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. var gameTime : float = 60;
  2. var scoreHC : int = 0;
  3. var lives : int = 1;
  4.  
  5. function Start() {
  6. InvokeRepeating ("Countdown", 1.0, 1.0);
  7. }
  8.  
  9. function Update () {
  10. if(lives <= 0) {
  11. Application.LoadLevel("Lose");
  12. lives = 1;
  13. gameTime = 60;
  14. PlayerPrefs.SetInt("SCOREHC", scoreHC);
  15. scoreHC = 0;
  16. }
  17.  
  18. if(gameTime <= 0) {
  19. Application.LoadLevel("win");
  20. lives = 1;
  21. gameTime = 60;
  22. PlayerPrefs.SetInt("SCOREHC", scoreHC);
  23. scoreHC = 0;
  24. }
  25.  
  26. print("Score: " + scoreHC);
  27. }
  28.  
  29. function AddScoreHC() {
  30. scoreHC += 1;
  31. }
  32.  
  33. function LoseLife() {
  34. lives -= 1;
  35. }
  36.  
  37. function AddLife() {
  38. lives += 1;
  39. }
  40.  
  41. function Countdown() {
  42. if(--gameTime == 0) {
  43. CancelInvoke("Countdown");
  44. }
  45. }
  46.  
  47. function OnGUI () {
  48. GUI.Label(Rect(10, 10, 100, 20), "Score: " + scoreHC);
  49. GUI.Label(Rect(10, 25, 100, 25), "Lives left: " + lives);
  50. GUI.Label(Rect(Screen.width - 100, 10, 100, 50), "Time left: " + gameTime);
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement