169 lines
4.9 KiB
TypeScript
169 lines
4.9 KiB
TypeScript
// 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 { MSG_Event } from "../DefineMsg/LogicMsg";
|
|
import { valueObj } from "../Model/data/baseObject";
|
|
import { PropLeaveUp, propType, PropUnlock } from "../Model/data/propObject";
|
|
import ProxyClientDataMgr from "../Model/ProxyClientDataMgr";
|
|
|
|
const {ccclass, property} = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class fishingUpgradeModule extends UIBase {
|
|
|
|
@property(cc.ProgressBar)
|
|
progressBar:cc.ProgressBar = null;
|
|
@property(cc.Button)
|
|
levelUpBtn:cc.Button = null;
|
|
@property(cc.Sprite)
|
|
grayBg:cc.Sprite = null;
|
|
@property(cc.Label)
|
|
unlockConditionStr:cc.Label = null;
|
|
@property(cc.Label)
|
|
detailStr:cc.Label = null;
|
|
@property(cc.Button)
|
|
unlockBtn:cc.Button = null;
|
|
|
|
fashingFacility:valueObj = null;
|
|
|
|
maxLevel = 11;
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
// onLoad () {}
|
|
init()
|
|
{
|
|
|
|
}
|
|
|
|
onShow(objData:valueObj)
|
|
{
|
|
this.fashingFacility = objData;
|
|
//this.
|
|
this.updataUI();
|
|
}
|
|
|
|
updataUI()
|
|
{
|
|
let fashingFacility = this.fashingFacility;
|
|
let facilityId = fashingFacility.getId();
|
|
let unLockObj = fashingFacility.getPropByType(propType.unlock) as PropUnlock;
|
|
let levelObj = fashingFacility.getPropByType(propType.level) as PropLeaveUp;
|
|
let unLockDespObj = ProxyClientDataMgr.ins().getUnlockDesp(facilityId);
|
|
let unLockStr:string = this.getDespStr(unLockDespObj)
|
|
let groupDesp = ProxyClientDataMgr.ins().getGroupUpDesp(facilityId);
|
|
let groupUpStr:string = this.getDespStr(groupDesp)
|
|
|
|
this.detailStr.string = fashingFacility.getName();
|
|
if(unLockObj&& !unLockObj.getUnLock())
|
|
{
|
|
this.progressBar.progress = 0;
|
|
this.unlockConditionStr.node.active = true;
|
|
this.grayBg.node.active = true;
|
|
this.unlockConditionStr.string = unLockStr;
|
|
this.levelUpBtn.node.active = false;
|
|
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.progressBar.progress = levelObj.getLevel()/this.maxLevel;
|
|
this.unlockConditionStr.node.active = false;
|
|
this.grayBg.node.active = false;
|
|
this.levelUpBtn.node.active = true;
|
|
this.levelUpBtn.getComponentInChildren(cc.Label).string = groupUpStr
|
|
this.unlockBtn.node.active = false;
|
|
this.progressBar.getComponentInChildren(cc.Label).string = "Lv"+levelObj.getLevel()
|
|
}
|
|
|
|
this.node.active = true;
|
|
|
|
}
|
|
|
|
getDespStr(objMap:Map<number,string>):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.fashingFacility.getId());
|
|
if(bUnlock)
|
|
{
|
|
ProxyClientDataMgr.ins().doUnlockItem(this.fashingFacility.getId());
|
|
this.updataUI()
|
|
}
|
|
else
|
|
{
|
|
EventCenter.emit(MSG_Event.Net_ERRO,"没有达到解锁条件哦");
|
|
}
|
|
}
|
|
|
|
levelUp()
|
|
{
|
|
let bLevelUp = ProxyClientDataMgr.ins().isGroupUpAble(this.fashingFacility.getId());
|
|
if(bLevelUp)
|
|
{
|
|
//EventCenter.emit(MSG_Event.Net_ERRO,"没有达到解锁条件哦");
|
|
ProxyClientDataMgr.ins().doGroupUpItem(this.fashingFacility.getId());
|
|
this.updataUI()
|
|
}
|
|
else
|
|
{
|
|
EventCenter.emit(MSG_Event.Net_ERRO,"没有达到升级条件哦");
|
|
}
|
|
}
|
|
|
|
start () {
|
|
|
|
}
|
|
|
|
// update (dt) {}
|
|
}
|