220 lines
5.8 KiB
JavaScript
220 lines
5.8 KiB
JavaScript
|
|
/******************************************************************
|
||
|
|
*
|
||
|
|
* 技能学习界面
|
||
|
|
*
|
||
|
|
******************************************************************/
|
||
|
|
|
||
|
|
const BridgeWindow = require( "bridge.window" );
|
||
|
|
const FxSVC = require( "nx.fx.sv.expand" );
|
||
|
|
const HeroConst = require( "hero_const" );
|
||
|
|
const HeroController = require( "hero_controller" );
|
||
|
|
const BackpackController = require( "backpack_controller" );
|
||
|
|
|
||
|
|
const HCT = HeroConst.CareerType;
|
||
|
|
|
||
|
|
// --英雄职业对应名字
|
||
|
|
const HCTNames = {
|
||
|
|
[ HCT.eMagician ]: "order_magician",
|
||
|
|
[ HCT.eWarrior ]: "order_warrior",
|
||
|
|
[ HCT.eTank ]: "order_tank",
|
||
|
|
[ HCT.eSsistant ]: "order_ssistant",
|
||
|
|
};
|
||
|
|
|
||
|
|
cc.Class( {
|
||
|
|
|
||
|
|
extends: BridgeWindow,
|
||
|
|
|
||
|
|
properties: {
|
||
|
|
|
||
|
|
svcList: { default: null, type: FxSVC },
|
||
|
|
curDesc: { default: null, type: cc.Node },
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
// 重载:参数打开
|
||
|
|
onOpenConfigs: function( _params ) {
|
||
|
|
|
||
|
|
this.partner = _params.hero_vo;
|
||
|
|
this.cb = _params.cb;
|
||
|
|
|
||
|
|
this.fresh();
|
||
|
|
},
|
||
|
|
|
||
|
|
// 重载:关闭前
|
||
|
|
onPreClosed: function() {
|
||
|
|
|
||
|
|
this.svcList.rebuild( [] );
|
||
|
|
},
|
||
|
|
|
||
|
|
// 刷新
|
||
|
|
fresh: function() {
|
||
|
|
|
||
|
|
// 统计已有技能
|
||
|
|
const had = {};
|
||
|
|
const sks = this.partner.talent_skill_list;
|
||
|
|
for( let pos in sks ) {
|
||
|
|
let id = sks[ pos ];
|
||
|
|
had[ id ] = pos;
|
||
|
|
}
|
||
|
|
|
||
|
|
const HC = HeroController.getInstance();
|
||
|
|
const HM = HC.getModel();
|
||
|
|
|
||
|
|
// 统计推荐技能
|
||
|
|
const commends = {};
|
||
|
|
const csks = game.configs.partner_skill_data.data_partner_commend_skill[this.partner.bid];
|
||
|
|
if( csks ) {
|
||
|
|
for( let i in csks ) {
|
||
|
|
let id = csks[i];
|
||
|
|
commends[id] = (i+1);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// 筛选可学技能
|
||
|
|
this.skills = [];
|
||
|
|
const libs = game.configs.partner_skill_data.data_partner_skill_learn;
|
||
|
|
const reds = HM.getTalentRedpointRecord();
|
||
|
|
for( let id in libs ) {
|
||
|
|
|
||
|
|
let cfgs = libs[id];
|
||
|
|
let sdt = {
|
||
|
|
id: id,
|
||
|
|
config: cfgs,
|
||
|
|
order: cfgs.order,
|
||
|
|
career_order: 1000,
|
||
|
|
order_had: 2, // 已拥有
|
||
|
|
order_can: 2, // 可领悟
|
||
|
|
};
|
||
|
|
|
||
|
|
// 该英雄有单独推荐的
|
||
|
|
if( commends[id] ) {
|
||
|
|
sdt.career_order = commends[id];
|
||
|
|
} else {
|
||
|
|
// 特定职业排序
|
||
|
|
let key = HCTNames[this.partner.type];
|
||
|
|
if( nx.dt.strNEmpty( key ) ) {
|
||
|
|
sdt.career_order = cfgs[key];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// // 已经有了
|
||
|
|
// if( had[id] ) {
|
||
|
|
// sdt.order_had = 1;
|
||
|
|
// }
|
||
|
|
|
||
|
|
// 可领悟
|
||
|
|
if( reds[id] ) {
|
||
|
|
sdt.order_can = 1;
|
||
|
|
}
|
||
|
|
|
||
|
|
this.skills.push( sdt );
|
||
|
|
}
|
||
|
|
|
||
|
|
// 排序
|
||
|
|
let fnc = Utils.tableLowerSorter(["order_had", "order_can", "career_order", "order"])
|
||
|
|
this.skills.sort(fnc)
|
||
|
|
|
||
|
|
// 重置
|
||
|
|
this.svcList.rebuild( this.skills );
|
||
|
|
|
||
|
|
// 设置默认
|
||
|
|
this.scheduleOnce( () => {
|
||
|
|
this.onFocusChanged( { mdata: this.skills[ 0 ], index : 0 } );
|
||
|
|
}, 0.1 );
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
// 选中切换
|
||
|
|
onFocusChanged: function( _item ) {
|
||
|
|
|
||
|
|
// 空
|
||
|
|
if( !_item || !_item.mdata ) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
nx.audio.playSFX( "audios/effects/touchitem" );
|
||
|
|
// 聚焦
|
||
|
|
this.svcList.cleanFocus();
|
||
|
|
this.svcList.addFocus( _item.index );
|
||
|
|
this.setCurrent( _item.mdata );
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
// 设置当前
|
||
|
|
setCurrent: function( _data ) {
|
||
|
|
|
||
|
|
let info = gskilldata( 'data_get_skill', _data.id );
|
||
|
|
if( nx.dt.objEmpty( info ) ) {
|
||
|
|
nx.gui.setActive( this.curDesc, "", false );
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
this.sid = _data.id;
|
||
|
|
nx.gui.setActive( this.curDesc, "", true );
|
||
|
|
|
||
|
|
// 名字
|
||
|
|
nx.gui.setString( this.curDesc, "name", nx.text.getKey( info.name ) );
|
||
|
|
|
||
|
|
// 图标设置
|
||
|
|
nx.bridge.setIcon( this.curDesc, "icon", info.icon );
|
||
|
|
|
||
|
|
// 描述设置
|
||
|
|
let detail = nx.gui.find( this.curDesc, "detail/view/content" );
|
||
|
|
if( detail ) {
|
||
|
|
|
||
|
|
// 描述
|
||
|
|
let desc = nx.text.getKey( info.des || info.desc );
|
||
|
|
nx.gui.setString( detail, "desc/txt", desc );
|
||
|
|
|
||
|
|
// 冷却
|
||
|
|
let txt = nx.text.getKey( "SkillCD1" );
|
||
|
|
if( info.cd > 0 ) {
|
||
|
|
txt = nx.text.format( "SkillCD2", info.cd );
|
||
|
|
}
|
||
|
|
if( info.fire_cd != 0 ) {
|
||
|
|
txt += nx.text.format( "SkillCD3", info.fire_cd );
|
||
|
|
}
|
||
|
|
nx.gui.setString( detail, "cd/txt", txt );
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
// 学习面板
|
||
|
|
let node = nx.gui.find( this.curDesc, "learn" );
|
||
|
|
if( node ) {
|
||
|
|
|
||
|
|
let BC = BackpackController.getInstance();
|
||
|
|
let BM = BC.getModel();
|
||
|
|
|
||
|
|
// 耗材
|
||
|
|
let expend = _data ? _data.config.expend : [];
|
||
|
|
let temp = nx.gui.find( node, "needs" );
|
||
|
|
for( let i = 0; i < temp.children.length; ++i ) {
|
||
|
|
|
||
|
|
let item = temp.children[i];
|
||
|
|
let info = expend[i];
|
||
|
|
if( !info ) {
|
||
|
|
nx.gui.setActive( item, "", false );
|
||
|
|
continue;
|
||
|
|
}
|
||
|
|
|
||
|
|
nx.gui.setActive( item, "", true );
|
||
|
|
let cmp = nx.gui.getComponent( item, "", "cmp.item.base" );
|
||
|
|
if( cmp ) {
|
||
|
|
cmp.setData( info[0] );
|
||
|
|
let hcnt = BM.getItemNumByBid( info[0] );
|
||
|
|
nx.gui.setString( cmp, "count", info[1] + "/" + hcnt );
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
// 点击学习
|
||
|
|
onTouchLearn: function() {
|
||
|
|
|
||
|
|
nx.dt.fnInvoke( this.cb, this.sid );
|
||
|
|
this.close();
|
||
|
|
},
|
||
|
|
|
||
|
|
} );
|