Files

163 lines
4.2 KiB
JavaScript
Raw Permalink Normal View History

2026-05-23 22:10:14 +08:00
const NxSpine = require( "nx.fx.spine" );
const BridgeWindow = require( "bridge.window" );
const PathTool = require("pathtool");
const BattleEvent = require("battle_event");
cc.Class({
extends: BridgeWindow,
properties: {
infoNd: {
default: null,
type: cc.Node
},
infoSp: {
default: null,
type: NxSpine
},
bMvp: {
default: null,
type: NxSpine
},
mvp_icon_sp:{
default:null,
type:NxSpine
},
hurtTxt: {
default: null,
type: cc.Label
},
},
// LIFE-CYCLE CALLBACKS:
onLoad () {
},
start () {
},
onOpenConfigs(params){
if(!params || !params.data){
this.delayClose();
return;
}
let data = params.data;
this.setInfos(data);
this.infoNd.scaleX = 1;
this.infoSp.action( "action1_1", false, ( _key, _name ) => {
if( _key == "start" ) {
this.changeMvpDraw( 1 );
gcore.GlobalEvent.fire( BattleEvent.BATTLE_HARM_DATA, data );
}
if( _key == "complete" ) {
this.infoSp.action( "action1_2", true );
return;
}
} );
},
changeMvpDraw( type ) {
this.bMvp.node.active = true;
this.mvp_icon_sp.node.runAction(cc.fadeIn(0.55).easing(cc.easeIn(0.55)));
if(type == 1){
if(this.hurt_mvp){
this.bMvp.action("action1",false);
}else{
this.bMvp.node.active = false;
}
}else{
if(this.cure_mvp){
this.bMvp.action("action1",false);
}else{
this.bMvp.node.active = false;
}
}
},
//設置mvp
setInfos(data) {
if( nx.dt.arrEmpty( data.hurt_statistics ) ) {
return;
}
let hurt_arr = data.hurt_statistics;
let partner_hurt = {};
for( let i = 0; i < hurt_arr.length; i++ ) {
let data = hurt_arr[ i ];
if( data.type == 1 ) {//我方數據
partner_hurt = data.partner_hurts;
}
}
if( nx.dt.arrEmpty( partner_hurt ) ) {
return;
}
let total_hurt = 0;
let mvp_hurt = 0;
this.mvp_skin_id = 0;
let svp_cure = 0;
this.svp_skin_id = 0;
for( let v in partner_hurt ) {
let info = partner_hurt[ v ];
//总伤害
total_hurt += info.dps;
if( info.dps >= mvp_hurt ) {
//生成新的dps
mvp_hurt = info.dps;
this.hurt_mvp = info.bid;
for( let key in info.ext_data ) {
if( info.ext_data[ key ].key == 5 ) {
this.mvp_skin_id = info.ext_data[ key ].val;
}
}
}
if( info.cure > svp_cure ) {
svp_cure = info.cure;
this.cure_mvp = info.bid;
for( let key in info.ext_data ) {
if( info.ext_data[ key ].key == 5 ) {
this.svp_skin_id = info.ext_data[ key ].val;
}
}
}
}
this.setMvpPartner();
// this.setSvpPartner();
//伤害统计
this.hurtTxt.string = total_hurt;
},
setMvpPartner() {
let mvp_bid = this.hurt_mvp;
let partner_config = game.configs.partner_data.data_partner_base[ mvp_bid ];
let skin_config = game.configs.partner_skin_data.data_skin_info[ this.mvp_skin_id ];
//名称和立绘
if( partner_config ) {
let bustid = partner_config.bustid;
if( skin_config ) {
bustid = skin_config.bustid;
}
var bust_res = PathTool.getSpinePath(bustid,"show",false);
this.mvp_icon_sp.load(bust_res,(_e)=>{
if(!_e){
this.mvp_icon_sp.action("action1",true);
}else{
this.mvp_icon_sp.stop();
}
});
}
},
onPreClosed(){
}
// update (dt) {},
});