123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- 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)
- }
- }
- }
|