| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- /*
- * @Author: mojunshou 1637302775@qq.com
- * @Date: 2025-03-21 14:43:24
- * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-04-23 17:32:10
- * @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';
- import { DCHandler } from '../common/manager/DCHandler';
- 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() {
- DCHandler.inst.reportData(3000500);
- 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) => {
- if (this.lab_list[index]) {
- this.lab_list[index].string = item.propNum + "";
- }
- })
- }
- //开心收下正常领取
- private btn_none() {
- if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
- ServerHandler.inst.getPassRewards();
- DCHandler.inst.reportData(3000501);
- }
- oops.gui.remove(UIID.GamePass);
- DCHandler.inst.reportData(3000503);
- }
- //十倍领取
- private btn_more() {
- this.isAuto = false;
- if (DeviceUtil.isNative && DeviceUtil.isAndroid) {
- smc.game.GameModel.viewType = "pass_reward";
- ADHandler.inst.showAd(AD_TYPE.Pass_Receive);
- oops.gui.remove(UIID.GamePass);
- DCHandler.inst.reportData(3000503);
- } else {
- oops.gui.remove(UIID.GamePass);
- }
- }
- //设置自动领取
- setAutoReceive() {
- let time = this.time;
- this.lab_tips.string = `${time}秒后自动领取`;
- this.callback = function () {
- this.lab_tips.string = `${time}秒后自动领取`;
- time--;
- if (time <= 0 && this.isAuto) {
- this.btn_more();
- this.unschedule(this.callback);
- DCHandler.inst.reportData(3000502);
- }
- }
- this.schedule(this.callback, 1, this.time);
- }
- }
|