import { _decorator, Component, Node, director } from 'cc'; import { GameController } from '../GameController'; import { WeaponBase } from '../weapons/WeaponBase'; import { SkillBase } from './SkillBase'; const { ccclass, property } = _decorator; @ccclass('KillAllMonsterSkill') export class KillAllMonsterSkill extends SkillBase { constructor(){ super(); } private weapon:WeaponBase; private startTime:number; /** * 使用技能 * @param weapon */ UseSkill(weapon:WeaponBase):void{ this.weapon=weapon; this.weapon.fireKey=2; this.weapon.MoveFirePosition(); this.startTime=director.getCurrentTime(); } private lastTime:number=0; /** * 更新 * @param dt */ Update(dt:number):void{ let current:number=director.getCurrentTime(); if(current-this.startTime>this.time){ this.DispatchEvent(SkillBase.SKILL_COMPLETE); return; } let posType:number=GameController.single.FindAttackMonsterPosType; if(posType<0){ return; } if(current-this.lastTime>this.fireInterval){ if(posType==0){ this.weapon.fireKey=1; }else if(posType==1){ this.weapon.fireKey=2; }else if(posType==2){ this.weapon.fireKey=3; } this.weapon.MoveFirePosition(); this.weapon.Fire(false); this.lastTime=current; } } /** * 销毁 */ Dispose():void{ } }