92 lines
2.4 KiB
JavaScript
92 lines
2.4 KiB
JavaScript
const ArenaController = require( "arena_controller" );
|
|
|
|
|
|
cc.Class({
|
|
|
|
extends: cc.Component,
|
|
|
|
properties: {
|
|
|
|
nodCanget: { default: null, type: cc.Node },
|
|
nodGot: { default: null, type: cc.Node },
|
|
nodShow: { default: null, type: cc.Node },
|
|
nodClose: { default: null, type: cc.Node },
|
|
|
|
},
|
|
|
|
setData: function( _data, _idx, _get ){
|
|
|
|
this.mdata = _data;
|
|
this.index = _idx;
|
|
this.getInfo = _get;
|
|
|
|
this.setReward();
|
|
this.setState();
|
|
|
|
},
|
|
|
|
setState: function(){
|
|
|
|
if( nx.dt.objNEmpty( this.getInfo ) ){
|
|
let glist = this.getInfo.got.num_list;
|
|
let gotlst = [];
|
|
glist.forEach( item => {
|
|
if( item ){
|
|
gotlst.push( item.num );
|
|
}
|
|
});
|
|
// this.nodCanget
|
|
nx.gui.setColor( this, "point", this.getInfo.got.had_combat_num >= this.mdata.num ? cc.Color.WHITE : cc.Color.BLACK );
|
|
|
|
nx.gui.setActive( this.nodCanget, "", this.getInfo.got.had_combat_num >= this.mdata.num );
|
|
nx.gui.setActive( this.nodGot, "", nx.dt.arrMember( gotlst, this.mdata.num ) );
|
|
nx.gui.setActive( this.nodCanget, "tip", this.getInfo.got.had_combat_num >= this.mdata.num && !nx.dt.arrMember( gotlst, this.mdata.num ) );
|
|
}else{
|
|
nx.gui.setColor( this, "point", cc.Color.BLACK );
|
|
nx.gui.setActive( this.nodCanget, "", false );
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
setReward: function(){
|
|
// {"num":70,"items":[[37002,1]]}
|
|
nx.gui.setString( this, "point", this.mdata.num );
|
|
let nod = nx.gui.getComponent( this.nodShow, "bg/award", "cmp.common.itemlayout" );
|
|
if( nod ){
|
|
nod.rebuild( this.mdata.items );
|
|
}
|
|
},
|
|
|
|
showReward: function(){
|
|
|
|
let nod = this.node.parent;
|
|
if( nod ){
|
|
let chd = nod.children;
|
|
for (let i = 0; i < chd.length; i++) {
|
|
let n = chd[i];
|
|
if( i != this.index ){
|
|
nx.gui.setActive( n, "show", false );
|
|
}
|
|
|
|
}
|
|
}
|
|
nx.gui.setActive( this.nodShow, "", !this.nodShow.active );
|
|
nx.gui.setActive( this.nodClose, "", this.nodShow.active == true );
|
|
|
|
},
|
|
|
|
getReward: function(){
|
|
|
|
let AC = ArenaController.getInstance();
|
|
if( AC ){
|
|
AC.sender20209( this.mdata.num );
|
|
}
|
|
|
|
}
|
|
|
|
|
|
});
|