45 lines
1.3 KiB
JavaScript
45 lines
1.3 KiB
JavaScript
const ItemBase = require("nx.fx.sv.expand.item");
|
|
const HeroVo = require("hero_vo");
|
|
cc.Class({
|
|
extends: ItemBase,
|
|
|
|
properties: {
|
|
fabHero:{
|
|
default:null,
|
|
type:cc.Prefab
|
|
},
|
|
},
|
|
|
|
setData(_data){
|
|
if(_data == 0){//置空
|
|
if(this.formHero){
|
|
let cmp = nx.gui.getComponent(this.formHero,"","cmp.item.base");
|
|
if(cmp){
|
|
cmp.rebind(0,null,"");
|
|
}
|
|
this.formHero.active = false;
|
|
}
|
|
return;
|
|
}
|
|
let unit_data = Utils.getUnitConfig(_data);
|
|
if(unit_data && unit_data.head_icon){
|
|
let hero = new HeroVo();
|
|
let pconfig = game.configs.partner_data.data_partner_base[Number(unit_data.head_icon)];
|
|
pconfig.lev = unit_data.lev;
|
|
pconfig.star = unit_data.star;
|
|
hero.updateHeroVo(pconfig);
|
|
if(!this.formHero){
|
|
this.formHero = cc.instantiate(this.fabHero);
|
|
this.formHero.parent = this.node;
|
|
}
|
|
this.formHero.active = true;
|
|
let cmp = nx.gui.getComponent(this.formHero,"","cmp.item.base");
|
|
if(cmp){
|
|
cmp.rebind(0,hero,"");
|
|
}
|
|
}
|
|
},
|
|
|
|
// update (dt) {},
|
|
});
|