import { _decorator, Component, Node } from 'cc'; import { ActiveSkillBase } from './ActiveSkillBase'; import { UmUtil } from '../../../../cc-common/cc-util/UmUtil'; import { GameGlobalData } from '../../global/GameGlobalData'; import { Vec3 } from 'cc'; import { UmLog } from '../../../../cc-common/cc-util/UmLog'; import { EACTIVE_SKILL_TYPE, GameDefine } from '../../config/GameDefine'; import { Sprite } from 'cc'; import { Label } from 'cc'; const { ccclass, property } = _decorator; @ccclass('ActiveSkill3') export class ActiveSkill3 extends ActiveSkillBase { @property(Sprite) clock: Sprite = null!; @property(Label) clockTxt: Label = null!; activeTime = 0; public enableActiveSkill(data, parent) { super.enableActiveSkill(data, parent); this.skillType = Number(EACTIVE_SKILL_TYPE.SKILL_3); } protected update(dt: number) { if (!GameGlobalData.Instance.isStatePlay() || this.isDestroying) return; this.node.position = Vec3.ZERO; if (this.activeTime >= this.useTime) { this.destroyNode(); return; } this.activeTime += dt; this.updateClock(); } updateClock() { this.clock.fillRange = 1 - this.activeTime / this.useTime; var remainTime = Math.min((this.useTime - this.activeTime).truncDigits(0) + 1, this.useTime); this.clockTxt.string = remainTime.toString(); } }