NodeEvent.ts 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /** @format */
  2. import {GAME_ROLE_TIP} from '../../enums/Enum'
  3. import {IBuff} from './GameInterface'
  4. export enum EventType {
  5. Enter,
  6. Stand,
  7. Run,
  8. Attack,
  9. Skill,
  10. StopSkill,
  11. HurtOrAdd,
  12. RoleTip,
  13. HPChange,
  14. Die,
  15. BuffChange,
  16. GraphicsDraw,
  17. SlowDown,
  18. BulletEjection,
  19. }
  20. export class EventBase {
  21. type: EventType
  22. constructor(type: number) {
  23. this.type = type
  24. }
  25. }
  26. export class EventEnter extends EventBase {
  27. constructor() {
  28. super(EventType.Enter)
  29. }
  30. }
  31. export class EventStand extends EventBase {
  32. constructor() {
  33. super(EventType.Stand)
  34. }
  35. }
  36. export class EventRun extends EventBase {
  37. constructor() {
  38. super(EventType.Run)
  39. }
  40. }
  41. export class EventBuffChange extends EventBase {
  42. buffs: IBuff[]
  43. addBuffs: IBuff[]
  44. removeBuffs: IBuff[]
  45. constructor(buffs: IBuff[], addBuffs: IBuff[], removeBuffs: IBuff[]) {
  46. super(EventType.BuffChange)
  47. this.buffs = buffs
  48. this.addBuffs = addBuffs
  49. this.removeBuffs = removeBuffs
  50. }
  51. }
  52. export class EventAttack extends EventBase {
  53. dir: cc.Vec2
  54. isShoot: boolean
  55. attackScale: number //攻击速度比例值
  56. attackIndex: number //spine攻击动作序号
  57. constructor(dir: cc.Vec2, isShoot: boolean, attackScale: number, attackIndex: number) {
  58. super(EventType.Attack)
  59. this.dir = dir
  60. this.isShoot = isShoot
  61. this.attackScale = attackScale
  62. this.attackIndex = attackIndex
  63. }
  64. }
  65. export class EventSkill extends EventBase {
  66. castTime: number
  67. skillIndex: number
  68. constructor(castTime: number, skillIndex: number) {
  69. super(EventType.Skill)
  70. this.castTime = castTime
  71. this.skillIndex = skillIndex + 1
  72. }
  73. }
  74. export class EventStopSkill extends EventBase {
  75. constructor() {
  76. super(EventType.StopSkill)
  77. }
  78. }
  79. export class EventHurtOrAdd extends EventBase {
  80. public changeHP: number
  81. public isCrit: boolean
  82. constructor(changeHP: number, isCrit?: boolean) {
  83. super(EventType.HurtOrAdd)
  84. this.changeHP = changeHP
  85. this.isCrit = isCrit
  86. }
  87. }
  88. export class EventRoleTip extends EventBase {
  89. public tipType: GAME_ROLE_TIP
  90. public num: number
  91. public tip: string
  92. constructor(tipType: GAME_ROLE_TIP, num: number, tip: string) {
  93. super(EventType.RoleTip)
  94. this.tipType = tipType
  95. this.num = num
  96. this.tip = tip
  97. }
  98. }
  99. export class EventDie extends EventBase {
  100. constructor() {
  101. super(EventType.Die)
  102. }
  103. }
  104. export class EventHPChange extends EventBase {
  105. public lastHP: number
  106. public nowHP: number
  107. public HP: number
  108. public lastShieldHP: number
  109. public shieldHP: number
  110. public changeTime: number
  111. constructor(
  112. HP: number,
  113. lastHP: number,
  114. nowHP: number,
  115. lastShieldHP: number,
  116. shieldHP: number,
  117. changeTime: number = 0.2,
  118. ) {
  119. super(EventType.HPChange)
  120. this.HP = HP
  121. this.lastHP = lastHP
  122. this.nowHP = nowHP
  123. this.lastShieldHP = lastShieldHP
  124. this.shieldHP = shieldHP
  125. this.changeTime = changeTime
  126. }
  127. }
  128. export class EventGraphicsDraw extends EventBase {
  129. public points: cc.Vec2[]
  130. public radius: number
  131. public color: cc.Color
  132. constructor(points: cc.Vec2[], radius?: number, color?: cc.Color) {
  133. super(EventType.GraphicsDraw)
  134. this.points = points
  135. this.radius = radius
  136. this.color = color
  137. }
  138. }
  139. export class EventSlowDown extends EventBase {
  140. public isSlow: boolean
  141. constructor(isSlow: boolean) {
  142. super(EventType.SlowDown)
  143. this.isSlow = isSlow
  144. }
  145. }
  146. export class EventBulletEjection extends EventBase {
  147. public posX: number
  148. public posY: number
  149. constructor(posX: number, posY: number) {
  150. super(EventType.BulletEjection)
  151. this.posX = posX
  152. this.posY = posY
  153. }
  154. }