143 lines
4.5 KiB
JavaScript
143 lines
4.5 KiB
JavaScript
|
|
const ItemBase = require( "nx.fx.sv.expand.item" );
|
||
|
|
const PathTool = require("pathtool");
|
||
|
|
const PlanesafkController = require("planesafk_controller");
|
||
|
|
const PlanesafkConst = require("planesafk_const");
|
||
|
|
|
||
|
|
cc.Class({
|
||
|
|
extends: ItemBase,
|
||
|
|
|
||
|
|
properties: {
|
||
|
|
name_txt:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Label
|
||
|
|
},
|
||
|
|
desc_txt:{
|
||
|
|
default:null,
|
||
|
|
type:cc.RichText
|
||
|
|
},
|
||
|
|
bg_sp:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Sprite
|
||
|
|
},
|
||
|
|
quality_sp:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Sprite
|
||
|
|
},
|
||
|
|
effect_sp:{
|
||
|
|
default:null,
|
||
|
|
type:cc.Sprite
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
// LIFE-CYCLE CALLBACKS:
|
||
|
|
|
||
|
|
onLoad () {
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
// 数据重置
|
||
|
|
rebind: function( _idx, _data, _key ) {
|
||
|
|
|
||
|
|
this._super( _idx, _data, _key );
|
||
|
|
|
||
|
|
// 刷新
|
||
|
|
this.setData( _data );
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
setData(data,index,key){
|
||
|
|
if(nx.dt.objEmpty(data)){
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
this.buff_cfg = data;
|
||
|
|
|
||
|
|
// 名称
|
||
|
|
this.name_txt.string = this.buff_cfg.name;
|
||
|
|
// 描述
|
||
|
|
this.desc_txt.string = this.buff_cfg.desc;
|
||
|
|
// 图标
|
||
|
|
// var icon_res = PathTool.getIconPath("bufficon",this.buff_cfg.res_id)//_string_format("resource/planes/buff_icon/%s.png", this.buff_cfg.res_id)
|
||
|
|
// //this.icon_sp_load = loadSpriteTextureFromCDN(this.icon_sp, icon_res, ResourcesType.single, this.icon_sp_load)
|
||
|
|
// this.icon_sp_load = nx.gui.setSpriteFrame(this.icon_sp,"",icon_res);
|
||
|
|
|
||
|
|
|
||
|
|
// 品质图标
|
||
|
|
var qua_icon_res = this.getQualityIconRes(this.buff_cfg.quality)
|
||
|
|
nx.gui.setSpriteFrame(this.bg_sp.node,"",qua_icon_res);
|
||
|
|
|
||
|
|
// 功能图标
|
||
|
|
var s_icon_res = cc.js.formatStr("prefab/pve/planesafk/icon/%s",this.buff_cfg.res_id);
|
||
|
|
nx.gui.setSpriteFrame(this.quality_sp.node,"",s_icon_res);
|
||
|
|
|
||
|
|
// 效果图标
|
||
|
|
var effect_res = "";
|
||
|
|
var range_cfg = this.buff_cfg.range;
|
||
|
|
|
||
|
|
if ( nx.dt.arrNEmpty( range_cfg ) ) {
|
||
|
|
var effect_type = range_cfg[0][0]
|
||
|
|
var effect_val = range_cfg[0][1]
|
||
|
|
if (effect_type == "career_type") { // 职业
|
||
|
|
effect_res = cc.path.join( "prefab/pve/planesafk/icon/icon_career" + effect_val ) ;
|
||
|
|
} else if (effect_type == "camp_type") { // 阵营
|
||
|
|
effect_res = cc.path.join( "prefab/pve/planesafk/icon/icon_camp" + effect_val );
|
||
|
|
// effect_res = PathTool.getBattleCampIconByType(effect_val)
|
||
|
|
} else if ( effect_type == "partner") { // 英雄
|
||
|
|
effect_res = cc.path.join( "prefab/pve/planesafk/icon/icon_warfare_11" );
|
||
|
|
} else {
|
||
|
|
effect_res = cc.path.join( "prefab/pve/planesafk/icon/icon_camp0" );
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else // 全部
|
||
|
|
{
|
||
|
|
effect_res = "prefab/pve/planesafk/icon/icon_camp0";
|
||
|
|
}
|
||
|
|
|
||
|
|
if ( nx.dt.strNEmpty( effect_res ) ) {
|
||
|
|
this.effect_sp.active =(true)
|
||
|
|
nx.gui.setSpriteFrame(this.effect_sp,"",effect_res)
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
nx.gui.setSpriteFrame(this.effect_sp,"",effect_res)
|
||
|
|
this.effect_sp.active =(false)
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
// 根据品质获取品质图标资源
|
||
|
|
getQualityIconRes:function( quality ){
|
||
|
|
if (quality == PlanesafkConst.Buff_Quility.Blue) {
|
||
|
|
return cc.js.formatStr("prefab/pve/planesafk/icon/%s","bg_warfare_blue");
|
||
|
|
}
|
||
|
|
else if (quality == PlanesafkConst.Buff_Quility.Purple) {
|
||
|
|
return cc.js.formatStr("prefab/pve/planesafk/icon/%s","bg_warfare_puple");
|
||
|
|
}
|
||
|
|
else if (quality == PlanesafkConst.Buff_Quility.Orange) {
|
||
|
|
return cc.js.formatStr("prefab/pve/planesafk/icon/%s","bg_warfare_glod");
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
return cc.js.formatStr("prefab/pve/planesafk/icon/%s","bg_warfare_blue");
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
getCareerRes(effect_val){
|
||
|
|
return cc.js.formatStr("prefab/pve/planesafk/icon/icon_warfare_0%s",effect_val+1);
|
||
|
|
},
|
||
|
|
|
||
|
|
getBattleCampIconByType(effect_val){
|
||
|
|
return cc.js.formatStr("prefab/pve/planesafk/icon/icon_warfare_0%s",effect_val+5);
|
||
|
|
},
|
||
|
|
|
||
|
|
onClickChoseBtn:function( ){
|
||
|
|
if (this.buff_cfg) {
|
||
|
|
let buff_id = this.buff_cfg.buff_id;
|
||
|
|
var extend = {};
|
||
|
|
extend.buff_id = buff_id;
|
||
|
|
extend.data = this.buff_cfg;
|
||
|
|
PlanesafkController.getInstance().sender28600( this.buff_cfg.line, this.buff_cfg.index, 1, [{type:PlanesafkConst.Proto_28600._5, val1:buff_id, val2 : 0}], extend )
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// update (dt) {},
|
||
|
|
});
|