147 lines
4.3 KiB
JavaScript
147 lines
4.3 KiB
JavaScript
|
|
const ItemBase = require( "nx.fx.sv.expand.item" );
|
||
|
|
const ItemLayout = require("cmp.common.itemlayout");
|
||
|
|
const EsecsiceController = require("esecsice_controller");
|
||
|
|
|
||
|
|
cc.Class({
|
||
|
|
extends: ItemBase,
|
||
|
|
|
||
|
|
properties: {
|
||
|
|
bg_pic:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Sprite
|
||
|
|
},
|
||
|
|
list:{
|
||
|
|
default:null,
|
||
|
|
type:ItemLayout
|
||
|
|
},
|
||
|
|
time_txt:{
|
||
|
|
default:null,
|
||
|
|
type:cc.RichText
|
||
|
|
},
|
||
|
|
limit_desc:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Label
|
||
|
|
},
|
||
|
|
timeCd:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Node
|
||
|
|
},
|
||
|
|
tag_id:0
|
||
|
|
},
|
||
|
|
|
||
|
|
// LIFE-CYCLE CALLBACKS:
|
||
|
|
|
||
|
|
onLoad () {
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
start () {
|
||
|
|
this.setData();
|
||
|
|
},
|
||
|
|
|
||
|
|
setData(){
|
||
|
|
if(this.tag_id == 0){
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
this.data = game.configs.dailyplay_data.data_exerciseactivity[this.tag_id];
|
||
|
|
|
||
|
|
if(nx.dt.objEmpty(this.data)){
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
const path = PathTool.getIconPath( "dungeon",this.data.pic_name );
|
||
|
|
nx.gui.setSpriteFrame( this.bg_pic, "", path );
|
||
|
|
|
||
|
|
let data_list = [];
|
||
|
|
for(let i in this.data.val[0]){
|
||
|
|
let bid = this.data.val[0][i];
|
||
|
|
let item_vo = {bid:bid,num:0};
|
||
|
|
data_list.push(item_vo);
|
||
|
|
}
|
||
|
|
this.list.rebuild(data_list);
|
||
|
|
|
||
|
|
if(this.data.desc){
|
||
|
|
this.time_txt.string = this.data.desc;
|
||
|
|
}
|
||
|
|
|
||
|
|
let setGray = function( _nod,_mat ){
|
||
|
|
let nod = _nod;
|
||
|
|
let sp = nx.gui.getComponent( nod, "qa", cc.Sprite );
|
||
|
|
let isp = nx.gui.getComponent( nod, "icon", cc.Sprite );
|
||
|
|
let ssp = nx.gui.getComponent( nod, "star", cc.Sprite );
|
||
|
|
let rt = nx.gui.getComponent( nod, "rt/img", cc.Sprite );
|
||
|
|
let material = _mat == 1 ? cc.Material.getBuiltinMaterial( '2d-gray-sprite' ) : cc.Material.getBuiltinMaterial( '2d-sprite' ) ;
|
||
|
|
sp.setMaterial( 0,material );
|
||
|
|
isp.setMaterial( 0,material );
|
||
|
|
ssp.setMaterial( 0,material );
|
||
|
|
rt.setMaterial( 0,material );
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
let bg_lock = this.bg_pic.node.getComponent(cc.Button);
|
||
|
|
let title_lock = nx.gui.getComponent( this, "ti_pic", cc.Button );
|
||
|
|
if(this.data.is_open == 1){
|
||
|
|
var bool = nx.bridge.checkConditions(this.data.activate);
|
||
|
|
if(!bool.val){
|
||
|
|
bg_lock.interactable = true;
|
||
|
|
this.is_lev_limit = false;
|
||
|
|
title_lock.interactable = true;
|
||
|
|
for (let i = 0; i < this.list.node.children.length; i++) {
|
||
|
|
let nod = this.list.node.children[i];
|
||
|
|
|
||
|
|
setGray( nod, 0 );
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
this.limit_desc.node.parent.active = false;
|
||
|
|
}else{
|
||
|
|
bg_lock.interactable = false;
|
||
|
|
title_lock.interactable = false;
|
||
|
|
for (let i = 0; i < this.list.node.children.length; i++) {
|
||
|
|
let nod = this.list.node.children[i];
|
||
|
|
setGray( nod, 1 );
|
||
|
|
}
|
||
|
|
this.is_lev_limit = true;
|
||
|
|
this.limit_desc.node.parent.active = true;
|
||
|
|
}
|
||
|
|
}else{
|
||
|
|
bg_lock.interactable = false;
|
||
|
|
title_lock.interactable = false;
|
||
|
|
this.is_lev_limit = true;
|
||
|
|
this.limit_desc.node.parent.active = true;
|
||
|
|
for (let i = 0; i < this.list.node.children.length; i++) {
|
||
|
|
let nod = this.list.node.children[i];
|
||
|
|
|
||
|
|
setGray( nod, 1 );
|
||
|
|
}
|
||
|
|
}
|
||
|
|
// this.limit_desc.string = cc.js.formatStr(nx.text.getKey("lab_stone_dungeon_open_level_haveval"),this.data.activate[0][1]);
|
||
|
|
|
||
|
|
|
||
|
|
//設置額外屬性
|
||
|
|
this.setOtherAttr();
|
||
|
|
},
|
||
|
|
|
||
|
|
setOtherAttr(){
|
||
|
|
if(this.timeCd && this.tag_id == 6){
|
||
|
|
let PCT = require("planesafk_controller");
|
||
|
|
let time = PCT.getInstance().getModel().getCdTime() - client.socket.getTime();
|
||
|
|
nx.gui.setCdTxt(this.timeCd,"",time);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
onClickItem(){
|
||
|
|
if(nx.dt.objEmpty(this.data)){
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
if(this.is_lev_limit){
|
||
|
|
nx.tbox(this.data.lock_desc);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
EsecsiceController.getInstance().switchEcecsiceActivityView(this.data.goto_id);
|
||
|
|
}
|
||
|
|
// update (dt) {},
|
||
|
|
});
|