KillAllMonsterSkill.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. let posType:number=GameController.single.FindAttackMonsterPosType;
  35. if(posType<0){
  36. return;
  37. }
  38. if(current-this.lastTime>this.fireInterval){
  39. if(posType==0){
  40. this.weapon.fireKey=1;
  41. }else if(posType==1){
  42. this.weapon.fireKey=2;
  43. }else if(posType==2){
  44. this.weapon.fireKey=3;
  45. }
  46. this.weapon.MoveFirePosition();
  47. this.weapon.Fire(false);
  48. this.lastTime=current;
  49. }
  50. }
  51. /**
  52. * 销毁
  53. */
  54. Dispose():void{
  55. }
  56. }