Advertisement
Guest User

Untitled

a guest
Dec 18th, 2015
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. [RequireComponent(typeof(Rigidbody))]
  4. public class ARVORE : MonoBehaviour {
  5. public AudioClip somQueda;
  6. public int TempoDeQueda = 8;
  7. public int VIDA;
  8. private Rigidbody corpoRigido;
  9. private float cronometro;
  10. private bool comecarContagem;
  11. public GameObject Madeiras;
  12. public GameObject[] localMadeiras;
  13. public int minMadeiras = 1, maxMadeiras = 5;
  14. void Start () {
  15.  
  16. corpoRigido = GetComponent <Rigidbody> ();
  17. corpoRigido.useGravity = true;
  18. corpoRigido.isKinematic = true;
  19. VIDA = 100;
  20. cronometro = 0;
  21. comecarContagem = false;
  22. corpoRigido.mass = 250;
  23. }
  24. void Update () {
  25. if (VIDA <= 0) {
  26. corpoRigido.isKinematic = false;
  27. corpoRigido.AddForce(Random.Range (-20,20)*75,0,Random.Range (-20,20)*75);
  28. comecarContagem = true;
  29. GetComponent<AudioSource> ().PlayOneShot(somQueda);
  30.  
  31.  
  32.  
  33. }
  34. if (comecarContagem == true) {
  35. cronometro += Time.deltaTime;
  36.  
  37.  
  38. }
  39.  
  40.  
  41. if (cronometro >= TempoDeQueda) {
  42. cronometro = 0;
  43.  
  44. int quantidade = Random.Range (minMadeiras,maxMadeiras);
  45. if(quantidade > localMadeiras.Length){
  46. quantidade = localMadeiras.Length;
  47.  
  48. }
  49. for(int x = 0; x < quantidade; x++){
  50. Instantiate(Madeiras,localMadeiras[x].transform.position,transform.rotation);
  51.  
  52. }
  53. Destroy(gameObject);
  54.  
  55. }
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement