SkillEventProcess.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /** @format */
  2. import {EventProcess} from './EventProcess'
  3. import FrameAnimation from '../../uiutils/FrameAnimation'
  4. import {ISkillConfig} from '../../config/SkillConfig'
  5. import {EventAttack, EventBase, EventDie, EventGraphicsDraw, EventHPChange, EventRoleTip, EventType} from './NodeEvent'
  6. import {FrameAniConfig} from '../../config/FrameAniConfig'
  7. import {ANI_TYPE} from '../../enums/Enum'
  8. const {ccclass, property} = cc._decorator
  9. @ccclass
  10. export class SkillEventProcess extends EventProcess {
  11. frameAnimation: FrameAnimation
  12. skillCfg: ISkillConfig
  13. onAttach(): void {
  14. this.frameAnimation = this.getComponent(FrameAnimation)
  15. if (this.skillCfg.url) {
  16. if (FrameAniConfig[this.skillCfg.url]) {
  17. let aniConfig = FrameAniConfig[this.skillCfg.url]
  18. if (aniConfig.type == ANI_TYPE.frameAni) {
  19. this.playFrameAni(`skill/${aniConfig.url}`, Boolean(aniConfig.loop), aniConfig.duration)
  20. } else if (aniConfig.type == ANI_TYPE.action) {
  21. this.playAnimation(`skill/${aniConfig.url}`)
  22. }
  23. } else {
  24. this.playFrameAni(`skill/${this.skillCfg.url}`, Boolean(this.skillCfg.loop), this.skillCfg.duration)
  25. }
  26. }
  27. }
  28. processEvent(event: EventBase): void {
  29. if (!cc.isValid(this.node)) return
  30. switch (event.type) {
  31. case EventType.GraphicsDraw:
  32. if (cc.debug.isDisplayStats()) {
  33. this.graphicsDraw(event as EventGraphicsDraw)
  34. } else {
  35. this.graphicsDraw(null)
  36. }
  37. break
  38. }
  39. }
  40. }