// Learn TypeScript: // - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html // Learn Attribute: // - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html import User from "../../FrameWork/User/User"; import AppPlatform from "../../FrameWork/Util/AppPlatform"; import Common5 from "../../Platform/th/Common5"; import TaskManager from "../JuQingChat/TaskManager"; import PrefabManage from "../PrefabManager/PrefabManage"; const { ccclass, property } = cc._decorator; @ccclass export default class smallgameItemNode extends cc.Component { @property(cc.Sprite) icon: cc.Sprite = null; @property(cc.Node) adIcon: cc.Node = null; @property(cc.Label) title_str: cc.Label = null; @property(cc.Label) shuliang: cc.Label = null; config: any; // LIFE-CYCLE CALLBACKS: // onLoad () {} start() { } init(data) { this.config = data // Common5.addUrlSprite_custom(this.config.icon, this.icon) Common5.getSpriteFrameFromBundle("smallgame", this.config.icon, this.icon) this.title_str.string = data.title this.shuliang.string = `收入: 大量金钱` let isAD = User.getStatistics(this.config.savekey) let isactive = true if (!isAD) { isactive = false } if (isactive) { this.adIcon.active = isactive } this.refreshState() } refreshState() { } onTouchStartGame() { if (this.adIcon.active) { let tab = { onClose: (finish) => { if (finish) { User.setShowAdNum(User.getShowAdNum() + 1) Common5.ReportDY("inLevel", `任务${TaskManager.getCurUnLockMainTaskId()}-AD-${this.config.title}`) User.setStatistics(this.config.savekey, '1') User.setStatistics(`${this.config.savekey + 'CurGoLevel'}`, 0) PrefabManage.loadPrefabByType(this.config.gametype) } else { Common5.showTips_custom("广告未观看完"); } }, onFailed: () => { } } AppPlatform.playVideo_custom(tab) } else { User.setStatistics(this.config.savekey, '1') this.adIcon.active = true User.setStatistics(`${this.config.savekey + 'CurGoLevel'}`, 0) //当前过了几关,为了只算一次钱 PrefabManage.loadPrefabByType(this.config.gametype) } } // update (dt) {} }