153 lines
4.4 KiB
TypeScript
153 lines
4.4 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
|
||
|
||
const {ccclass, property} = cc._decorator;
|
||
import UIBase from "../../common/ui/base/UIBase";
|
||
import { PanelType } from "../../common/ui/config/SysDefine";
|
||
import { EventCenter } from "../../common/ui/uiEv/EventCenter";
|
||
import { MSG_Event } from "../DefineMsg/LogicMsg";
|
||
import { composeObj } from "../Model/data/baseObject";
|
||
import ProxyClientDataMgr from "../Model/ProxyClientDataMgr";
|
||
import ToolFunc from "../ToolFunc";
|
||
import UIUpgradeVenueLayer from "./UIUpgradeVenueLayer";
|
||
export enum BTN_TYPE{
|
||
UNLOCK,
|
||
CANCLE,
|
||
}
|
||
@ccclass
|
||
export default class UIUnlockVenueLayer extends UIBase {
|
||
|
||
panelType: PanelType = PanelType.PopUp;
|
||
|
||
@property(cc.Button)
|
||
cancleBtn:cc.Button = null;
|
||
|
||
@property(cc.Button)
|
||
unlockBtn:cc.Button = null;
|
||
|
||
@property(cc.Sprite)
|
||
venueNameSpr:cc.Sprite = null;
|
||
|
||
@property(cc.Sprite)
|
||
venueBgSpr:cc.Sprite = null;
|
||
|
||
@property(cc.Sprite)
|
||
venueSpr:cc.Sprite = null;
|
||
|
||
@property(cc.Sprite)
|
||
venueCoinSpr:cc.Sprite = null;
|
||
|
||
@property(cc.Label)
|
||
conditionStr:cc.Label = null;
|
||
|
||
@property(cc.Label)
|
||
conditionGetStr:cc.Label = null;
|
||
|
||
@property(cc.Label)
|
||
conditionMoneyStr:cc.Label = null;
|
||
|
||
parent = null;
|
||
|
||
venueData:composeObj = null;
|
||
|
||
onClickEvent(event,customEventData)
|
||
{
|
||
let node = event.target;
|
||
let button = node.getComponent(cc.Button);
|
||
switch (+customEventData) {
|
||
case BTN_TYPE.UNLOCK:
|
||
|
||
//
|
||
this.checkUnlock();
|
||
console.log("0000000");
|
||
break;
|
||
case BTN_TYPE.CANCLE:
|
||
//ToolFunc.ins.closeAction(this.node);
|
||
UIUnlockVenueLayer.closeView();
|
||
console.log("1111111");
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
// LIFE-CYCLE CALLBACKS:
|
||
|
||
// onLoad () {}
|
||
|
||
checkUnlock():void
|
||
{
|
||
let bUnlock = ProxyClientDataMgr.ins().isUnLockAble(this.venueData.getId());
|
||
if(bUnlock)
|
||
{
|
||
//EventCenter.emit(MSG_Event.Net_ERRO,"没有达到解锁条件哦");
|
||
ProxyClientDataMgr.ins().doUnlockItem(this.venueData.getId());
|
||
UIUpgradeVenueLayer.openView(this.venueData);
|
||
UIUnlockVenueLayer.closeView();
|
||
}
|
||
else
|
||
{
|
||
EventCenter.emit(MSG_Event.Net_ERRO,"没有达到解锁条件哦");
|
||
}
|
||
// this.parent.openPanel(1,{});
|
||
// ToolFunc.ins.closeAction(this.node);
|
||
}
|
||
|
||
updataUI():void
|
||
{
|
||
let venueId = this.venueData.getId();
|
||
let tempMap = ProxyClientDataMgr.ins().getUnlockDesp(venueId);
|
||
let bUnlock = ProxyClientDataMgr.ins().isUnLockAble(venueId);
|
||
for (let [idkey, desp] of tempMap) {
|
||
if(idkey == 1001)
|
||
{
|
||
this.conditionMoneyStr.string = desp+"金币"
|
||
}
|
||
else
|
||
{
|
||
this.conditionStr.string = "前置条件:"+desp;
|
||
}
|
||
}
|
||
|
||
if(bUnlock)
|
||
{
|
||
this.conditionGetStr.string = "(已完成)";
|
||
}
|
||
|
||
this.unlockBtn.getComponentInChildren(cc.Label).string = "解锁"+this.venueData.getName();
|
||
|
||
|
||
// this.parent = parent;
|
||
// var self = this;
|
||
// cc.resources.load("monkey1",cc.SpriteFrame,function(err,spriteFrame:cc.SpriteFrame){
|
||
// self.venueNameSpr.spriteFrame = spriteFrame;
|
||
// })
|
||
|
||
// cc.resources.load("monkey1",cc.SpriteFrame,function(err,spriteFrame:cc.SpriteFrame){
|
||
// self.unlockBtn.normalSprite = spriteFrame;
|
||
// self.unlockBtn.pressedSprite = spriteFrame;
|
||
// self.unlockBtn.hoverSprite = spriteFrame;
|
||
// })
|
||
// this.conditionStr.string = "前置条件:9磅15便士";
|
||
// this.conditionGetStr.string = "(未完成)";
|
||
// this.conditionMoneyStr.string = "1000"+"金币";
|
||
}
|
||
|
||
onShow(venueData:composeObj)
|
||
{
|
||
this.venueData = venueData;
|
||
this.updataUI();
|
||
}
|
||
|
||
start () {
|
||
|
||
|
||
}
|
||
|
||
// update (dt) {}
|
||
}
|