//********************* // create by 流云 // time: Wed Apr 08 2026 // desc: //********************* import { _decorator, Component, Node, find, Vec3, tween, v3, Tween } from 'cc'; import { Auto_PopUnLockBtn } from './Auto_PopUnLockBtn'; import { GEvent } from 'db://assets/mx/module/event/GEvent'; import { NewFunType } from '../../newFun/NewFun'; const { ccclass, property } = _decorator; @ccclass('UIPopUnLockBtn') export class UIPopUnLockBtn extends Auto_PopUnLockBtn { onLoad(): void { super.onLoad(); } onEnable(): void { super.onEnable(); } onDisable(): void { super.onDisable(); } onInit(): void { this.showOpenCenterEff(); this.showOpenMaskEff(2); this.id = this.prema; gg.newFun.setUnLockNewFun(NewFunType.MainPageTab, this.prema); this.updateUI(); } id: number = 0; /** 避免遮罩点击与动画结束各调一次 close,或与 close 动画叠加重绘空引用(MultiTextures / updateUVs) */ private _closing = false; private finishCloseThenRefreshMainUI(): void { if (this._closing) return; this._closing = true; void this.close(2).then(() => { GEvent.Ins.emit(GEvent.UpdateMainUI); }); } /** 与常见弹窗一致:点遮罩关闭;先停掉按钮 tween,避免销毁后回调再触逻辑 */ click_bgMask(): void { for (const c of this.ui_btns.children) { Tween.stopAllByTarget(c); } this.ui_light.active = false; const btn = this.ui_btns.getChildByName('' + this.id); if (btn?.isValid) btn.active = false; this.finishCloseThenRefreshMainUI(); } updateUI(): void { this.ui_btns.children.map(c => c.active = false); let btn = this.ui_btns.getChildByName('' + this.id); if (btn) { btn.active = true; let targetPos = btn.position.clone(); btn.position = v3(0, 0, 0); tween(btn) .delay(2) .call(() => { this.ui_light.active = false; }) .to(1, { position: targetPos }) .call(() => { btn.active = false; this.finishCloseThenRefreshMainUI(); }) .start(); } else { this.finishCloseThenRefreshMainUI(); } } }