Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import GunBehaviour;
  2.  
  3. private var blah = 1<<8;
  4. private var mask = ~blah;
  5. private var isShooting : boolean = false;
  6. private var currentGun : GunBehaviour;
  7. var guns : GunBehaviour[];
  8.  
  9. function Start() {
  10.     currentGun = Instantiate(guns[0],transform.position,transform.rotation);
  11.     currentGun.transform.parent = transform;
  12.     currentGun.OnChangeTo();
  13. }
  14.  
  15. function Update() {
  16.     if(Input.GetMouseButton(0)) {
  17.         var hit : RaycastHit;
  18.         var shot = Physics.Raycast(Camera.main.transform.position,Camera.main.transform.forward,hit,100.0,mask);
  19.         if (Time.timeScale!=0) {
  20.             if (!isShooting) {
  21.                 currentGun.OnShootEnter();
  22.                 isShooting = true;
  23.             }
  24.             currentGun.OnShootStay(shot,hit);
  25.         }
  26.     } else {
  27.         if (isShooting) {
  28.             currentGun.OnShootExit();
  29.             isShooting = false;
  30.         }
  31.     }
  32. }
  33.  
  34. function change(g:int) {
  35.     currentGun.OnChangeFrom();
  36.     if (currentGun.particleEmitter!=null) {
  37.         currentGun.GetComponent(ParticleAnimator).autodestruct = true;
  38.         currentGun.particleEmitter.emit = false;
  39.     } else {
  40.         Destroy(currentGun.gameObject);
  41.     }
  42.     currentGun = Instantiate(guns[g],transform.position,transform.rotation);
  43.     currentGun.transform.parent = transform;
  44.     currentGun.OnChangeTo();
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement