SkillOptCell.ts 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /** @format */
  2. import FightCore from '../zuma/FightCore'
  3. import {Data} from '../GameControl'
  4. import {ICard} from '../interface/GlobalInterface'
  5. import {IZumabuffConfig, ZumabuffConfig} from '../config/ZumabuffConfig'
  6. const {ccclass, property} = cc._decorator
  7. @ccclass
  8. export class SkillOptCell extends cc.Component {
  9. mask: cc.Sprite = null //技能精灵
  10. timeLb: cc.Label = null //显示技能冷却剩余时间的文字
  11. time: number = 1 //技能冷却时间
  12. countDown: number = 0
  13. showTime: boolean = false //是否显示文字
  14. isStop: boolean = true //是否停止
  15. zumabuffCfg: IZumabuffConfig
  16. fightCore: FightCore
  17. onLoad() {
  18. this.mask = cc.find('mask', this.node).getComponent(cc.Sprite)
  19. this.timeLb = cc.find('timeLb', this.node).getComponent(cc.Label)
  20. this.timeLb.node.active = this.showTime
  21. this.node.on(cc.Node.EventType.TOUCH_END, this.onTouchStart, this)
  22. }
  23. update(dt: number) {
  24. dt *= Data.game.gameSpeed
  25. if (!this.isStop && !this.fightCore.isStop) {
  26. this.countDown -= dt
  27. if (this.countDown <= 0) {
  28. this.countDown = 0
  29. this.isStop = true
  30. if (this.zumabuffCfg) {
  31. }
  32. }
  33. this.mask.fillRange = this.time > 0 ? this.countDown / this.time : 0 //恢复技能
  34. this.timeLb.string = this.countDown > 0 ? (this.mask.fillRange * this.time).toFixed(1) : '' //更新技能冷却时间
  35. }
  36. }
  37. init(buffID: number, fightCore: FightCore) {
  38. this.fightCore = fightCore
  39. this.zumabuffCfg = ZumabuffConfig[buffID]
  40. this.time = 0
  41. this.countDown = this.time
  42. this.mask.fillRange = 0
  43. this.isStop = true
  44. this.resetNode()
  45. }
  46. startCD() {
  47. this.countDown = this.time
  48. this.isStop = false
  49. this.resetNode()
  50. }
  51. onTouchStart(e: cc.Event.EventTouch): void {
  52. if (!this.zumabuffCfg) return
  53. //cc.find('popChoose', this.node).active = true
  54. }
  55. resetNode() {
  56. this.node.stopAllActions()
  57. //cc.find('light', this.node).active = false
  58. //cc.find('popChoose', this.node).active = false
  59. }
  60. showCreateAni() {
  61. //cc.find('light', this.node).active = true
  62. }
  63. }