/*
 * @Author: mojunshou 1637302775@qq.com
 * @Date: 2025-04-19 10:27:15
 * @LastEditors: mojunshou 1637302775@qq.com
 * @LastEditTime: 2025-04-28 16:31:22
 * @Description:官方承诺
 */
import { _decorator, Component, Node, Animation } from 'cc';
import { oops } from 'db://oops-framework/core/Oops';
import { GameComponent } from 'db://oops-framework/module/common/GameComponent';
import { UIID } from '../../common/config/GameUIConfig';
import { ServerHandler } from '../../common/manager/ServerHandler';
import { smc } from '../../common/SingletonModuleComp';
import { GameEvent } from '../../common/config/GameEvent';
const { ccclass, property } = _decorator;

@ccclass('WelfareThree')
export class WelfareThree extends GameComponent {
    @property(Node)
    private showNode1: Node = null!;

    @property(Node)
    private showNode2: Node = null!;

    start() {
        //3秒后打开官方承诺，关闭当前窗口
        oops.message.dispatchEvent(GameEvent.updateGameState, "paused");
        this.showNode1.active = true;
        this.showNode2.active = false;
        this.scheduleOnce(() => {
            this.showNode1.active = false;
            this.showNode2.active = true;
            //播放动画
            const animation = this.showNode2.getComponent(Animation);
            if (animation) {
                animation.play();
            }

            //3秒后打开官方承诺，关闭当前窗口
            this.scheduleOnce(() => {
                this.updateState();
                oops.gui.remove(UIID.WelfareThree);
            }, 5)

        }, 3)
    }

    updateState() {
        ServerHandler.inst.updatePopupState({
            level: smc.account.AccountModel.curLevel,
            type: smc.game.GameModel.popupType
        })

    }
}


