import { AnimationComponent } from "cc"; import { WeaponBase } from "./WeaponBase"; export default class AutomaticFifleWeapon extends WeaponBase { constructor(leftHand:AnimationComponent,rightHand:AnimationComponent){ super(leftHand,rightHand); } Fire(bullet:boolean):void{ super.Fire(bullet); if(this.fireKey==1){ this.FireLeft(); if(bullet){ this.bulletCount--; } }else if(this.fireKey==3){ this.FireRight(); if(bullet){ this.bulletCount--; } }else{ this.FireLeft(); if(this.bulletCount>1){ this.FireRight(); } if(bullet){ this.bulletCount-=2; } } } private FireLeft():void{ this.isLeftFire=true; this.leftHand.on(AnimationComponent.EventType.FINISHED,this.FireCompleteHandler,this,true); this.leftHand.play(this.weaponConfig.handFireAnimation); this.rightHand.crossFade("Idle",0.5); this.leftGunFire.play(this.weaponConfig.gunFireAnimation); } private FireRight():void{ this.isLeftFire=false; this.rightHand.on(AnimationComponent.EventType.FINISHED,this.FireCompleteHandler,this,true); this.rightHand.play(this.weaponConfig.handFireAnimation); this.leftHand.crossFade("Idle",0.5); this.rightGunFire.play(this.weaponConfig.gunFireAnimation); } private FireCompleteHandler():void{ this.isFire=false; if(this.isLeftFire){ this.leftHand.crossFade("Idle",0.5); }else{ this.rightHand.crossFade("Idle",0.5) } } }