|
|
|
// Learn TypeScript:
|
|
|
|
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
|
|
|
|
// Learn Attribute:
|
|
|
|
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
|
|
|
|
// Learn life-cycle callbacks:
|
|
|
|
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
|
|
|
|
|
|
|
|
import { ryw_Event } from "../../FrameWork/Event/EventEnum";
|
|
|
|
import EventMgr from "../../FrameWork/Event/EventMgr";
|
|
|
|
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";
|
|
|
|
import PrefabManage, { GameType } from "../PrefabManager/PrefabManage";
|
|
|
|
|
|
|
|
const { ccclass, property } = cc._decorator;
|
|
|
|
|
|
|
|
@ccclass
|
|
|
|
export default class JieDaoItemNode extends cc.Component {
|
|
|
|
|
|
|
|
@property(cc.Sprite)
|
|
|
|
icon: cc.Sprite = null;
|
|
|
|
|
|
|
|
@property(cc.Label)
|
|
|
|
title_str: cc.Label = null;
|
|
|
|
|
|
|
|
@property(cc.RichText)
|
|
|
|
lockBeiShu: cc.RichText = null;
|
|
|
|
|
|
|
|
@property(cc.Label)
|
|
|
|
unlockBeiShu: cc.Label = null;
|
|
|
|
|
|
|
|
config: any;
|
|
|
|
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
|
|
|
|
// 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)
|
|
|
|
this.refreshState()
|
|
|
|
}
|
|
|
|
|
|
|
|
onTouchQieHuan() {
|
|
|
|
JieDaoManager.setJieDaoInUse(this.config.level)
|
|
|
|
EventMgr.emitEvent_custom(ryw_Event.RefreshJieDao)
|
|
|
|
}
|
|
|
|
|
|
|
|
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 {
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
checkTask() {
|
|
|
|
let ziChanData = User.getZiChanData()
|
|
|
|
let mainTaskInfo: any = TaskManager.getCurUnLockMainTaskInfo()
|
|
|
|
let mainId = mainTaskInfo.Id
|
|
|
|
// if (mainId == MainTaskIdEnum.MainTask_514_2 && ziChanData.unLockNum[0] >= 1) {
|
|
|
|
// TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_514_2)
|
|
|
|
// TaskManager.setCurTask(MainTaskIdEnum.MainTask_515)
|
|
|
|
// }else if (mainId == MainTaskIdEnum.MainTask_532 && ziChanData.unLockNum[1] >= 1) {
|
|
|
|
// TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_532)
|
|
|
|
// TaskManager.setCurTask(MainTaskIdEnum.MainTask_533)
|
|
|
|
// }else if (mainId == MainTaskIdEnum.MainTask_542 && ziChanData.unLockNum[2] >= 1) {
|
|
|
|
// TaskManager.finishCurMainTask(MainTaskIdEnum.MainTask_542)
|
|
|
|
// TaskManager.setCurTask(MainTaskIdEnum.MainTask_543_1)
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
// update (dt) {}
|
|
|
|
}
|