231 lines
7.3 KiB
JavaScript
231 lines
7.3 KiB
JavaScript
const BridgeWindow = require( "bridge.window" );
|
|
const NxSpine = require( "nx.fx.spine" );
|
|
const BackPackConst = require( "backpack_const" );
|
|
const TipsController = require( "tips_controller" );
|
|
const HeroConst = require( "hero_const" );
|
|
const HeroController = require("hero_controller");
|
|
|
|
|
|
cc.Class({
|
|
|
|
extends: BridgeWindow,
|
|
|
|
properties: {
|
|
|
|
props : {
|
|
default:null,
|
|
type : cc.Node,
|
|
},
|
|
|
|
skills : {
|
|
default:null,
|
|
type : cc.Node,
|
|
},
|
|
|
|
role : {
|
|
default:null,
|
|
type : cc.Node,
|
|
},
|
|
|
|
smallrole : {
|
|
default:null,
|
|
type : NxSpine,
|
|
}
|
|
|
|
},
|
|
|
|
// 重载:参数打开
|
|
onOpenConfigs: function( _params ) {
|
|
let key = _params.bid + "_" + _params.star;
|
|
this.propsData = gdata("partner_data", "data_partner_show", key );
|
|
// this.partner = _params;
|
|
this.partner = BackPackConst.uniformData( _params.bid );
|
|
|
|
// // 无效关闭
|
|
// this.partner = _params;
|
|
// if( nx.dt.objEmpty( this.partner ) ) {
|
|
// this.scheduleOnce( () => {
|
|
// this.close();
|
|
// }, 0.05 );
|
|
// }
|
|
this.freshProps();
|
|
this.freshRole();
|
|
this.freshSkills();
|
|
|
|
},
|
|
|
|
// 置空
|
|
setEmpty: function() {
|
|
|
|
nx.gui.getComponent( this.role, "role", "nx.fx.spine" ).stop();
|
|
this.smallrole.stop();
|
|
|
|
nx.gui.setSpriteFrame( this.role, "qa", null );
|
|
nx.gui.setActive( nx.gui.find( this.role, "infos" ), "", false );
|
|
|
|
},
|
|
|
|
freshRole: function( ){
|
|
// 置空
|
|
if( nx.dt.objEmpty( this.partner ) ) {
|
|
this.setEmpty();
|
|
return;
|
|
}
|
|
// 名字
|
|
nx.gui.setString( nx.gui.find( this.role, "infos" ), "name", this.partner.name );
|
|
|
|
// 品质
|
|
let path = cc.path.join( "coms/images", "mk_partner_qa" + this.partner.quality );
|
|
nx.gui.setSpriteFrame( this.role, "qa", path );
|
|
|
|
// 阵营
|
|
path = cc.path.join( "prefab/partner/ui/camp" + this.partner.camp_type );
|
|
nx.gui.setSpriteFrame( nx.gui.find( this.role, "infos" ), "camp", path );
|
|
|
|
// 动画
|
|
let key = this.partner.bid + "_" + this.partner.init_star;
|
|
let cfg = gdata("partner_data", "data_partner_star", key )
|
|
if( cfg ) {
|
|
|
|
// 立绘
|
|
path = PathTool.getSpinePath( cfg.res_id, "show", false );
|
|
nx.gui.getComponent( this.role, "role", "nx.fx.spine" ).load( path, ( _e ) => {
|
|
if( !_e ) {
|
|
nx.gui.getComponent( this.role, "role", "nx.fx.spine" ).action( "action1", true );
|
|
} else {
|
|
nx.gui.getComponent( this.role, "role", "nx.fx.spine" ).stop();
|
|
}
|
|
} );
|
|
|
|
// 战斗迷你
|
|
path = PathTool.getSpinePath( cfg.res_id, cfg.res_id, false );
|
|
this.smallrole.load( path, ( _e ) => {
|
|
if( !_e ) {
|
|
this.smallrole.action( "stand2", true );
|
|
} else {
|
|
this.smallrole.stop();
|
|
}
|
|
} );
|
|
|
|
}
|
|
else {
|
|
nx.gui.getComponent( this.role, "role", "nx.fx.spine" ).stop();
|
|
this.smallrole.stop();
|
|
nx.error( "立绘配置缺失:", key );
|
|
}
|
|
console.log( JSON.stringify( cfg ) );
|
|
// 等级
|
|
nx.gui.setString( nx.gui.find( this.role, "infos" ), "lv", "Lv." + cfg.lev_max || 1 );
|
|
|
|
// 星级
|
|
let paths = cc.path.join( "coms/images", "star" + this.partner.init_star );
|
|
nx.gui.setSpriteFrame( nx.gui.find( this.role, "infos" ), "stars", paths );
|
|
|
|
},
|
|
|
|
freshProps: function( ){
|
|
|
|
// 等级
|
|
// let maxlv = Math.max( cbc.lev_max, scfg.lev_max );
|
|
nx.gui.setString( this.props, "lv/txt", this.propsData.lev + "/" + this.propsData.lev );
|
|
|
|
let HM = HeroController.getInstance().getModel();
|
|
let count = HM.getHeroMaxBreakCountByInitStar( this.partner.init_star );
|
|
|
|
nx.gui.gocChildren( this.props, "grade/star", count );
|
|
|
|
// 职业
|
|
let career = this.partner.type || 4;
|
|
let icon = cc.path.join( "coms/images", "career" + career );
|
|
let name = HeroConst.CareerName[ career ] || nx.text.getKey( "lab_none" );
|
|
nx.gui.setActive( this.props, "career", true );
|
|
nx.gui.setString( this.props, "career/txt", nx.text.getKey( name ) );
|
|
nx.gui.setSpriteFrame( this.props, "career/icon", icon );
|
|
nx.gui.setActive( this.props, "help", true );
|
|
|
|
// 属性
|
|
nx.gui.setString( this.props, "atk/txt", this.propsData.atk );
|
|
nx.gui.setString( this.props, "def/txt", this.propsData.def );
|
|
nx.gui.setString( this.props, "hp/txt", this.propsData.hp );
|
|
nx.gui.setString( this.props, "speed/txt", this.propsData.speed );
|
|
},
|
|
|
|
freshSkills: function( ){
|
|
|
|
let HM = HeroController.getInstance().getModel();
|
|
let break_count = HM.getHeroMaxBreakCountByInitStar( this.partner.init_star );
|
|
// 数据统计
|
|
let key = this.partner.bid + "_" + this.partner.init_star;
|
|
let scfg = gdata( "partner_data", "data_partner_star", key );
|
|
let k1 = this.partner.type + "_" + this.partner.break_id + "_" + break_count;
|
|
let cbc = game.configs.partner_data.data_partner_brach[ k1 ];
|
|
if( nx.dt.objEmpty( scfg ) || nx.dt.objEmpty( cbc ) ) {
|
|
nx.error( "技能刷新失败,当前配置无效!", k1 );
|
|
this.setEmpty();
|
|
return;
|
|
}
|
|
|
|
// nx.gui.setActive( this.skills, "", true );
|
|
|
|
const count = cbc.skill_num;
|
|
const chds = this.skills.children;
|
|
for( let i = 0; i < chds.length; ++i ) {
|
|
|
|
// 技能数组[0]为普攻,直接忽略,最多4个技能
|
|
let item = chds[i];
|
|
let sifo = scfg.skills[i+1];
|
|
if( !sifo ) {
|
|
item.active = false;
|
|
continue;
|
|
}
|
|
|
|
item.active = true;
|
|
let cmp = nx.gui.getComponent( item, "", "cmp.skill.base" );
|
|
if( cmp ) {
|
|
cmp.setData( sifo[1], ( i + 1 ) > count );
|
|
}
|
|
|
|
}
|
|
},
|
|
|
|
// 点击角色
|
|
onTouchRole: function() {
|
|
|
|
// 屏蔽频繁点击打断
|
|
if( nx.gui.getComponent( this.role, "role", "nx.fx.spine" ).spAction != "action1" ) {
|
|
return;
|
|
}
|
|
|
|
// 播放 -> 常态
|
|
nx.gui.getComponent( this.role, "role", "nx.fx.spine" ).action( "action2", false, ( _event ) => {
|
|
if( _event == "complete" ) {
|
|
nx.gui.getComponent( this.role, "role", "nx.fx.spine" ).action( "action1", true );
|
|
}
|
|
} );
|
|
|
|
},
|
|
|
|
// 人物介绍
|
|
onTouchStory: function() {
|
|
const TC = TipsController.getInstance();
|
|
let txt = nx.text.getKey( "story" + this.partner.bid );
|
|
TC.showTextPanel( "PartnerStory", txt );
|
|
},
|
|
|
|
// 点击详情
|
|
onTouchDetail: function() {
|
|
|
|
if( nx.dt.objNEmpty( this.partner ) ) {
|
|
const HC = HeroController.getInstance();
|
|
HC.openHeroTipsAttrPanel( true, this.propsData, true );
|
|
}
|
|
},
|
|
|
|
// 观察
|
|
onTouchWatch: function() {
|
|
|
|
HeroController.getInstance().openHeroLookDrawWindowTest( true,this.partner );
|
|
},
|
|
|
|
});
|