123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- import { _decorator, Component, Node, AnimationComponent } from 'cc';
- import { SoundManager } from '../../../../engines/sounds/SoundManager';
- import { GameController } from '../GameController';
- import { WeaponBase } from './WeaponBase';
- const { ccclass, property } = _decorator;
- export class SingleShotWeapon extends WeaponBase {
- constructor(leftHand:AnimationComponent,rightHand:AnimationComponent){
- super(leftHand,rightHand);
- }
- Fire(bullet:boolean):void{
- super.Fire(bullet);
- if(this.fireKey==1){
- this.FireLeft();
- }else if(this.fireKey==3){
- this.FireRight();
- }else{
- this.isLeftFire=!this.isLeftFire;
- if(this.isLeftFire){
- this.FireLeft();
- }else{
- this.FireRight();
- }
- }
- if(bullet){
- this.bulletCount--;
- }
- }
- private FireLeft():void{
- GameController.single.WeaponAttack();
- 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);
- SoundManager.single.PlaySound("WeaponLeft",this.weaponConfig.fireSound,false,true);
- }
- private FireRight():void{
- GameController.single.WeaponAttack();
- 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);
- SoundManager.single.PlaySound("WeaponRight",this.weaponConfig.fireSound,false,true);
- }
-
- private FireCompleteHandler():void{
- this.isFire=false;
- if(this.isLeftFire){
- this.leftHand.crossFade("Idle",0.5);
- }else{
- this.rightHand.crossFade("Idle",0.5)
- }
- }
- }
|