You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
155 lines
6.1 KiB
155 lines
6.1 KiB
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 TaskManager from "../../Scripts/JuQingChat/TaskManager";
|
|
import KaiKuangDataManage from "../../Scripts/Manager/KaiKuangDataManage";
|
|
import PrefabManage, { GameType } from "../../Scripts/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
|
|
startTime_Game = 0
|
|
onLoad () {
|
|
//确认勘探之后再隐藏该座山峰
|
|
this.startTime_Game = new Date().getTime();
|
|
EventMgr.onceEvent_custom(ryw_Event.subBack,()=>{
|
|
let dateDadian = User.getDadianListGame()
|
|
if(!dateDadian['开矿山']){
|
|
console.log('开矿山++++++++++++++++++====')
|
|
User.setDadianListGame('开矿山', true)
|
|
// Common5.ReportDY("inLevel", '开矿山-玩家');
|
|
}
|
|
|
|
let endTime = new Date().getTime();
|
|
let time_ = endTime-this.startTime_Game
|
|
let times = Math.floor( time_/1000)
|
|
if(times>0){
|
|
// Common5.ReportDYTime("inLevel", '开矿山', times);
|
|
}
|
|
|
|
},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("山峰配置加载成功", Common5.AllMountingConfig);
|
|
callFunc()
|
|
});
|
|
}else{
|
|
callFunc()
|
|
}
|
|
}
|
|
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){
|
|
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
|
|
let mainId = mainTaskInfo.Id
|
|
let configData = TaskManager.getTaskConfigById(mainId)
|
|
let KuangShanID = configData.KuangShanID
|
|
for(var i=0;i<idArr.length;i++){
|
|
let mountingConfig = KaiKuangDataManage.getMountingConfigById(idArr[i].id)
|
|
let item = parentNode.getChildByName("item_"+i)
|
|
if(idArr[i].isFinish){
|
|
item.active = false
|
|
}else{
|
|
item.active = true
|
|
item.getChildByName("mountingNameStr").getComponent(cc.Label).string = mountingConfig.mountingName
|
|
item.getChildByName("mountingPrice").getComponent(cc.Label).string = Common5.getNumberChangeHanzi(mountingConfig.mountingPrice,'1',1)+""
|
|
Common5.getSpriteFrameFromBundle("kaiKuang","texture/icon/"+mountingConfig.iconName,item.getChildByName("spFrame").getComponent(cc.Sprite));
|
|
item.attr({mountingConfig:mountingConfig})
|
|
|
|
if (configData && (configData.KuangShanID || configData.KuangShanID == 0) && configData.KuangShanID == idArr[i].id) {
|
|
item.getChildByName("购买").active = true
|
|
}else{
|
|
item.getChildByName("购买").active = false
|
|
}
|
|
}
|
|
}
|
|
}
|
|
onBtnRefreshClick(){
|
|
Common5.playEffect("ui")
|
|
let tab = {
|
|
onClose: (finish)=>{
|
|
if (finish) {
|
|
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
|
|
let mainId = mainTaskInfo.Id
|
|
Common5.ReportDY("inLevel", `任务${mainId}-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)
|
|
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)
|
|
PrefabManage.loadPrefabByType(GameType.KaiKuangMainView)
|
|
}
|
|
onBtnClose(){
|
|
Common5.playEffect("ui")
|
|
this.introductionBox.active = false
|
|
}
|
|
} |