12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- /** @format */
- import FightCore from '../zuma/FightCore'
- import {Data} from '../GameControl'
- import {ICard} from '../interface/GlobalInterface'
- import {IZumabuffConfig, ZumabuffConfig} from '../config/ZumabuffConfig'
- const {ccclass, property} = cc._decorator
- @ccclass
- export class SkillOptCell extends cc.Component {
- mask: cc.Sprite = null //技能精灵
- timeLb: cc.Label = null //显示技能冷却剩余时间的文字
- time: number = 1 //技能冷却时间
- countDown: number = 0
- showTime: boolean = false //是否显示文字
- isStop: boolean = true //是否停止
- zumabuffCfg: IZumabuffConfig
- fightCore: FightCore
- onLoad() {
- this.mask = cc.find('mask', this.node).getComponent(cc.Sprite)
- this.timeLb = cc.find('timeLb', this.node).getComponent(cc.Label)
- this.timeLb.node.active = this.showTime
- this.node.on(cc.Node.EventType.TOUCH_END, this.onTouchStart, this)
- }
- update(dt: number) {
- dt *= Data.game.gameSpeed
- if (!this.isStop && !this.fightCore.isStop) {
- this.countDown -= dt
- if (this.countDown <= 0) {
- this.countDown = 0
- this.isStop = true
- if (this.zumabuffCfg) {
- }
- }
- this.mask.fillRange = this.time > 0 ? this.countDown / this.time : 0 //恢复技能
- this.timeLb.string = this.countDown > 0 ? (this.mask.fillRange * this.time).toFixed(1) : '' //更新技能冷却时间
- }
- }
- init(buffID: number, fightCore: FightCore) {
- this.fightCore = fightCore
- this.zumabuffCfg = ZumabuffConfig[buffID]
- this.time = 0
- this.countDown = this.time
- this.mask.fillRange = 0
- this.isStop = true
- this.resetNode()
- }
- startCD() {
- this.countDown = this.time
- this.isStop = false
- this.resetNode()
- }
- onTouchStart(e: cc.Event.EventTouch): void {
- if (!this.zumabuffCfg) return
- //cc.find('popChoose', this.node).active = true
- }
- resetNode() {
- this.node.stopAllActions()
- //cc.find('light', this.node).active = false
- //cc.find('popChoose', this.node).active = false
- }
- showCreateAni() {
- //cc.find('light', this.node).active = true
- }
- }
|