Files
fc/dev/project/assets/Scripts/mod/battle/cmp/cmp.battle.settle.win.js
T
2026-05-23 22:10:14 +08:00

662 lines
22 KiB
JavaScript

var PathTool = require( "pathtool" );
var BattleConst = require( "battle_const" );
var BattleController = require( "battle_controller" );
var BattleEvent = require( "battle_event" );
const RoleController = require( "role_controller" );
const StartowerController = require( "startower.mod" );
const StartowerEvent = require( "startower.define" );
const HTC = require( "hero_controller" );
const FID = require( "bridge.function.ids" );
const ItemLay = require( "cmp.common.itemlayout" );
const NxSpine = require( "nx.fx.spine" );
const BridgeWindow = require( "bridge.window" );
const CampFitMod = require("campfight.mod");
const PVPRank = require("pvprank.mod");
cc.Class( {
extends: BridgeWindow,
properties: {
mainNd: {
default: null,
type: cc.Node
},
rewardPanel: {
default: null,
type: cc.Node
},
rewardNd: {
default: null,
type: cc.Node
},
confirm: {
default: null,
type: cc.Node
},
infoNd: {
default: null,
type: cc.Node
},
list: {
default: null,
type: ItemLay
},
hurtTxt: {
default: null,
type: cc.Label
},
mvp_icon_sp:{
default:null,
type:NxSpine
},
svp_icon_sp: {
default: null,
type: cc.Sprite
},
harm_btn: {
default: null,
type: cc.Node
},
mainSp: {
default: null,
type: NxSpine
},
infoSp: {
default: null,
type: NxSpine
},
bMvp: {
default: null,
type: NxSpine
},
fab_head: {
default: null,
type: cc.Prefab
},
fabPartner: {
default: null,
type: cc.Prefab
}
},
// LIFE-CYCLE CALLBACKS:
onLoad() {
this.ctrl = BattleController.getInstance();
this.model = this.ctrl.getModel();
this.role_vo = RoleController.getInstance().getRoleVo();
this.is_result = false;
this.bindGEvent( BattleEvent.BATTLE_HARM_MVP, this.changeMvpDraw.bind( this ) );
this.vbind( [
[ "CloseSpecial", this.delayCloss.bind( this ) ]
] );
// this.bindGEvent( BattleEvent.BATTLE_HARM_MVP, this.changeMvpDraw.bind( this ) );
},
start() {
},
delayCloss: function( _data ){
if( !_data ){
return;
}
if( _data && _data == 1 ){
this.close();
nx.bridge.vset( "CloseSpecial", null );
}
},
// 重载:关闭前
onPreClosed: function() {
nx.bridge.vset( "ResultInfo", {} );
this.ctrl.delSpecialRetInfo(this.fight_type);
this.list.rebuild( [] );
if( this.model.getBattleScene() && this.ctrl.getIsSameBattleType( this.fight_type ) ) {
//只执行一次,防止假战斗被误清除
if( this.is_result ) return;
this.model.result( this.data, null );
this.is_result = true;
}
if(this.fight_type == BattleConst.Fight_Type.StarTower){
// nx.bridge.jumper.jump2Window( FID.Tower );
gcore.GlobalEvent.fire(StartowerEvent.Show_Jump_Sp);
}
else if(this.fight_type == BattleConst.Fight_Type.newHeroUse){
nx.bridge.jumper.jump2Window(FID.StarUserTramp);
}
else if(this.fight_type == BattleConst.Fight_Type.newYearCross){
nx.bridge.jumper.jump2Window( FID.CampFitPvP );
CampFitMod.getInstance().reqSelfGroup();
}else if( this.fight_type == BattleConst.Fight_Type.EliteMatchWar || this.fight_type == BattleConst.Fight_Type.EliteKingMatchWar ) {
nx.bridge.jumper.jump2Window( FID.EliteMatch );
}
/***
* else if( this.fight_type == BattleConst.Fight_Type.ElementWar ) {
nx.bridge.jumper.jump2Window( FID.PVEFactionSec );
}else if( this.fight_type == BattleConst.Fight_Type.HeavenWar ) {
nx.bridge.jumper.jump2Window( FID.PVERuins );
}else if( this.fight_type == BattleConst.Fight_Type.PlanesWar ) {
nx.bridge.jumper.jump2Window( FID.Planes );
}else if( this.fight_type == BattleConst.Fight_Type.Endless ) {
nx.bridge.jumper.jump2Window( FID.Endless );
}else if( this.fight_type == BattleConst.Fight_Type.Adventrue ) {
nx.bridge.jumper.jump2Window( FID.Adventure );
}else if( this.fight_type == BattleConst.Fight_Type.DungeonStone ) {
nx.bridge.jumper.jump2Window( FID.Dungeon );
}
*/
},
onOpenConfigs( params ) {
let wins = 0;
let par = nx.bridge.ui.getSceneNode(5);
for(let i in par.children){
if(par.children[i] && par.children[i].name == "WndWinSettle"){
wins++;
}
}
if(wins > 1){
this.delayClose();
return;
}
let data = nx.bridge.vget( "ResultInfo" );
if( nx.dt.objEmpty( data ) ) {
return;
}
// nx.bridge.Tag2PanelClose("WndWinSettle");
//需要提前隐藏下层的战斗场景
gcore.GlobalEvent.fire(BattleEvent.HIDE_BAT_UI_IN_SETTLE);
this.data = data;
this.result = data.result
this.fight_type = params.combat_type || data.combat_type || BattleConst.Fight_Type.Darma;
let action1 = "action1_1";
let action2 = "action1_2";
//獎勵處理
if( this.fight_type == BattleConst.Fight_Type.StarTower ) {
this.first_items = data.first_award;
action1 = "action2_1";
action2 = "action2_2";
} else if( this.fight_type == BattleConst.Fight_Type.Darma || this.fight_type == BattleConst.Fight_Type.PlanesWar ||
this.fight_type == BattleConst.Fight_Type.Endless || this.fight_type == BattleConst.Fight_Type.HeavenWar ||
this.fight_type == BattleConst.Fight_Type.SingleBoss || this.fight_type == BattleConst.Fight_Type.newYearCross ||
this.fight_type == BattleConst.Fight_Type.EliteMatchWar || this.fight_type == BattleConst.Fight_Type.EliteKingMatchWar ) {
action1 = "action3_1";
action2 = "action3_2";
}
this.reward_list = data.item_rewards || data.award || data.award_list ;
//總傷害,mvp處理,皮膚處理ext_data,key 5
this.setInfos();
if( this.data && this.data.hurt_statistics ) {
this.harm_btn.active = true;
} else {
this.harm_btn.active = false;
}
if(this.fight_type == BattleConst.Fight_Type.newHeroUse){
nx.gui.setActive(this.infoNd,"comfirm",true);
nx.gui.setActive(this.infoNd,"harm",false);
this.clickInfo();
}else{
this.doMainStep( action1, action2 );
}
this.scheduleOnce(()=>{
nx.audio.playSFX( "audios/effects/win",false );
},0.1);
},
sendBattleClear(){
if( this.model.getBattleScene() && this.ctrl.getIsSameBattleType( this.fight_type ) ) {
//只执行一次,防止假战斗被误清除
if( this.is_result ) return;
this.model.result( this.data, null );
this.is_result = true;
}
},
doMainStep( start_act, final_act ) {
this.mainSp.action( start_act, false, ( _key, _name ) => {
console.log( _key, _name );
if( _key == "t1" ) {
this.setMainPanel();
return;
}
if( _key == "t2" ) {
this.setRewards();
return;
}
if( _key == "t3" ) {
this.confirm.active = true;
this.confirm.runAction( cc.sequence( cc.spawn( cc.scaleTo( 0.16, 1.1 ), cc.fadeIn( 0.16 ) ), cc.scaleTo( 0.16, 1 ) ) );
this.scheduleOnce( () => {
this.postPlotEvent( "battle_win_show" );
// this.postPlotEvent( "closeBattleWin" );
}, 0.05 );
return;
}
if( _key == "t4" ) {
this.harm_btn.runAction( cc.fadeIn( 0.33 ) );
return;
}
if( _key == "complete" ) {
this.mainSp.action( final_act, true, null );
return;
}
} );
},
//根據結算類型設置數據
setMainPanel() {
let nd = nx.gui.find( this.rewardPanel, String( this.fight_type ) );
if( nd ) {
nd.active = true;
nd.runAction( cc.fadeIn( 0.16 ) );
if( this.fight_type == BattleConst.Fight_Type.StarTower ) {
this.setTowerInfo( nd );
} else if( this.fight_type == BattleConst.Fight_Type.Darma ) {
this.setDramaInfo( nd );
this.showDramaProgress( nd );
} else if( this.fight_type == BattleConst.Fight_Type.PlanesWar ) {
this.setPlanesInfo( nd );
} else if( this.fight_type == BattleConst.Fight_Type.Endless ) {
this.setEndlessInfo( nd );
} else if( this.fight_type == BattleConst.Fight_Type.HeavenWar ){
this.setHeavenInfo( nd );
} else if( this.fight_type == BattleConst.Fight_Type.newYearBoss ){
this.setPlanesInfo( nd );
}else if( this.fight_type == BattleConst.Fight_Type.SingleBoss ){
this.setSBossInfo( nd );
}else if( this.fight_type == BattleConst.Fight_Type.newYearCross ){
this.setYearCrossInfo( nd );
}else if( this.fight_type == BattleConst.Fight_Type.EliteMatchWar || this.fight_type == BattleConst.Fight_Type.EliteKingMatchWar ){
this.setPVPMatchInfo( nd );
}
}
},
setPVPMatchInfo( nd ){
// console.log( "顯示相關" );
let cfg = game.configs.arena_elite_data.data_elite_level;
let ncfg = cfg[this.data.elite_lev];
let total = ncfg.need_exp;
let nncfg = cfg[this.data.new_elite_lev];
nx.gui.setActive( nd, "normal", nx.dt.arrEmpty( this.data.promoted_info ) );
nx.gui.setActive( nd, "promote", nx.dt.arrNEmpty( this.data.promoted_info ) );
nx.gui.setString( nd, "normal/lev", ncfg.name );
let exp = this.data.end_score > total ? total : this.data.end_score;
nx.gui.setString( nd, "normal/expinfo", exp + "/" + nncfg.need_exp );
let mod = PVPRank.getInstance();
let path = mod.dealUI( this.data.elite_lev );
let newpath = mod.dealUI( this.data.new_elite_lev );
nx.gui.setString( nd, "normal/exp/txt", exp );
let changeee = "";
if( this.data.end_score > total ){
changeee = "( +" + ( total - this.data.score ) + ")" ;
}else{
changeee = this.data.add_score > 0 ? "( +" + this.data.add_score + ")" : "(" + this.data.add_score + ")";
}
nx.gui.setString( nd, "normal/exp/change", changeee );
nx.gui.setSpriteFrame( nd, "normal/ico", path );
nx.gui.setString( nd, "normal/score/change", this.data.add_score > 0 ? "( +" + this.data.add_score + ")" : "(" + this.data.add_score + ")" );
nx.gui.setString( nd, "normal/score/txt", this.data.big_score );
let prog = nx.gui.find( nd, "normal/prog" );
let progbefore = nx.gui.find( nd, "normal/prognor" );
let cmp = prog.getComponent( cc.ProgressBar );
if( cmp ){
cmp.progress = ( this.data.score )/ total
}
let ncmp = progbefore.getComponent( cc.ProgressBar );
if( ncmp ){
ncmp.progress = ( this.data.add_score + this.data.score )/ total
}
nx.gui.setString( nd, "promote/from/lev", ncfg.name );
nx.gui.setString( nd, "promote/to/lev", nncfg.name );
nx.gui.setString( nd, "promote/exp/result/txt", 0 );
nx.gui.setString( nd, "promote/exp/result/change", this.data.end_score );
nx.gui.setString( nd, "promote/exp/score/txt", this.data.score );
nx.gui.setString( nd, "promote/exp/score/change", this.data.end_score );
nx.gui.setSpriteFrame( nd, "promote/from/ico", path );
nx.gui.setSpriteFrame( nd, "promote/to/ico", newpath );
nx.gui.setActive( nd, "promote/exp", false );
},
setYearCrossInfo(nd){
let hurt_arr = this.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;
}
}
let all_dmg = 0;
for(let a in partner_hurt){
if(partner_hurt[a]){
all_dmg += partner_hurt[a].dps;
}
}
nx.gui.setString(nd,"dps",all_dmg);
},
setSBossInfo(nd){
let hurt_arr = this.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;
}
}
let all_dmg = 0;
for(let a in partner_hurt){
if(partner_hurt[a]){
all_dmg += partner_hurt[a].dps;
}
}
let all_cure = 0;
for(let a in partner_hurt){
if(partner_hurt[a]){
all_cure += partner_hurt[a].cure;
}
}
nx.gui.setString(nd,"dps",all_dmg);
nx.gui.setString(nd,"cure",all_cure);
},
setHeavenInfo( nd ){
let con_infos = game.configs.dungeon_heaven_data.data_customs[this.data.id][this.data.order_id].cond_info;
if(!con_infos)return;
for(let i in con_infos){
let cfg = game.configs.dungeon_heaven_data.data_star_cond[con_infos[i][1]];
let item = nd.children[i];
if(item && cfg){
for(let j in this.data.star_info){
if(this.data.star_info[j].id == con_infos[i][0]){
nx.gui.setSpriteFrame(item,"star","prefab/pve/RelicExploration/ui/star_02");
nx.gui.setSpriteFrame(item,"get","prefab/pve/RelicExploration/ui/star_01");
nx.gui.setActive(item,"get",this.data.star_info[j].state == 1);
break;
}
}
nx.gui.setString(item,"task",cfg.type);
}
}
},
setEndlessInfo( nd ) {
nx.gui.setString( nd, "max_lev", this.data.target_role_name );
},
setPlanesInfo( nd ) {
nx.gui.setString( nd, "dps", this.data.all_dps );
let vo = HTC.getInstance().getModel().getHeroById( this.data.best_partner );
if( vo ) {
let heroNd = nx.gui.find( nd, "head" );
if( !this.bestPartner ) {
this.bestPartner = cc.instantiate( this.fabPartner );
this.bestPartner.parent = heroNd;
}
let cmp = nx.gui.getComponent( this.bestPartner, "", "cmp.partner.com" );
cmp.setData( vo );
}
},
setTowerInfo( nd ) {
let str = nx.text.getKey( "lab_eleMaxLev" ) + this.data.max_tower;
nx.gui.setString( nd, "time", str );
StartowerController.getInstance().refrreshNewTower( this.data );
},
setDramaInfo( nd ) {
//等级
nx.gui.setString( nd, "lev", cc.js.formatStr( "Lv.%d", this.data.new_lev ) );
//名字
nx.gui.setString( nd, "name", this.role_vo.name );
//设置头像
let headNd = nx.gui.find( nd, "head" );
this.head_icon = cc.instantiate( this.fab_head );
let cmp = this.head_icon.getComponent( "cmp.common.header" );
if( this.role_vo ) {
cmp.rebind( 0, this.role_vo );
}
this.head_icon.parent = headNd;
},
//剧情经验条
showDramaProgress( par ) {
var baseCurMaxExp = game.configs.role_data.data_role_attr[ this.data.lev ].exp_max;
var basePercent = this.data.exp / baseCurMaxExp;
var maxPercent = this.data.new_exp / baseCurMaxExp;
if( this.data.lev != this.data.new_lev ) {//有升级
maxPercent = 1;
}
let bar = nx.gui.getComponent( par, "bar", cc.ProgressBar );
bar.progress = basePercent;
nx.gui.setString( par, "exp", cc.js.formatStr( "%d/%d", Number( this.data.exp ), Number( baseCurMaxExp ) ) );
basePercent = basePercent + 0.01;
if( basePercent > maxPercent ) {
if( this.data.lev == this.data.new_lev ) {
baseCurMaxExp = game.configs.role_data.data_role_attr[ this.data.new_lev ].exp_max;
basePercent = this.data.new_lev / baseCurMaxExp;
bar.progress = basePercent;
nx.gui.setString( par, "exp", cc.js.formatStr( "%d/%d", this.data.new_exp, Number( baseCurMaxExp ) ) );
} else {
this.data.lev = this.data.lev + 1;
basePercent = 0;
maxPercent = 1;
baseCurMaxExp = game.configs.role_data.data_role_attr[ this.data.lev ].exp_max;
if( this.data.lev == this.data.new_lev ) {
maxPercent = this.data.new_exp / game.configs.role_data.data_role_attr[ this.data.new_lev ].exp_max;
}
}
} else {
bar.progress = basePercent;
nx.gui.setString( par, "exp", cc.js.formatStr( "%d/%d", Math.ceil( baseCurMaxExp * basePercent ), Number( baseCurMaxExp ) ) );
}
},
//設置mvp
setInfos() {
if( nx.dt.arrEmpty( this.data.hurt_statistics ) ) {
return;
}
let hurt_arr = this.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;
// if(this.fight_type == BattleConst.Fight_Type.newHeroUse){
// let unit = Utils.getUnitConfig(this.hurt_mvp);
// mvp_bid = Number(unit.head_icon);
// }
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();
}
});
}
},
setRewards() {
this.rewardNd.active = true;
this.rewardNd.runAction( cc.fadeIn( 0.16 ) );
let rewards = [];
if( this.first_items ) {
for( let i in this.first_items ) {
let v = this.first_items[ i ];
rewards.push( { bid: v.item_id, num: v.num } );
}
}
for( let a = 0; a < this.reward_list.length; a++ ) {
let item = this.reward_list[ a ];
if( item ){
rewards.push( { bid: item.bid || item.item_id, num: item.num } );
}
}
this.list.rebuild( rewards );
},
changeMvpDraw( type ) {
this.bMvp.node.active = true;
if(type == 1){
this.mvp_icon_sp.node.runAction(cc.fadeIn(0.55).easing(cc.easeIn(0.55)));
// this.svp_icon_sp.node.runAction(cc.fadeOut(0.1));
if(this.hurt_mvp){
this.bMvp.action("action1",false);
}else{
this.bMvp.node.active = false;
}
}else{
// this.mvp_icon_sp.node.runAction(cc.fadeOut(0.1));
// this.svp_icon_sp.node.runAction(cc.fadeIn(0.55).easing(cc.easeIn(0.55)));
if(this.cure_mvp){
this.bMvp.action("action1",false);
}else{
this.bMvp.node.active = false;
}
}
},
clickMain() {
this.mvp_icon_sp.node.opacity = 0;
this.mainNd.active = true;
this.infoNd.scaleX = 0;
this.bMvp.node.active = false;
},
clickInfo() {
this.mainNd.active = false;
this.infoNd.active = true;
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, this.data );
}
if( _key == "complete" ) {
this.infoSp.action( "action1_2", true );
return;
}
} );
},
// ==========================================
// 引导相关
// ==========================================
// 引导事件
postPlotEvent: function( _key ) {
if( nx.bridge.plot && nx.dt.strNEmpty( _key ) ) {
nx.bridge.plot.postKey( _key );
}
},
} );