Files
2026-05-23 22:10:14 +08:00

90 lines
2.0 KiB
JavaScript

const ItemBase = require( "cmp.partner.com" );
const ADVCT = require("adventure_controller");
const AdventureEVT = require("adventure_event");
cc.Class( {
extends: ItemBase,
properties: {
nodLev:{
default:null,
type:cc.Node
},
nodHp:{
default:null,
type:cc.Node
},
hpBar:{
default:null,
type:cc.ProgressBar
},
},
// 重载:刷新
freshAll: function() {
this._super();
if( (this.mdata.now_hp != null || this.mdata.hp_per!=null) ){//有血條顯示 this.mdata.now_hp >= 0 || this.mdata.hp_per > 0
this.is_select = false;//不需要選人
this.nodLev.active = false;
this.nodHp.active = true;
this.setHp();
this.setPerHp();
}else{//沒有血條
this.is_select = true;//需要選人
this.nodLev.active = true;
this.nodHp.active = false;
}
let nod = nx.gui.find( this, "qa" );
// let cfg = game.configs.partner_data.data_partner_base[this.mdata.bid];
if( nod ){
let path = this.mdata.quality != 1 ? "coms/images/mk_sqa" + this.mdata.quality : null;
nx.gui.setSpriteFrame( nod, "", path );
nx.gui.setActive( nod, "", true );
}
},
// 置空
setEmpty: function() {
this._super();
let nod = nx.gui.find( this, "qa" );
if( nod ){
nx.gui.setActive( nod, "", false );
}
},
setHp(){
this.hpBar.progress = this.mdata.now_hp/this.mdata.hp;
if(this.mdata.now_hp <= 0){//死亡
}
},
setPerHp(){
if(!this.mdata.hp_per)return;
this.hpBar.progress = this.mdata.hp_per/100;
},
onSelectHero(){
},
onFocus(){
if ( this.nodFocus) {
this.nodFocus.node.active = true;
}
},
outFocus(){
if ( this.nodFocus) {
this.nodFocus.node.active = false;
}
},
} );