/* * @Author: mojunshou 1637302775@qq.com * @Date: 2025-03-21 14:43:24 * @LastEditors: mojunshou 1637302775@qq.com * @LastEditTime: 2025-04-11 14:52:51 * @Description: 游戏通关弹窗 */ import { Label, Node } from 'cc'; import { _decorator } from 'cc'; import { oops } from 'db://oops-framework/core/Oops'; import { DeviceUtil } from 'db://oops-framework/core/utils/DeviceUtil'; import { GameComponent } from "db://oops-framework/module/common/GameComponent"; import { AD_TYPE } from '../common/config/GameDefine'; import { UIID } from '../common/config/GameUIConfig'; import { CocosHandler } from '../common/manager/CocosHandler'; import { smc } from '../common/SingletonModuleComp'; import { ADHandler } from '../common/manager/ADHandler'; import { GameEvent } from '../common/config/GameEvent'; import { ServerHandler } from '../common/manager/ServerHandler'; const { ccclass, property } = _decorator; /** 显示对象控制 */ @ccclass('GamePassView') export class GamePassView extends GameComponent { //提示Node @property(Label) private lab_tips: Label = null!; @property(Node) private receiveNode: Node = null!; //十倍领取 @property([Label]) private lab_list: Label[] = []; private time: number = 3; //倒数时间 private isAuto: boolean = true; //服务器传是否展示按钮 callback: Function = null!; protected start() { this.setButton(); this.isAuto = true; this.setData(); this.addEventList(); } addEventList() { oops.message.on(GameEvent.showCoinAnimation, this.showCoinAnimation, this); } showCoinAnimation() { if (oops.gui.has(UIID.GamePass)) { oops.gui.remove(UIID.GamePass); } } private setData() { this.isAuto = smc.game.GameModel.passViewInfo.doubleReward; this.receiveNode.active = this.isAuto; if (this.isAuto) { this.setAutoReceive(); } const list = smc.game.GameModel.passViewInfo.showReward; list.forEach((item, index) => { console.log("tiem.propId", item.propId) if (this.lab_list[index]) { this.lab_list[index].string = item.propNum + ""; } }) } //开心收下正常领取 private btn_none() { // oops.message.dispatchEvent(GameEvent.showCoinAnimation); oops.gui.remove(UIID.GamePass); //给服务器发信息--少量领取 ServerHandler.inst.getPassRewards(); } //十倍领取 private btn_more() { this.isAuto = false; if (DeviceUtil.isNative && DeviceUtil.isAndroid) { ADHandler.inst.showAd(AD_TYPE.Pass_Receive); } else { oops.gui.remove(UIID.GamePass); } } //设置自动领取 setAutoReceive() { let time = this.time; this.callback = function () { if (time <= 0 && this.isAuto) { this.unschedule(this.callback) // ADHandler.inst.showAd(AD_TYPE.Pass_Receive); } this.lab_tips.string = `${time}秒后自动领取`; time--; } this.schedule(this.callback, 1, this.time); } }