import { _decorator, Node} from 'cc'; import { PoolManager } from '../../core/manager/PoolManager'; import { Game } from '../../game/Game'; import { PlayerCamera } from '../../game/PlayerCamera'; import { GunBase } from '../base/GunBase'; import { Enemy } from '../../game/Enemy'; import { Player } from '../../game/Player'; const { ccclass, property } = _decorator; //1003 盾牌兵盾牌 不存在子弹 @ccclass('Gun12') export class Gun12 extends GunBase { @property({type: Node,tooltip:"开盾特效节点"}) shieldEffect: Node = null; //盾牌拥有者 public holder: Player|Enemy = null; //开盾结束回调 public endCb: Function = null!; //开盾回调结束 public ammoCb: Function = null; //触发间隔时间统计 private curTime: number = 0; //是否是第一次开盾 private isFristShield: boolean = false; //所有的烟雾 public smokes: Array = []! onLoad() { this.muzzleNode.active = false; } /** * 设置开盾的数据 * @param data 开盾的数据 * @param endCB 结束回调 * @param ammoCb 换弹匣回调 */ public init(data: any,holder: any,endCb?: Function,ammoCb?: Function){ this.data = data; this.shotBullets = 0; this.isFire = false; this.isFristShield = true; this.holder = holder; this.endCb = endCb; this.ammoCb = ammoCb; } //开火 public fire() { this.isFire = true; this.createBullet(); this.playParticle(this.shieldEffect); } //结束开火 public endFire(){ this.isFire = false; this.endCb?.(this.data); this.recycle(); } /** * 展示子弹 */ public createBullet() { if(!this.holder ||this.holder.isDead ||!this.isFire ||Game.I.isPause ||Game.I.isGameOver){ return; } //举盾操作 this.raiseShield(); this.endFire(); } /** * 举盾操作 * @param isGuaranteedHit 子弹是否必中(必中的时候targetNode不能为空) * @param targetNode 射击的目标对象 * @returns 返回一颗子弹 */ public raiseShield(){ } /** * 回收烟雾 */ public recycle(){ this.smokes.forEach(e => { if(e && e.parent){ PoolManager.putNode(e); } }); this.smokes = []; } }