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C,UAAU,CAAC,cAAc,EAAE,CAAC,CAAC;SACvD;QACD,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;QACtB,IAAI,QAAQ,EAAE;YACV,SAAS;YACT,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC;iBACb,KAAK,CAAC,QAAQ,GAAG,GAAG,CAAC;iBACrB,EAAE,CAAC,QAAQ,GAAG,GAAG,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;iBAClC,IAAI,CAAC,GAAG,EAAE;YACX,CAAC,CAAC;iBACD,KAAK,EAAE,CAAC;SAChB;QAED,SAAS;QACT,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC;aACb,EAAE,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;aAChD,IAAI,CAAC,GAAG,EAAE;YACP,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC;YACvB,IAAI,MAAM,CAAC,QAAQ;gBAAE,MAAM,CAAC,QAAQ,EAAE,CAAC;QAC3C,CAAC,CAAC;aACD,KAAK,EAAE,CAAC;IACjB,CAAC;IA5Be,yBAAU,aA4BzB,CAAA;AACL,CAAC,EA5KgB,cAAc,GAAd,sBAAc,KAAd,sBAAc,QA4K9B","file":"","sourceRoot":"/","sourcesContent":["import FrameAnimation from \"../components/FrameAnimation\";\nimport { ScheduleUtils } from \"./ScheduleUtils\";\n\nexport namespace AnimationUtils {\n export function playFrameAnimation(node: cc.Node, loop: boolean, name: string, callback?: (loopCount?: number) => void) {\n let anims = node.getComponents(FrameAnimation)\n if (!anims || anims.length == 0) {\n return\n }\n let findOne: FrameAnimation = anims[0]\n for (let i = 0; i < anims.length; i++) {\n const anim = anims[i];\n if (anim.tag == name) {\n findOne = anim\n } else {\n anim.enabled = false\n }\n }\n findOne.enabled = true;\n findOne.play(callback, loop);\n }\n\n export function playFrameAnimationOnce(node: cc.Node, name: string, callback?: (loopCount?: number) => void) {\n playFrameAnimation(node, false, name, callback);\n }\n\n export function playFrameAnimationLoop(node: cc.Node, name: string) {\n playFrameAnimation(node, true, name);\n }\n\n export function animateProgress(progressBar: cc.ProgressBar, progress: number, speed = 1, label?: cc.Label): Promise<void> {\n return new Promise((resolve) => {\n let oldProgress = progressBar.progress\n if (oldProgress == progress) {\n resolve();\n return;\n }\n if (progress > 1) progress = 1;\n if (progress < 0) progress = 0;\n let delta = progress - oldProgress;\n\n if ((<any>progressBar).updateFunc) ScheduleUtils.unscheduleUpdate((<any>progressBar).updateFunc);\n const update = (dt: number) => {\n oldProgress += delta * dt * speed;\n if ((delta > 0 && oldProgress > progress) || (delta < 0 && oldProgress < progress)) {\n oldProgress = progress;\n delete (<any>progressBar).updateFunc;\n ScheduleUtils.unscheduleUpdate(update);\n resolve();\n }\n progressBar.progress = oldProgress;\n if (label) label.string = `${Math.round(oldProgress * 1000) / 10}%`;\n }\n (<any>progressBar).updateFunc = update;\n ScheduleUtils.scheduleUpdate(update);\n });\n }\n\n //异步动画执行API. 方便链式调用.\n export async function runAction(node: cc.Node | cc.Component, action: cc.FiniteTimeAction | cc.FiniteTimeAction[]): Promise<any> {\n return new Promise<any>(resolve => {\n if (!action || !node) {\n console.info(\"runAction param is null:\", node, action)\n resolve();\n return;\n }\n let nd = node instanceof cc.Component ? node.node : node\n nd.runAction(cc.sequence(action, cc.callFunc(function () {\n resolve()\n })))\n })\n }\n\n let timerIds: number[] = [];\n export function ActionTypeWriter(comp: cc.Label | cc.RichText, str: string, time?: number) {\n return new Promise<any>((resolve) => {\n if (timerIds && timerIds.length) {\n for (let i = 0; i < timerIds.length; i++) {\n clearTimeout(timerIds[i]);\n }\n timerIds = [];\n }\n if (!comp || !str || \"\" === str.trim()) { return; }\n comp.string = str;\n time = time ? time : 1;\n let cArr: string[] = [];\n for (let i = 0; i < str.length; i++) {\n cArr.push(\" \");\n }\n let reg = new RegExp(',', 'g');\n for (let i = 0; i < str.length; i++) {\n cArr[i] = str[i];\n let s = cArr.toString();\n let id = setTimeout(() => {\n s = s.replace(reg, \"\");\n comp.string = s;\n if (s.length === str.length) {\n resolve();\n }\n }, time / str.length * 1000 * i);\n timerIds.push(id);\n }\n });\n }\n\n let animTime: number = 0.3;\n /**\n * \n * @param maskNode 遮罩node\n * @param mainNode 所有内容node\n * @param params callback:执行完成后的回调,maskNodeOpacityValue遮罩node的opacity值\n */\n export function showUIAnim(mainNode: cc.Node, params = { callback: () => { }, maskNodeOpacityValue: 200 }, maskNode?: cc.Node): void {\n\n mainNode.scale = 0;\n mainNode.active = true;\n // 播放背景动画\n let opacityValue = params.maskNodeOpacityValue;\n if (maskNode) {\n maskNode.opacity = 0;\n maskNode.active = true;\n cc.tween(maskNode)\n .to(animTime * 0.8, { opacity: opacityValue })\n .call(() => {\n })\n .start();\n }\n\n // 播放主体动画\n cc.tween(mainNode)\n .to(animTime, { scale: 1 }, { easing: 'backOut' })\n .call(() => {\n // 弹窗已完全展示(动画完毕)\n if (params.callback) params.callback();\n })\n .start();\n\n }\n\n /**\n * \n * @param parentNode 该组件挂载的node\n * @param maskNode 遮罩node\n * @param mainNode 所有内容node\n * @param params callback:执行完成后的回调,maskNodeOpacityValue遮罩node的opacity值\n */\n export function hideUIAnim(parentNode: cc.Node, mainNode: cc.Node, params = { callback: () => { } }, maskNode?: cc.Node): void {\n // 拦截点击事件\n let blocker = parentNode.getChildByName(\"blocker\");\n if (!blocker) {\n blocker = new cc.Node('blocker');\n blocker.addComponent(cc.BlockInputEvents);\n blocker.setParent(parentNode);\n blocker.setContentSize(parentNode.getContentSize());\n }\n blocker.active = true;\n if (maskNode) {\n // 播放背景动画\n cc.tween(maskNode)\n .delay(animTime * 0.2)\n .to(animTime * 0.8, { opacity: 0 })\n .call(() => {\n })\n .start();\n }\n\n // 播放主体动画\n cc.tween(mainNode)\n .to(animTime, { scale: 0 }, { easing: 'backIn' })\n .call(() => {\n blocker.active = false;\n if (params.callback) params.callback();\n })\n .start();\n }\n}\n"]}