58 lines
1.1 KiB
JavaScript
58 lines
1.1 KiB
JavaScript
|
|
|
||
|
|
const ItemBase = require( "cmp.item.base" );
|
||
|
|
const HeroController = require( "hero_controller" );
|
||
|
|
|
||
|
|
cc.Class( {
|
||
|
|
|
||
|
|
extends: ItemBase,
|
||
|
|
|
||
|
|
properties: {
|
||
|
|
hp:{
|
||
|
|
default:null,
|
||
|
|
type:cc.ProgressBar
|
||
|
|
},
|
||
|
|
die:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Node
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
setEmpty: function(){
|
||
|
|
this._super();
|
||
|
|
|
||
|
|
this.hp.node.active = false;
|
||
|
|
this.die.active = false;
|
||
|
|
},
|
||
|
|
|
||
|
|
// 重载:刷新
|
||
|
|
freshAll: function() {
|
||
|
|
|
||
|
|
this._super();
|
||
|
|
|
||
|
|
// 血量刷新
|
||
|
|
this.setHp();
|
||
|
|
this.setLevel(this.info.level);
|
||
|
|
},
|
||
|
|
|
||
|
|
setHp(){
|
||
|
|
if(this.mdata.hp_per!=null){
|
||
|
|
this.hp.node.active = true;
|
||
|
|
this.hp.progress = this.mdata.hp_per/100;
|
||
|
|
if(this.mdata.hp_per <= 0){//已死亡
|
||
|
|
this.die.active = true;
|
||
|
|
}else{
|
||
|
|
this.die.active = false;
|
||
|
|
}
|
||
|
|
}else{
|
||
|
|
this.hp.node.active = false;
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
// 单设:等级
|
||
|
|
setLevel: function (_lev) {
|
||
|
|
nx.gui.setString(this.nodCount, "", "Lv." + _lev);
|
||
|
|
},
|
||
|
|
|
||
|
|
|
||
|
|
} );
|