// Learn TypeScript: // - https://docs.cocos.com/creator/manual/en/scripting/typescript.html // Learn Attribute: // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html import UIBase from "../../common/ui/base/UIBase"; import { EventCenter } from "../../common/ui/uiEv/EventCenter"; import UIBaseEv from "../../common/ui/uiEv/UIBaseEv"; import { MSG_Event } from "../DefineMsg/LogicMsg"; import { valueObj } from "../Model/data/baseObject"; import DataManager from "../Model/data/DataManager"; import { PropLeaveUp, propType, PropUnlock } from "../Model/data/propObject"; import ProxyClientDataMgr from "../Model/ProxyClientDataMgr"; import UIUnlockVenueLayer from "../ui/UIUnlockVenueLayer"; import UIUpgradeVenueLayer from "../ui/UIUpgradeVenueLayer"; const {ccclass, property} = cc._decorator; @ccclass export default class venueUpgradeModule extends UIBaseEv { @property(cc.Label) detailStr:cc.Label = null; @property(cc.Label) levelStr:cc.Label = null; @property(cc.Label) buffStr:cc.Label = null; @property(cc.Sprite) grayBg:cc.Sprite = null; @property(cc.Label) unlockCondition:cc.Label = null; @property(cc.Button) levelUpBtn:cc.Button = null; @property(cc.Button) unlockBtn:cc.Button = null; levelUpMoney = 0; level = 0; max_level = 5; upgradeData:valueObj = null; // LIFE-CYCLE CALLBACKS: // onLoad () {} updataItem(upgradeData:valueObj) { this.upgradeData = upgradeData; this.updataUI(); } updataUI() { let itemId = this.upgradeData.getId(); let levelObj = this.upgradeData.getPropByType(propType.level) as PropLeaveUp; let unlockObj = this.upgradeData.getPropByType(propType.unlock) as PropUnlock; this.upgradeData.getPropByType(propType.unlock); let groupDesp = ProxyClientDataMgr.ins().getGroupUpDesp(itemId); let unlockDesp = ProxyClientDataMgr.ins().getUnlockDesp(itemId); let buffDesp = ProxyClientDataMgr.ins().getBuffDesp(itemId); let groupUpStr = this.getDespStr(groupDesp); let unlockStr = this.getDespStr(unlockDesp); if(unlockObj && !unlockObj.getUnLock()) { this.grayBg.node.active = true; this.unlockCondition.node.active = true; this.levelStr.string = ""; this.buffStr.string = ""; this.levelUpBtn.node.active = false; this.unlockCondition.string = unlockStr; this.unlockBtn.node.active = true; this.unlockBtn.getComponentInChildren(cc.Label).string = "解锁" } else { if( groupDesp.size=== 0) { groupUpStr = "已满级" this.levelUpBtn.interactable = false; } else { this.levelUpBtn.interactable = true; } this.grayBg.node.active = false; this.unlockCondition.node.active = false; this.unlockBtn.node.active = false; this.levelStr.string = "Lv"+levelObj.getLevel(); this.buffStr.string = buffDesp[1] as string; this.levelUpBtn.node.active = true; this.levelUpBtn.getComponentInChildren(cc.Label).string = groupUpStr; } this.detailStr.string = this.upgradeData.getName(); this.node.active = true; } getDespStr(objMap:Map):string { let str:string = "" let bGet = false; for (let[k,v] of objMap) { let kobj = ProxyClientDataMgr.ins().getValueObj(k); if(bGet) { str = str + " "; } if(k === 0) { str = str + v; } else { str = str + kobj.getName()+v; } bGet = true; } return str; } onClickEvent(event,customEventData) { switch (+customEventData) { case 0: this.levelUp(); break; case 1: this.unlock(); default: break; } } unlock() { let bUnlock = ProxyClientDataMgr.ins().isUnLockAble(this.upgradeData.getId()); if(bUnlock) { ProxyClientDataMgr.ins().doUnlockItem(this.upgradeData.getId()); this.updataUI() } else { EventCenter.emit(MSG_Event.Net_ERRO,"没有达到解锁条件哦"); } } levelUp() { let bLevelUp = ProxyClientDataMgr.ins().isGroupUpAble(this.upgradeData.getId()); if(bLevelUp) { //EventCenter.emit(MSG_Event.Net_ERRO,"没有达到解锁条件哦"); ProxyClientDataMgr.ins().doGroupUpItem(this.upgradeData.getId()); this.updataUI() } else { EventCenter.emit(MSG_Event.Net_ERRO,"没有达到升级条件哦"); } } start () { } // update (dt) {} }