Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import GunBehaviour;
- private var blah = 1<<8;
- private var mask = ~blah;
- private var isShooting : boolean = false;
- private var currentGun : GunBehaviour;
- var guns : GunBehaviour[];
- function Start() {
- currentGun = Instantiate(guns[0],transform.position,transform.rotation);
- currentGun.transform.parent = transform;
- currentGun.OnChangeTo();
- }
- function Update() {
- if(Input.GetMouseButton(0)) {
- var hit : RaycastHit;
- var shot = Physics.Raycast(Camera.main.transform.position,Camera.main.transform.forward,hit,100.0,mask);
- if (Time.timeScale!=0) {
- if (!isShooting) {
- currentGun.OnShootEnter();
- isShooting = true;
- }
- currentGun.OnShootStay(shot,hit);
- }
- } else {
- if (isShooting) {
- currentGun.OnShootExit();
- isShooting = false;
- }
- }
- }
- function change(g:int) {
- currentGun.OnChangeFrom();
- if (currentGun.particleEmitter!=null) {
- currentGun.GetComponent(ParticleAnimator).autodestruct = true;
- currentGun.particleEmitter.emit = false;
- } else {
- Destroy(currentGun.gameObject);
- }
- currentGun = Instantiate(guns[g],transform.position,transform.rotation);
- currentGun.transform.parent = transform;
- currentGun.OnChangeTo();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement