import { ryw_Event } from "../../FrameWork/Event/EventEnum"; import EventMgr from "../../FrameWork/Event/EventMgr"; import User from "../../FrameWork/User/User"; import AppPlatform from "../../FrameWork/Util/AppPlatform"; import Common5 from "../../Platform/th/Common5"; import KaiKuangDataManage from "../Manager/KaiKuangDataManage"; import PrefabManage, { GameType } from "../PrefabManager/PrefabManage"; const {ccclass, property} = cc._decorator; @ccclass export default class KaiKuangFirstView extends cc.Component { @property(cc.Node) itemTopNode:cc.Node = null @property(cc.Node) itemMidNode:cc.Node = null @property(cc.Node) itemBottomNode:cc.Node = null @property(cc.Node) introductionBox:cc.Node = null curSelectItem:cc.Node = null onLoad () { //确认勘探之后再隐藏该座山峰 EventMgr.onEvent_custom(ryw_Event.changeScene,()=>{ console.log('changeScene++=KaiKuangFirstView') this.node.removeFromParent() this.node.destroy() },this) EventMgr.onEvent_custom(ryw_Event.Event_hideMounting, () => { if(this.curSelectItem){ this.curSelectItem.active = false } }, this); let callFunc = ()=>{ this.initContent() } if(!Common5.AllMountingConfig){ cc.loader.loadRes('Json/kaiKuangConfig/AllMountingConfig.json', function (err, gameconfig) { if (err) { console.log(err); return; } Common5.AllMountingConfig = gameconfig.json; console.log("山峰配置加载成功"); callFunc() }); }else{ callFunc() } } protected start(): void { this.scheduleOnce(()=>{ PrefabManage.preloadPrefabByType(GameType.KaiKuangMainView) },0.1) } initContent(){ let allMounting = KaiKuangDataManage.getMountingInfo() console.log("获取allMounting==",allMounting) this.initContentByTypeStr(this.itemTopNode,allMounting["高"]) this.initContentByTypeStr(this.itemMidNode,allMounting["中"]) this.initContentByTypeStr(this.itemBottomNode,allMounting["低"]) } initContentByTypeStr(parentNode,idArr){ for(var i=0;i{ if (finish) { Common5.kaiKuangVDIndex++ Common5.ReportDY("inLevel", '开矿山-AD-刷新开采证'); KaiKuangDataManage.clearAllRecord() this.initContent() } else{ Common5.showTips_custom("广告未观看完"); } },onFailed:()=>{ } } AppPlatform.playVideo_custom(tab) } onItemClick(event){ Common5.playEffect("ui") this.curSelectItem = event.target this.introductionBox.active = true this.introductionBox.getChildByName("tittleStr").getComponent(cc.Label).string = event.target.mountingConfig.mountingName+'开采权' this.introductionBox.getChildByName("introduceStr").getComponent(cc.Label).string = event.target.mountingConfig.mountingDesc this.introductionBox.getChildByName("moneyStr").getComponent(cc.Label).string = "开采费:"+ Common5.getNumberChangeHanzi(event.target.mountingConfig.mountingPrice,'1',1) Common5.proLoadPicBuyUrl('kuangshan/shan/'+event.target.mountingConfig.effectPath) KaiKuangDataManage.setCurMountingConfig(event.target.mountingConfig) } onBtnKaiCai(){ Common5.playEffect("ui") let curMountingConfig = KaiKuangDataManage.getCurMountingConfig() if(curMountingConfig.mountingPrice > User.getMoney()){ Common5.showTips_customTime('余额不足挣钱去吧',1) return }else{ // Common5.subMoney(this.expendMoney) } // KaiKuangDataManage.saveDataToStorage(curMountingConfig.id,true) // this.curSelectItem.active = false this.introductionBox.active = false // Common5.subMoney(curMountingConfig.mountingPrice) let callFunc = ()=>{ PrefabManage.loadPrefabByType(GameType.KaiKuangMainView) } if(Common5.AllMineralsConfig){ callFunc() }else{ cc.loader.loadRes('Json/kaiKuangConfig/AllMineralsConfig.json', function (err, gameconfig) { if (err) { console.log(err); return; } Common5.AllMineralsConfig = gameconfig.json; console.log("矿物加载成功"); callFunc() }); } } onBtnClose(){ Common5.playEffect("ui") this.introductionBox.active = false } }