import { ryw_Event } from "../FrameWork/Event/EventEnum"; import EventMgr from "../FrameWork/Event/EventMgr"; import GameMgr from "../FrameWork/Mgr/GameMgr"; import GameReport from "../FrameWork/Report/ZyZyReport"; import User from "../FrameWork/User/User"; import AppPlatform from "../FrameWork/Util/AppPlatform"; import Common5 from "../Platform/th/Common5"; import DayUnlock from "../ttFrame/manager/DayUnlock"; const { ccclass, property } = cc._decorator; @ccclass export default class GameAlllockView extends cc.Component { level: number = 0; type: number = 0; backBtn: cc.Node = null; videoBtnOne: cc.Node = null; videoBTN: cc.Node = null; isLoading = false; private needVideoNum = 2; protected start(): void { this.needVideoNum = Common5.videoWxtlPowerNum; console.log(this.needVideoNum,'this.needVideoNum+++++++++==') this.backBtn = this.node.getChildByName("unlockback"); this.videoBtnOne = this.node.getChildByName("content").getChildByName("videoBtnOne"); this.videoBTN = this.node.getChildByName("content").getChildByName("videoBTN"); Common5.btnRegister_custom(this.backBtn, () => { this.btnCloseFunc(); }) Common5.btnRegister_custom(this.videoBtnOne, () => { this.btnVideo(); }) Common5.btnRegister_custom(this.videoBTN, () => { this.btnVideoUnlockAll(); }) if (this.level == -1 && this.type == -1) { this.videoBtnOne.active = false; } else { let bundle = cc.assetManager.loadBundle(Common5.gameConfig.zmGameConfig[this.level].bundle,(err,bundle)=>{ bundle.preload(Common5.gameConfig.zmGameConfig[this.level].url, cc.Prefab, () => { console.log(this.level + " preloadSuccess!") }) }) if (Common5.gameConfig.zmGameConfig[this.level].subbundle && Common5.gameConfig.zmGameConfig[this.level].subbundle!=""){ let subbundle = cc.assetManager.loadBundle(Common5.gameConfig.zmGameConfig[this.level].subbundle,(err,subbundle)=>{ subbundle.load(Common5.gameConfig.zmGameConfig[this.level].suburl, cc.Prefab, () => { console.log(this.level + " subbundle preloadSuccess!") }) }) } } this.updateVideoTimes(); } updateVideoTimes() { this.node.getChildByName("content").getChildByName("videoBTN").getChildByName("label").getComponent(cc.Label).string = DayUnlock.getDayUnlockVideoAllNum().toString() + "/" + Common5.videoDayUnlockNum; } setLevel(levelIn, typeIn) { this.level = levelIn; this.type = typeIn; } btnVideo() { let tab = { onClose: (finish) => { if (finish) { Common5.selectGameNum = this.level; Common5.wordGameType = this.type; Common5.selectGameInfo = Common5.gameConfig.zmGameConfig[this.level]; this.isLoading = true; console.log(this.level,'解锁关卡id += this.level+++++++++==') GameReport.ADReport('解锁本关',Common5.selectGameInfo.title2,1) Common5.ReportDY("inLevel", Common5.selectGameInfo.title2 + "-AD-解锁本关"); User.setlevelNum_Word_Array_custom(this.level); User.saveDataToServer() EventMgr.emitEvent_custom(ryw_Event.unLockLevel); this.node.removeFromParent(); return; } else { GameReport.ADReport('解锁本关',Common5.selectGameInfo.title2,0) Common5.showTips_custom("广告未观看完"); } }, onFailed: () => { } } AppPlatform.playVideo_custom(tab); } btnVideoUnlockAll() { let tab = { onClose: (finish) => { if (finish) { Common5.ReportDY("inLevel", "解锁全部-AD-解锁全部"); // if (AppPlatform.is_TT_GAME_custom()) { // window["tt"].reportAnalytics('watchAd', { // type: '看视频无限体力', // }); // } GameReport.ADReport('解锁全部',Common5.selectGameInfo.title2,1) let num = DayUnlock.getDayUnlockVideoAllNum(); num = num + 1; if (DayUnlock.getDayUnlockVideoAllTime() == 0) { if (num == 1) { DayUnlock.setDayUnlocVideoAllNum(num); GameMgr.getInstance_custom().saveGameData_custom(); } else if (num == 2) { DayUnlock.setDayUnlocVideoAllNum(num); GameMgr.getInstance_custom().saveGameData_custom(); } } if (num >= this.needVideoNum) { Common5.isNoPower = false; num = this.needVideoNum; DayUnlock.setDayUnlocVideoAllNum(num); this.updateVideoTimes(); DayUnlock.setDayUnlocVideoAllNum(0); DayUnlock.addNewDayUnlocksicalAll(); GameMgr.getInstance_custom().saveGameData_custom(); this.scheduleOnce(() => { this.btnCloseFunc(); }, 0.3) EventMgr.emitEvent_custom(ryw_Event.unLockAllLevelTmp); console.log("unLockAllLevelTmp222"); } else { DayUnlock.setDayUnlocVideoAllNum(num); this.updateVideoTimes(); GameMgr.getInstance_custom().saveGameData_custom(); } EventMgr.emitEvent_custom(ryw_Event.unLockAllLevelUpdate); } else { GameReport.ADReport('解锁全部',Common5.selectGameInfo.title2,0) Common5.showTips_custom("广告未观看完"); } }, onFailed: () => { } } AppPlatform.playVideo_custom(tab); } btnCloseFunc() { this.node.removeFromParent(); } }