Advertisement
Imeguras

Untitled

Sep 9th, 2016
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1.  
  2. using UnityEngine;
  3. using System.Collections;
  4.  
  5. public class vidaEdificioScratch : MonoBehaviour {
  6. // a posiçao para onde ir
  7. public float goX ;
  8. public float goY ;
  9. public float goZ ;
  10. //Privado so pode mexer isto
  11. private float X;
  12. private float Y;
  13. private float Z;
  14.  
  15. //vida do edificio
  16. public int getVida;
  17. private int setVida;
  18. //a ser atacado ou n
  19. public bool atacado;
  20.  
  21. void Start () {
  22.  
  23. getVida = setVida;
  24. setVida = 100;
  25. goX = X;
  26. goY = Y;
  27. goX = Z;
  28. X = transform.position.x;
  29. Y = transform.position.y;
  30. Z = transform.position.z;
  31. }
  32. void Alerta1(){
  33. if (atacado == true) {
  34. if (getVida != 0) {
  35. atacado = true;
  36. }else{
  37. if (getVida == 0) {
  38. atacado = false;
  39.  
  40. }
  41. }
  42. }
  43. }
  44.  
  45. void Update () {
  46.  
  47.  
  48. if (Input.GetKey ("a")) {
  49. setVida = setVida - 20;
  50. atacado = true;
  51. Alerta1 ();
  52. } else {
  53. if (getVida == 0) {
  54. Debug.Log ("MORRI");
  55. DestroyObject (this);
  56.  
  57. }
  58. }
  59. }
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement