104 lines
2.6 KiB
JavaScript
104 lines
2.6 KiB
JavaScript
/******************************************************************
|
|
*
|
|
* 伙伴信息页 --- 基本属性
|
|
*
|
|
******************************************************************/
|
|
|
|
const BridgeComponent = require( "bridge.component" );
|
|
|
|
const HeroConst = require( "hero_const" );
|
|
const HeroEvent = require( "hero_event" );
|
|
const HeroControl = require( "hero_controller" );
|
|
|
|
cc.Class( {
|
|
|
|
extends: BridgeComponent,
|
|
|
|
properties: {
|
|
lstAttrs: { default: null, type: cc.Node },
|
|
},
|
|
|
|
// 显示
|
|
onEnable: function() {
|
|
|
|
// 视图监听
|
|
this.vbind( [
|
|
[ "ShowPartner", this.onPartnerChanged.bind( this ) ]
|
|
] );
|
|
|
|
// 事件监听
|
|
this.bindGEvent( HeroEvent.Hero_Data_Update, this.onPartnerUpdate.bind( this ) );
|
|
this.bindGEvent( HeroEvent.Equip_Update_Event, this.onPartnerUpdate.bind( this ) );
|
|
|
|
},
|
|
|
|
// 隐藏
|
|
onDisable: function() {
|
|
|
|
// 视图监听解除
|
|
this.vunbind();
|
|
|
|
// 事件监听解除
|
|
this.unbindGEvents();
|
|
|
|
},
|
|
|
|
// 置空
|
|
setEmpty: function() {
|
|
nx.gui.setActive( this, "help", false );
|
|
nx.gui.hideAllChildren( this.lstAttrs, "" );
|
|
},
|
|
|
|
// 有伙伴数据更新
|
|
onPartnerUpdate: function( _vo ) {
|
|
|
|
if( _vo &&
|
|
this.partner &&
|
|
_vo.partner_id == this.partner.partner_id ) {
|
|
this.onPartnerChanged( _vo );
|
|
}
|
|
},
|
|
|
|
// 伙伴更新
|
|
onPartnerChanged: function( _partner ) {
|
|
|
|
this.partner = _partner;
|
|
|
|
// 置空
|
|
if( nx.dt.objEmpty( this.partner ) ) {
|
|
this.setEmpty();
|
|
return;
|
|
}
|
|
|
|
// 单设
|
|
let single = function( _node, _base = 0, _add = 0 ) {
|
|
|
|
nx.gui.setString( _node, "now", _base );
|
|
|
|
if( _add <= 0 ) {
|
|
nx.gui.setActive( _node, "add", false );
|
|
} else {
|
|
nx.gui.setActive( _node, "add", true );
|
|
nx.gui.setString( _node, "add/num", _add );
|
|
}
|
|
};
|
|
|
|
// 属性
|
|
single( nx.gui.find( this.lstAttrs, 'hp' ), this.partner.hp, this.partner.skin_hp );
|
|
single( nx.gui.find( this.lstAttrs, 'atk' ), this.partner.atk, this.partner.skin_atk );
|
|
single( nx.gui.find( this.lstAttrs, 'def' ), this.partner.def, this.partner.skin_def );
|
|
single( nx.gui.find( this.lstAttrs, 'spd' ), this.partner.speed, this.partner.skin_speed );
|
|
|
|
},
|
|
|
|
// 点击详情
|
|
onTouchDetail: function() {
|
|
|
|
if( nx.dt.objNEmpty( this.partner ) ) {
|
|
const HC = HeroControl.getInstance();
|
|
HC.openHeroTipsAttrPanel( true, this.partner, true );
|
|
}
|
|
},
|
|
|
|
} );
|