觉醒时刻
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.
 
 
 

215 lines
11 KiB

import AppPlatform from "../../../FrameWork/Util/AppPlatform";
import Common5 from "../../../Platform/th/Common5";
import TaskManager, { MainTaskIdEnum } from "../../JuQingChat/TaskManager";
import UserManager from "../../Manager/UserManager";
import NewGuideScript from "../../NewGuide/NewGuideScript";
import PrefabManage, { GameType } from "../../PrefabManager/PrefabManage";
import ZhongCanTingManager from "./ZhongCanTingManager";
const { ccclass, property } = cc._decorator;
@ccclass
export default class ZhongCanTingShengJi extends cc.Component {
@property(cc.Node)
tittleSp: cc.Node = null;
@property(cc.Node)
itemContent: cc.Node = null;
@property(cc.Node)
singleItem: cc.Node = null;
@property(cc.Node)
successNode: cc.Node = null;
curConfig = null
curLevel = 0
// onLoad () {}
callFunc = null
startProgress = false
start() {
}
initView(id, level, callFunc) {
this.curLevel = level
this.callFunc = callFunc
this.itemContent.removeAllChildren()
this.curConfig = ZhongCanTingManager.getZhongCanTingConfig()[id]
let maxLevel = this.curConfig.maxLevel
for (let i = 0; i < maxLevel; i++) {
let item = cc.instantiate(this.singleItem)
item.active = true
item.parent = this.itemContent
}
Common5.getSpriteFrameFromBundle("ZhongCanTingShengJi", "texture/" + this.curConfig.caiMing + '菜品', this.tittleSp.getComponent(cc.Sprite));
this.refreshAllItem()
}
refreshAllItem() {
for (let i = 0; i < this.curConfig.maxLevel; i++) {
let item = this.itemContent.children[i]
if (i == 0) {
item.getChildByName('shouYi').getComponent(cc.Label).string = `+${Common5.getNumberChangeHanzi(this.curConfig.meiMiaoShouYiArr[i], '1')}/秒`
item.getChildByName('王者框下').active = false
} else {
if (this.curConfig.shengJiXiaoHaoArr[i - 1] > 0) {
item.getChildByName('王者框下').active = false
} else {
item.getChildByName('王者框下').active = true
}
item.getChildByName('shouYi').getComponent(cc.Label).string = `+${Common5.getNumberChangeHanzi(this.curConfig.meiMiaoShouYiArr[i], '1')}/秒`
// item.getChildByName('shouYi').getComponent(cc.Label).string = `+${Common5.getNumberChangeHanzi(this.curConfig.meiMiaoShouYiArr[i] - this.curConfig.meiMiaoShouYiArr[i - 1], '1')}/秒`
}
item.getChildByName('caiMing').getComponent(cc.Label).string = this.curConfig.caiPinMing[i]
Common5.getSpriteFrameFromBundle("ZhongCanTingShengJi", "texture/" + this.curConfig.caiMing + '/' + this.curConfig.caiPinMing[i], item.getChildByName('caiIcon').getComponent(cc.Sprite));
if (this.curLevel > i) {
item.getChildByName("jieSuoQiPao").active = false
item.getChildByName('suoDing').active = false
item.getChildByName('菜品框').active = true
item.getChildByName('caiMing').active = true
} else {
item.getChildByName("jieSuoQiPao").active = false
item.getChildByName('suoDing').active = true
item.getChildByName('菜品框').active = false
item.getChildByName('caiMing').active = false
if (this.curLevel == i) {
item.getChildByName('suoDing').getChildByName('问号').active = false
let money = this.curConfig.shengJiXiaoHaoArr[this.curLevel - 1]
if (money > 0) {
item.getChildByName('suoDing').getChildByName('money').getComponent(cc.Label).string = `${Common5.getNumberChangeHanzi(money, '1')}`
item.getChildByName('suoDing').getChildByName('btnYanZhi').active = true
item.getChildByName('suoDing').getChildByName('btnADYanZhi').active = false
item.getChildByName('suoDing').getChildByName('钞票').active = true
item.getChildByName('suoDing').getChildByName('money').active = true
} else {
item.getChildByName('suoDing').getChildByName('btnYanZhi').active = false
item.getChildByName('suoDing').getChildByName('btnADYanZhi').active = true
item.getChildByName('suoDing').getChildByName('钞票').active = false
item.getChildByName('suoDing').getChildByName('money').active = false
}
} else {
item.getChildByName('suoDing').getChildByName('问号').active = true
item.getChildByName('suoDing').getChildByName('钞票').active = false
item.getChildByName('suoDing').getChildByName('money').active = false
item.getChildByName('suoDing').getChildByName('btnYanZhi').active = false
item.getChildByName('suoDing').getChildByName('btnADYanZhi').active = false
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
let mainId = mainTaskInfo.Id
let config = TaskManager.getTaskConfigById(mainId);
if (mainId == MainTaskIdEnum.MainTask_810 && i == 4) {
item.getChildByName("jieSuoQiPao").active = true
} else if (mainId == MainTaskIdEnum.MainTask_1406 && i == 7) {
item.getChildByName("jieSuoQiPao").active = true
} else {
item.getChildByName("jieSuoQiPao").active = false
}
// if (config.GMCapitalLevel && config.GMCapitalLevel.length > 0) {
// for (let index = 0; index < config.GMCapitalLevel.length; index++) {
// let arr = config.GMCapitalLevel[index]
// if (arr[1] == i + 1 && this.curLevel < arr[1]) {
// item.getChildByName("jieSuoQiPao").active = true
// break
// }
// }
// }
}
}
}
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
let mainId = mainTaskInfo.Id
if (mainId == MainTaskIdEnum.MainTask_311 && this.curLevel == 1) {
let node = this.itemContent.children[1]
this.guideView([node]);
}
}
guideView(nodeArray) {
PrefabManage.loadPrefabByType(GameType.GuideMskNode, null, (prefab) => {
let guideNodeArray = nodeArray
let firstNode = guideNodeArray.shift()
prefab.getComponent(NewGuideScript).setBindNode(firstNode, guideNodeArray)
})
}
onBtnClose() {
this.node.removeFromParent()
this.node.destroy()
}
onBtnCloseSuccessNode() {
this.successNode.active = false
}
onBtnClickMoneyShengJi(event) {
let money = this.curConfig.shengJiXiaoHaoArr[this.curLevel - 1]
if (UserManager.getCurMoney() < money) {
PrefabManage.showTextTips('钱不够,不能升级!')
} else {
this.showSuccessNode()
UserManager.subMoney(money)
this.curLevel += 1
ZhongCanTingManager.setBaDaCaiXiLevelInfo(this.curConfig.id, this.curLevel)
this.refreshAllItem()
ZhongCanTingManager.checkTask()
this.callFunc()
}
}
onBtnClickADShengJi(event) {
let tab = {
onClose: (finish) => {
if (finish) {
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
let mainId = mainTaskInfo.Id
Common5.ReportDY("inLevel", `任务${mainId}-AD-产业开设产业`);
this.showSuccessNode()
this.curLevel += 1
ZhongCanTingManager.setBaDaCaiXiLevelInfo(this.curConfig.id, this.curLevel)
this.refreshAllItem()
ZhongCanTingManager.checkTask()
this.callFunc()
} else {
Common5.showTips_custom("广告未观看完");
}
}, onFailed: () => {
}
}
AppPlatform.playVideo_custom(tab)
}
showSuccessNode() {
this.successNode.active = true
this.successNode.getChildByName('caiMing').getComponent(cc.Label).string = this.curConfig.caiPinMing[this.curLevel]
this.successNode.getChildByName('shouYi').getComponent(cc.Label).string = `收益:+${Common5.getNumberChangeHanzi(this.curConfig.meiMiaoShouYiArr[this.curLevel], '1')}/秒`
// this.successNode.getChildByName('shouYi').getComponent(cc.Label).string = `收益:+${Common5.getNumberChangeHanzi(this.curConfig.meiMiaoShouYiArr[this.curLevel] - this.curConfig.meiMiaoShouYiArr[this.curLevel - 1], '1')}/秒`
Common5.getSpriteFrameFromBundle("ZhongCanTingShengJi", "texture/" + this.curConfig.caiMing + '/' + this.curConfig.caiPinMing[this.curLevel], this.successNode.getChildByName('caiIcon').getComponent(cc.Sprite));
this.successNode.getChildByName('caiIcon').active = false
this.successNode.getChildByName('研制成功').active = false
this.successNode.getChildByName('研制中').active = true
this.successNode.getChildByName('btnSure').active = false
this.successNode.getChildByName('光效').active = false
this.successNode.getChildByName('progressBar').active = true
this.successNode.getChildByName('progressBar').getComponent(cc.ProgressBar).progress = 0
this.startProgress = true
}
protected update(dt: number): void {
if (this.startProgress) {
this.successNode.getChildByName('progressBar').getComponent(cc.ProgressBar).progress += dt * 2 / 3
if (this.successNode.getChildByName('progressBar').getComponent(cc.ProgressBar).progress >= 1) {
Common5.playEffectCustom('CommonRes', 'sound/获得奖励')
this.startProgress = false
this.successNode.getChildByName('caiIcon').active = true
this.successNode.getChildByName('研制成功').active = true
this.successNode.getChildByName('研制中').active = false
this.successNode.getChildByName('btnSure').active = true
this.successNode.getChildByName('光效').active = true
this.successNode.getChildByName('progressBar').active = false
}
}
}
}