Advertisement
Guest User

Untitled

a guest
Jan 24th, 2015
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class GameOver : MonoBehaviour
  5. {
  6.  
  7. public float restartDelay = 5f; // Time to wait before restarting the level
  8. public Vector3 gameO; // Isso eu que criei pra uns testes
  9. public Collision collision;
  10.  
  11. Animator anim; // Reference to the animator component.
  12. float restartTimer; // Timer to count up to restarting the level
  13.  
  14.  
  15. void Awake ()
  16. {
  17. // Set up the reference.
  18. anim = GetComponent <Animator> ();
  19. gameO.y = 1.5f; // Isso eu que criei pra uns testes
  20.  
  21.  
  22.  
  23. }
  24.  
  25.  
  26. void Update ()
  27. {
  28.  
  29. if(collision.gameObject.tag == "Cube" ) // Isso eu que criei pra uns testes
  30. {
  31. // ... tell the animator the game is over.
  32. anim.SetTrigger ("GameOver");
  33.  
  34. // .. increment a timer to count up to restarting.
  35. restartTimer += Time.deltaTime;
  36.  
  37. // .. if it reaches the restart delay...
  38. if(restartTimer >= restartDelay)
  39. {
  40. // .. then reload the currently loaded level.
  41. Application.LoadLevel(Application.loadedLevel);
  42. }
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement