Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //var Proyectil : Rigidbody; //Proyectil que se disparara, es un rigidbody.
- var speed = 70f; //Velocidad con la que sera enviado
- static var municion : int;
- static var municiontotal : int;
- var Disparo : AudioClip;
- //var destello : boolean;
- var destello : GameObject;
- var TheDammage = 100;
- var manoanim : GameObject;
- var municionanim : GameObject;
- var Effect : Transform;
- var recargas : AudioClip;
- var Nohay : AudioClip;
- //static var posta : int;
- function Start()
- {
- destello.active = false;
- municion = 35;
- municiontotal = 175;
- posta = 5;
- }
- function Update()
- {
- if(Input.GetMouseButtonUp(0)){
- destello.active = false;
- }
- if((Input.GetButtonDown("Fire1")) && (municion <= 0) && (municiontotal > 0))
- {
- audio.PlayOneShot(Nohay);
- }
- if( Input.GetButton( "Fire1" ) && municion > 0)
- {
- destello.active = true;
- audio.PlayOneShot(Disparo);
- municion -= 1;
- // Crea el proyectil que es un Rigidbody
- //var instantiatedProyectil : Rigidbody = Instantiate( Proyectil, transform.position, transform.rotation );
- // Da la velocidad con la que el proyectil se movera
- // x= 0 y= 0 z= speed asignada
- //instantiatedProyectil.velocity = transform.TransformDirection( Vector3( 0, 0, speed ) );
- //
- // Physics.IgnoreCollision( instantiatedProyectil.collider, transform.root.collider );
- // }
- if(Input.GetMouseButton(0)){
- if (municion > 0 && municiontotal >= 0){
- destello.active = true;
- var hit : RaycastHit;
- var ray : Ray = Camera.main.ScreenPointToRay(Vector3(Screen.width*0.5, Screen.height*0.5, 0));
- if (Input.GetButton("Fire1"))
- {
- if (Physics.Raycast (ray, hit, 100))
- {
- var particleClone = Instantiate(Effect, hit.point, Quaternion.LookRotation(hit.normal));
- Destroy(particleClone.gameObject, 2);
- hit.transform.SendMessage("ApplyDammage", TheDammage, SendMessageOptions.DontRequireReceiver);
- //municion -=1;
- }
- }
- }
- }
- }
- if( Input.GetButton("Fire1") && municion <= 0)
- {
- {
- destello.active = false;
- }
- if(municion <= 0)
- {
- destello.active = false;
- }
- if( Input.GetButtonUp("Fire1"));
- {
- destello.active = false;
- }
- }
- if((Input.GetKeyDown("r") && municiontotal > 0))
- {
- audio.PlayOneShot(recargas);
- manoanim.animation.Play();
- municionanim.animation.Play();
- municion = 0;
- posta = 10;
- Invoke ("recargando",2);
- }
- //municiontotal -= 35;
- //municion +=35;
- //if (municion >35){
- //municion = 35;
- }
- function recargando()
- {
- if(municiontotal > 0)
- {
- municiontotal -= 35;
- municion +=35;
- if (municion >35){
- municion = 35;
- }
- }
- }
- function OnGUI ()
- {
- 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>");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement