DefaultSkill.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import { director } from "cc";
  2. import { SoundManager } from "../../../../engines/sounds/SoundManager";
  3. import { GameController } from "../GameController";
  4. import { WeaponBase } from "../weapons/WeaponBase";
  5. import { SkillBase } from "./SkillBase";
  6. export default class DefaultSkill extends SkillBase
  7. {
  8. private startTime:number;
  9. /**
  10. * 使用技能
  11. * @param weapon
  12. * @param data
  13. */
  14. UseSkill(weapon:WeaponBase,data?:any):void{
  15. super.UseSkill(weapon,data);
  16. this.weapon.fireKey=2;
  17. this.weapon.MoveFirePosition();
  18. this.startTime=director.getCurrentTime();
  19. }
  20. /**
  21. * 更新
  22. * @param dt
  23. */
  24. Update(dt:number):void{
  25. super.Update(dt);
  26. let current:number=director.getCurrentTime();
  27. if(current-this.startTime>this.time){
  28. this.DispatchEvent(SkillBase.SKILL_COMPLETE);
  29. return;
  30. }
  31. let posType:number=GameController.single.FindAttackMonsterPosType;
  32. if(posType<0){
  33. SoundManager.single.StopSound("Weapon");
  34. SoundManager.single.StopSound("WeaponLeft");
  35. SoundManager.single.StopSound("WeaponRight");
  36. return;
  37. }
  38. }
  39. /**
  40. * 销毁
  41. */
  42. Dispose():void{
  43. super.Dispose();
  44. SoundManager.single.StopSound("Weapon");
  45. SoundManager.single.StopSound("WeaponLeft");
  46. SoundManager.single.StopSound("WeaponRight");
  47. }
  48. // /**
  49. // * 是否阻断玩家操作
  50. // */
  51. // get unController():boolean{
  52. // return false;
  53. // }
  54. // /**
  55. // * 射击间隔
  56. // */
  57. // get fireInterval():number{
  58. // return 50;
  59. // }
  60. }