|
|
|
@ -11,6 +11,7 @@ import User from "../../FrameWork/User/User"; |
|
|
|
|
import Common5 from "../../Platform/th/Common5"; |
|
|
|
|
import TaskManager, { MainTaskIdEnum } from "../JuQingChat/TaskManager"; |
|
|
|
|
import BagManager from "../Manager/BagManager"; |
|
|
|
|
import JieDaoManager from "../Manager/JieDaoManager"; |
|
|
|
|
import LevelUpManager from "../Manager/LevelUpManager"; |
|
|
|
|
import ShipuManager from "../Manager/ShipuManager"; |
|
|
|
|
import UserManager from "../Manager/UserManager"; |
|
|
|
@ -27,8 +28,11 @@ export default class JieDaoItemNode extends cc.Component { |
|
|
|
|
@property(cc.Label) |
|
|
|
|
title_str: cc.Label = null; |
|
|
|
|
|
|
|
|
|
@property(cc.RichText) |
|
|
|
|
lockBeiShu: cc.RichText = null; |
|
|
|
|
|
|
|
|
|
@property(cc.Label) |
|
|
|
|
beishu: cc.Label = null; |
|
|
|
|
unlockBeiShu: cc.Label = null; |
|
|
|
|
|
|
|
|
|
config: any; |
|
|
|
|
|
|
|
|
@ -37,71 +41,45 @@ export default class JieDaoItemNode extends cc.Component { |
|
|
|
|
// onLoad () {}
|
|
|
|
|
|
|
|
|
|
start() { |
|
|
|
|
|
|
|
|
|
EventMgr.onEvent_custom(ryw_Event.RefreshJieDao, () => { |
|
|
|
|
this.refreshState() |
|
|
|
|
}, this) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
init(data) { |
|
|
|
|
this.config = data |
|
|
|
|
Common5.getSpriteFrameFromBundle("JieDao", this.config.icon, this.icon) |
|
|
|
|
// Common5.addUrlSprite_custom(this.config.icon, this.icon)
|
|
|
|
|
Common5.getSpriteFrameFromBundle("ZiChan", this.config.icon, this.icon) |
|
|
|
|
this.title_str.string = data.descLab |
|
|
|
|
let ziChanData = User.getZiChanData() |
|
|
|
|
let level = User.getMyLevel() |
|
|
|
|
//是否满足解锁条件
|
|
|
|
|
if (ziChanData.unLockNum[this.config.configId] == -1 && ShipuManager.getShipuUnLockNum() >= this.config.unLockNum && level >= this.config.unLockLevel) { |
|
|
|
|
ziChanData.unLockNum[this.config.configId] = 0 |
|
|
|
|
} |
|
|
|
|
if (ziChanData.unLockNum[this.config.configId] == -1 && ShipuManager.getShipuUnLockNum() >= this.config.unLockNum) { |
|
|
|
|
// 变棕色
|
|
|
|
|
// this.str1.node.color = cc.color(33, 152, 0)
|
|
|
|
|
} |
|
|
|
|
if (ziChanData.unLockNum[this.config.configId] == -1 && level >= this.config.unLockLevel) { |
|
|
|
|
// 变棕色
|
|
|
|
|
// this.str2.node.color = cc.color(33, 152, 0)
|
|
|
|
|
} |
|
|
|
|
let unLockNum = ziChanData.unLockNum[this.config.configId] <= 0 ? 0 : ziChanData.unLockNum[this.config.configId] |
|
|
|
|
if (unLockNum > 0) { |
|
|
|
|
this.beishu.string = `秒赚倍数:${this.config.miaozhuan[unLockNum - 1]}倍` |
|
|
|
|
} else { |
|
|
|
|
this.beishu.string = `秒赚倍数:${0}倍` |
|
|
|
|
} |
|
|
|
|
if (unLockNum >= 0) { |
|
|
|
|
} |
|
|
|
|
this.refreshState() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
refreshState() { |
|
|
|
|
let ziChanData = User.getZiChanData() |
|
|
|
|
if (ziChanData.unLockNum[this.config.configId] == -1) { |
|
|
|
|
} else if (ziChanData.unLockNum[this.config.configId] < this.config.shuliang) { |
|
|
|
|
} else { |
|
|
|
|
if (this.config.name == '镇中心门店' && TaskManager.getCurUnLockMainTaskId() >= MainTaskIdEnum.MainTask_516_1 && TaskManager.getCurUnLockMainTaskId() <= MainTaskIdEnum.MainTask_517) { |
|
|
|
|
}else{ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
onTouchQieHuan() { |
|
|
|
|
JieDaoManager.setJieDaoInUse(this.config.level) |
|
|
|
|
EventMgr.emitEvent_custom(ryw_Event.RefreshJieDao) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
onTouchShop() { |
|
|
|
|
// //Common5.playEffect("sound/按键点击")
|
|
|
|
|
Common5.playRemoteAudioEffect('sound/diandiandian/升级音效') |
|
|
|
|
let ziChanData = User.getZiChanData() |
|
|
|
|
//是否满足解锁条件
|
|
|
|
|
if (ziChanData.unLockNum[this.config.configId] == -1 && ShipuManager.getShipuUnLockNum() >= this.config.unLockNum) { |
|
|
|
|
ziChanData.unLockNum[this.config.configId] = 0 |
|
|
|
|
} |
|
|
|
|
UserManager.subMoney(this.config.jiesuoMoney[ziChanData.unLockNum[this.config.configId]]) |
|
|
|
|
|
|
|
|
|
// ziChanData = {curshouyi:0,getnum:0,shouyi:0,unLockNum:[-1,-1,-1,-1]}
|
|
|
|
|
if (ziChanData.unLockNum[this.config.configId] == -1) { |
|
|
|
|
ziChanData.unLockNum[this.config.configId] = 1 |
|
|
|
|
refreshState() { |
|
|
|
|
this.title_str.string = this.config.descLab |
|
|
|
|
let inUse = JieDaoManager.getJieDaoInUse() |
|
|
|
|
if (inUse == this.config.level) { |
|
|
|
|
this.icon.node.getChildByName("图片遮罩").active = false |
|
|
|
|
this.node.getChildByName("使用中").active = true |
|
|
|
|
this.node.getChildByName("切换").active = false |
|
|
|
|
this.node.getChildByName("加成框").active = true |
|
|
|
|
this.node.getChildByName("加成框锁").active = false |
|
|
|
|
this.unlockBeiShu.string = this.config.jiesuoBeiShu == 1 ? '无加成' : `单价加成${this.config.jiesuoBeiShu * 100}%` |
|
|
|
|
this.unlockBeiShu["_forceUpdateRenderData"](true); |
|
|
|
|
this.unlockBeiShu.node.parent.setContentSize(cc.size(this.lockBeiShu.node.getContentSize().width + 30, this.lockBeiShu.node.parent.getContentSize().height)) |
|
|
|
|
} else { |
|
|
|
|
ziChanData.unLockNum[this.config.configId] += 1 |
|
|
|
|
this.icon.node.getChildByName("图片遮罩").active = true |
|
|
|
|
this.node.getChildByName("切换").active = true |
|
|
|
|
this.node.getChildByName("使用中").active = false |
|
|
|
|
this.node.getChildByName("加成框").active = false |
|
|
|
|
this.node.getChildByName("加成框锁").active = true |
|
|
|
|
let str1 = `<color=#ffffff><outline color=#3677A2 width=1><bold>无加成</color>` |
|
|
|
|
let str2 = `<color=#ffffff><outline color=#3677A2 width=1><bold>单价加成</c><color=#FFF669><outline color=#3677A2 width=1>${this.config.jiesuoBeiShu * 100}%<bold></color>` |
|
|
|
|
this.lockBeiShu.string = this.config.jiesuoBeiShu == 1 ? str1 : str2 |
|
|
|
|
} |
|
|
|
|
User.setZiChanData(ziChanData) |
|
|
|
|
this.init(this.config) |
|
|
|
|
EventMgr.emitEvent_custom(ryw_Event.RefreshZiChan) |
|
|
|
|
|
|
|
|
|
this.checkTask() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
checkTask() { |
|
|
|
|