Advertisement
Guest User

Pepe4

a guest
Jul 22nd, 2014
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //var Proyectil : Rigidbody; //Proyectil que se disparara, es un rigidbody.
  2. var speed = 70f; //Velocidad con la que sera enviado
  3. static var  municion : int;
  4. static var  municiontotal : int;
  5. var Disparo : AudioClip;
  6. //var destello : boolean;
  7. var destello : GameObject;
  8. var TheDammage = 100;
  9. var manoanim : GameObject;
  10. var municionanim : GameObject;
  11. var Effect : Transform;
  12. var recargas : AudioClip;
  13. var Nohay : AudioClip;
  14. //static var posta : int;
  15.  
  16. function Start()
  17. {
  18. destello.active = false;
  19.    municion = 35;
  20.    municiontotal = 175;
  21.    posta = 5;
  22.  
  23.    
  24. }
  25. function Update()
  26. {
  27. if(Input.GetMouseButtonUp(0)){
  28. destello.active = false;
  29. }
  30.  
  31.  
  32.  
  33.  
  34.  
  35. if((Input.GetButtonDown("Fire1")) && (municion <= 0) && (municiontotal > 0))
  36. {
  37. audio.PlayOneShot(Nohay);
  38.  
  39. }
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  if( Input.GetButton( "Fire1" ) && municion > 0)
  46.   {
  47.  
  48.   destello.active = true;
  49.  
  50. audio.PlayOneShot(Disparo);
  51. municion -= 1;
  52.  
  53.   // Crea el proyectil que es un Rigidbody
  54.    //var instantiatedProyectil : Rigidbody = Instantiate( Proyectil, transform.position, transform.rotation );
  55.  
  56.   //  Da la velocidad con la que el proyectil se movera
  57.   //                                                              x= 0 y= 0 z= speed asignada
  58.    //instantiatedProyectil.velocity = transform.TransformDirection( Vector3( 0, 0, speed ) );
  59.  //
  60.   // Physics.IgnoreCollision( instantiatedProyectil.collider, transform.root.collider );
  61. //  }
  62.  
  63.  
  64.  
  65.     if(Input.GetMouseButton(0)){
  66.  
  67.     if (municion > 0 && municiontotal >= 0){
  68.     destello.active = true;
  69.    
  70.         var hit : RaycastHit;
  71.     var ray : Ray = Camera.main.ScreenPointToRay(Vector3(Screen.width*0.5, Screen.height*0.5, 0));
  72.    
  73.     if (Input.GetButton("Fire1"))
  74.     {
  75.         if (Physics.Raycast (ray, hit, 100))
  76.         {
  77.             var particleClone = Instantiate(Effect, hit.point, Quaternion.LookRotation(hit.normal));
  78.             Destroy(particleClone.gameObject, 2);
  79.             hit.transform.SendMessage("ApplyDammage", TheDammage, SendMessageOptions.DontRequireReceiver);
  80.             //municion -=1;
  81.         }
  82.     }
  83.            
  84.    
  85. }
  86. }
  87. }  
  88.  
  89. if( Input.GetButton("Fire1") && municion <= 0)
  90. {
  91. {
  92. destello.active = false;
  93.  
  94. }
  95.  
  96. if(municion <= 0)
  97. {
  98. destello.active = false;
  99. }
  100. if( Input.GetButtonUp("Fire1"));
  101. {
  102. destello.active = false;
  103.  
  104. }
  105.  
  106. }
  107.  
  108.  
  109. if((Input.GetKeyDown("r") && municiontotal > 0))
  110. {
  111.  
  112. audio.PlayOneShot(recargas);
  113. manoanim.animation.Play();
  114. municionanim.animation.Play();
  115.  
  116.            
  117.     municion = 0;
  118.     posta = 10;
  119.     Invoke ("recargando",2);
  120.    
  121.  }
  122.    
  123.  
  124.  
  125.    
  126.     //municiontotal -= 35;
  127.     //municion +=35;
  128.  
  129.  
  130.     //if (municion >35){
  131.     //municion = 35;
  132.  
  133.  
  134.  
  135.  
  136. }
  137. function recargando()
  138. {
  139.  
  140.  
  141. if(municiontotal > 0)
  142. {
  143.     municiontotal -= 35;
  144.     municion +=35;
  145.  
  146.  
  147.     if (municion >35){
  148.     municion = 35;
  149. }
  150.  
  151. }
  152. }
  153. function OnGUI ()
  154. {
  155. GUI.Label (Rect (150,Screen.height - 110,200,200), "<color=red><size=30>" + municiontotal + "</size></color>" + "<color=green><size=30> / </size></color>" + "<color=yellow><size=30>" + municion + "</size></color>");
  156. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement