KillAllMonsterSkill.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import { _decorator, Component, Node, director } from 'cc';
  2. import { GameController } from '../GameController';
  3. import { WeaponBase } from '../weapons/WeaponBase';
  4. import { SkillBase } from './SkillBase';
  5. const { ccclass, property } = _decorator;
  6. @ccclass('KillAllMonsterSkill')
  7. export class KillAllMonsterSkill extends SkillBase {
  8. constructor(){
  9. super();
  10. }
  11. private weapon:WeaponBase;
  12. private startTime:number;
  13. /**
  14. * 使用技能
  15. * @param weapon
  16. */
  17. UseSkill(weapon:WeaponBase):void{
  18. this.weapon=weapon;
  19. this.weapon.fireKey=2;
  20. this.weapon.MoveFirePosition();
  21. this.startTime=director.getCurrentTime();
  22. }
  23. private lastTime:number=0;
  24. /**
  25. * 更新
  26. * @param dt
  27. */
  28. Update(dt:number):void{
  29. let current:number=director.getCurrentTime();
  30. if(current-this.startTime>this.time){
  31. this.DispatchEvent(SkillBase.SKILL_COMPLETE);
  32. return;
  33. }
  34. if(current-this.lastTime>this.fireInterval){
  35. if(GameController.single.leftMonsterList.length){
  36. this.weapon.fireKey=1;
  37. }else if(GameController.single.middleMonsterList.length){
  38. this.weapon.fireKey=2;
  39. }else{
  40. this.weapon.fireKey=3;
  41. }
  42. this.weapon.MoveFirePosition();
  43. this.weapon.Fire(false);
  44. this.lastTime=current;
  45. }
  46. }
  47. /**
  48. * 销毁
  49. */
  50. Dispose():void{
  51. }
  52. }