/*
 * @Author: mojunshou 1637302775@qq.com
 * @Date: 2025-03-21 11:17:22
 * @LastEditors: mojunshou 1637302775@qq.com
 * @LastEditTime: 2025-04-28 10:09:02
 * @Description: 二倍速弹窗
 */
import { _decorator } from "cc";
import { oops } from "db://oops-framework/core/Oops";
import VMParent from "db://oops-framework/libs/model-view/VMParent";
import { AD_TYPE } from "../common/config/GameDefine";
import { UIID } from "../common/config/GameUIConfig";
import { ADHandler } from "../common/manager/ADHandler";
import { smc } from "../common/SingletonModuleComp";
import { GameEvent } from "../common/config/GameEvent";
import { DCHandler } from "../common/manager/DCHandler";

const { ccclass, property } = _decorator;

/** 视图层对象 */
@ccclass('DoubleSpeedViewComp')
export class DoubleSpeedViewComp extends VMParent {
    /** 视图层逻辑代码分离演示 */
    data: any = {
        time: 0,
    }

    start() {
        // const entity = this.ent as ecs.Entity;         // ecs.Entity 可转为当前模块的具体实体对象
        DCHandler.inst.reportData(3000300);
        this.setButton();
        this.data.time = smc.game.GameModel.doubleSpeedTime / 60;


    }

    private btn_open() {
        this.openAd();
        oops.gui.remove(UIID.DoubleSpeed);
        //这有点问题
        oops.message.dispatchEvent(GameEvent.updateGameState, "playing");
    }

    //打开广告
    private openAd() {
        smc.game.GameModel.viewType = "speed_reward";
        ADHandler.inst.showAd(AD_TYPE.Double_Speed_Receive);
        DCHandler.inst.reportData(3000301);
        smc.game.GameModel.doubleSpeedAdCount++;
    }


    private btn_no() {
        oops.gui.remove(UIID.DoubleSpeed);
        ADHandler.inst.showAd("107");
        oops.message.dispatchEvent(GameEvent.updateGameState, "paused");
        DCHandler.inst.reportData(3000302);
    }


    private btn_close() {
        oops.gui.remove(UIID.DoubleSpeed);
        //播放插屏广告
        ADHandler.inst.showAd("107");
        oops.message.dispatchEvent(GameEvent.updateGameState, "paused");
        DCHandler.inst.reportData(3000302);
    }
}