Files
fc/dev/project/assets/Scripts/mod/home/library/cmps/cmp.library.partner.wnd.js
T
2026-05-23 22:10:14 +08:00

297 lines
8.9 KiB
JavaScript

/******************************************************************
*
* 图鉴详情
*
******************************************************************/
const NxSpine = require( "nx.fx.spine" );
const BridgeWindow = require( "bridge.window" );
const ModLibrary = require( "library.mod" );
const HeroController = require( "hero_controller" );
const HeroConst = require( "hero_const" );
const TipsController = require( "tips_controller" );
cc.Class( {
extends: BridgeWindow,
properties: {
spRole: { default: null, type: NxSpine },
spMini: { default: null, type: NxSpine },
nodQA: { default: null, type: cc.Node },
nodDoc: { default: null, type: cc.Node },
nodSkills: { default: null, type: cc.Node },
nodReward: { default: null, type: cc.Node },
nodEmpty: { default: null, type: cc.Node },
},
// 重载:参数打开
onOpenConfigs: function( _params ) {
this.bid = _params ? _params.bid : 0;
this.auto = _params ? _params.auto : false;
// 无效
if( !nx.dt.numPositive( this.bid, false ) ) {
this.delayClose();
return;
}
// 伙伴查询
this.library = ModLibrary.getInstance();
this.config = this.library.queryPartner( this.bid );
if( !this.config ) {
this.delayClose();
return;
}
// 更新
this.updateBase();
this.updateModels();
this.updateSkills();
this.updateDocument();
this.updateReward();
},
// 基础更新
updateBase: function() {
let data = game.configs.partner_data.data_partner_base[ this.config.id ];
if( !data ) {
return;
}
console.log( "当前的数据相关" + JSON.stringify( this.config ) );
// 品質
let path = cc.path.join( "coms/images", "mk_partner_qa" + this.config.quality );
let spshow = ( this.config.quality == 5 || this.config.quality == 6 );
nx.gui.setSpriteFrame( this.nodQA, "qa", spshow ? null : path );
let spppath = "";
if( this.config.quality == 5 ){
spppath = "resDB/effects/E81054/action";
}else if( this.config.quality == 6 ){
spppath = "resDB/effects/E81058/action";
}
let sp = nx.gui.getComponent( this.nodQA, "qa/spine", "nx.fx.spine" );
if( sp && nx.dt.strNEmpty( spppath ) ){
sp.load( spppath, ( _e ) => {
if( !_e ) {
sp.action( "action", true );
} else {
sp.stop();
}
} );
}
nx.gui.setActive( this.nodQA, "qa/spine", spshow );
// 阵营
path = cc.path.join( "prefab/partner/ui/camp" + data.camp_type );
nx.gui.setSpriteFrame( this.nodQA, "camp", path );
// 描述
let desc = data.introduce_str || data.hero_pos || "";
nx.gui.setString( this.nodQA, "desc/txt", desc );
// 职业
let career = data.type || 4;
let icon = cc.path.join( "coms/images", "career" + career );
let name = nx.text.getKey( HeroConst.CareerName[ career ] ) || nx.text.getKey( "lab_none" );
nx.gui.setSpriteFrame( this.nodQA, "career/ico", icon );
nx.gui.setString( this.nodQA, "career/txt", nx.text.getKey( name ) );
// 星级
let snode = nx.gui.find( this.nodQA, "stars" );
for( let i = 0; i < snode.children.length; ++i ) {
let mk = i < data.init_star;
nx.gui.setColor( snode.children[ i ], "", mk ? cc.Color.WHITE : cc.Color.GRAY );
}
},
// 模型更新
updateModels: function() {
// 未知隐藏
let hide = false;
if( this.auto && this.config.statu == 0 ) {
hide = true;
}
this.spMini.stop();
this.spRole.stop();
nx.gui.setActive( this.nodEmpty, "", hide );
nx.gui.setActive( this.spMini, "", !hide );
nx.gui.setActive( this.spRole, "", !hide );
// 隐藏
if( hide ) {
return;
}
// 迷你
let path = PathTool.getSpinePath( this.config.resid, this.config.resid, false );
this.spMini.load( path, ( _e ) => {
if( !_e ) {
this.spMini.action( "stand2", true );
}
} );
// 大模型
path = PathTool.getSpinePath( this.config.resid, "show", false );
this.spRole.load( path, ( _e ) => {
if( !_e ) {
this.spRole.action( "action1", true );
}
} );
},
// 技能更新
updateSkills: function() {
let skills = this.config.skills;
let chds = this.nodSkills.children;
for( let i = 0; i < chds.length; ++i ) {
let sid = skills[ i ];
let node = chds[ i ];
node.active = nx.dt.numPositive( sid, false );
if( !node.active ) {
continue;
}
let cmp = node.getComponent( "cmp.skill.base" );
if( cmp ) {
cmp.setData( sid );
}
}
},
// 档案更新
updateDocument: function() {
let key = `story${ this.config.id }`;
let text = nx.text.getKey( key );
let arr = text.split( "#" );
nx.gui.setString( this.nodDoc, "name/txt", arr[ 0 ] );
nx.gui.setString( this.nodDoc, "camp/txt", arr[ 1 ] );
let detail = nx.gui.find( this.nodDoc, "detail/view/content" );
nx.gui.setString( detail, "survey/desc", arr[ 2 ] );
nx.gui.setString( detail, "experience/desc", arr[ 3 ] );
// 推荐阵容
this.updateTeams();
let layout = nx.gui.getComponent( detail, "", cc.Layout );
if( layout ) {
layout.updateLayout();
}
let scv = nx.gui.getComponent( this.nodDoc, "detail", cc.ScrollView );
if( scv ) {
scv.scrollToTop( 0 );
}
},
// 推荐阵容
updateTeams: function() {
// 阵容检索
let list = this.library.queryRecommondForms( this.bid );
if( nx.dt.arrNEmpty( list ) ) {
list.sort( ( _a, _b ) => {
return _b.pr - _a.pr;
} );
}
// 阵容设置
let hero = HeroController.getInstance().getModel();
let node = nx.gui.find( this.nodDoc, "detail/view/content/forms/list" );
let team = function( _form, _desc, _info ) {
// 空展示
if( nx.dt.objEmpty( _info ) ) {
nx.gui.setString( node, _desc, "" );
nx.gui.setActive( node, `${ _form }/list`, false );
nx.gui.setActive( node, `${ _form }/empty`, true );
return;
}
// 阵容刷新
nx.gui.setActive( node, `${ _form }/empty`, false );
nx.gui.setActive( node, `${ _form }/list`, true );
nx.gui.setString( node, _desc, _info.desc );
let list = nx.gui.find( node, `${ _form }/list` );
for( let i = 0; i < list.children.length; ++i ) {
let item = list.children[ i ];
let bid = _info.camp[ i ];
let have = hero.getHadHeroStarBybid( bid );
let cmp = item.getComponent( "cmp.item.base" );
if( cmp ) {
cmp.setData( bid );
!have ? cmp.onFocus() : cmp.outFocus();
}
}
}
team( "form1", "desc1", list[ 0 ] );
team( "form2", "desc2", list[ 1 ] );
},
// 点击阵容成员
onTouchMember: function( _btn ) {
let nod = _btn.parent.getComponent( "cmp.item.base" );
if( !nod ) {
return;
}
let key = nod.info.bid + "_" + nod.info.stars;
this.propsData = gdata( "partner_data", "data_partner_show", key );
this.propsData.star = nod.info.stars;
this.propsData.break_lev = 0;
TipsController.getInstance().showPartnerTips( this.propsData );
// console.log(JSON.stringify( nod.info ) + "数据" + JSON.stringify( nod.mdata ) );
},
// 奖励更新
updateReward: function() {
if( nx.dt.objEmpty( this.config ) ||
this.config.statu != 1 ) {
nx.gui.setActive( this.nodReward, "", false );
return;
}
nx.gui.setActive( this.nodReward, "", true );
let reward = this.config.reward[ 0 ];
nx.bridge.setIcon( this.nodReward, "num/icon", reward[ 0 ] );
nx.gui.setString( this.nodReward, "num/txt", ( reward[ 1 ] > 1 ) ? reward[ 1 ] : "" );
},
// 領取獎勵
onTouchReward: function() {
this.library.reqPartnerReward( this.bid, ( _ret, _data ) => {
if( !_ret ) {
nx.tbox( _data );
return;
}
nx.gui.setActive( this.nodReward, "", false );
} );
},
} );