391 lines
12 KiB
JavaScript
391 lines
12 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 NxExpand = require( "nx.fx.sv.expand" );
|
|
const NxSpine = require( "nx.fx.spine" );
|
|
const BridgeWindow = require( "bridge.window" );
|
|
const StartowerController = require( "startower.mod" );
|
|
const BattleDramaController = require("battle_drama_controller");
|
|
cc.Class( {
|
|
extends: BridgeWindow,
|
|
|
|
properties: {
|
|
mainSp:{
|
|
default:null,
|
|
type:NxSpine
|
|
},
|
|
mainNd:{
|
|
default:null,
|
|
type:cc.Node
|
|
},
|
|
sMvp:{
|
|
default:null,
|
|
type:NxSpine
|
|
},
|
|
harmBtn:{
|
|
default:null,
|
|
type:cc.Node
|
|
},
|
|
rewardZi:{
|
|
default:null,
|
|
type:cc.Node
|
|
},
|
|
btns:{//按鈕組
|
|
default:null,
|
|
type:cc.Node
|
|
},
|
|
rewardNd:{
|
|
default:null,
|
|
type:cc.Node
|
|
},
|
|
awardList:{
|
|
default:null,
|
|
type:NxExpand
|
|
},
|
|
roleNd:{
|
|
default:null,
|
|
type:cc.Node
|
|
},
|
|
roleSp:{
|
|
default:null,
|
|
type:NxSpine
|
|
},
|
|
fabHead:{
|
|
default:null,
|
|
type:cc.Prefab
|
|
},
|
|
timeTxt:{
|
|
default:null,
|
|
type:cc.Node
|
|
}
|
|
},
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
onLoad() {
|
|
this.ctrl = BattleController.getInstance();
|
|
this.model = this.ctrl.getModel();
|
|
this.role_vo = RoleController.getInstance().getRoleVo();
|
|
|
|
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.awardList.rebuild([]);
|
|
this.ctrl.delSpecialRetInfo(this.fight_type);
|
|
let cur = nx.bridge.plot.vget( "id" );
|
|
if( nx.dt.strEmpty( cur ) ) {
|
|
nx.bridge.mainui.tryPlot( "main" );
|
|
|
|
}
|
|
nx.bridge.mainui.onDramaLevelChanged();
|
|
// 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 == 7){
|
|
// gcore.GlobalEvent.fire(StartowerEvent.Show_Jump_Sp);
|
|
// }
|
|
},
|
|
|
|
onOpenConfigs( params ) {
|
|
if(!params || !params.data){
|
|
this.delayClose();
|
|
return;
|
|
}
|
|
this.data = params.data;
|
|
this.fight_type = this.data.combat_type;
|
|
let action1 = "action1_1";
|
|
let action2 = "action1_2";
|
|
if(this.fight_type == 7){//試煉塔
|
|
this.first_items = this.data.first_award;
|
|
action1 = "action2_1";
|
|
action2 = "action2_2";
|
|
}
|
|
|
|
//數據統計
|
|
if( this.data && this.data.hurt_statistics ) {
|
|
this.harmBtn.active = true;
|
|
} else {
|
|
this.harmBtn.active = false;
|
|
}
|
|
//返回挂機
|
|
this.btns.children[0].active = (this.fight_type == 3);
|
|
this.reward_list = this.data.item_rewards || this.data.award || this.data.award_list;
|
|
this.setInfos(this.data);
|
|
this.doMainStep( action1, action2 );
|
|
},
|
|
|
|
doMainStep( start_act, final_act ) {
|
|
this.mainNd.runAction(cc.fadeIn(0.3));
|
|
let sps = PathTool.getSpinePath("E55312","action",false);
|
|
this.mainSp.load(sps,(_e)=>{
|
|
if(!_e){
|
|
this.mainSp.action( start_act, false, ( _key, _name ) => {
|
|
|
|
if( _key == "t1" ) {
|
|
let nd = nx.gui.find(this.mainNd,String(this.fight_type));
|
|
if(nd){
|
|
nd.runAction(cc.sequence(cc.fadeIn(0.16),cc.callFunc(()=>{
|
|
this.setMainPanel(nd);
|
|
})));
|
|
}
|
|
return;
|
|
}
|
|
|
|
if( _key == "t2" ) {
|
|
this.setRewards();
|
|
return;
|
|
}
|
|
|
|
if( _key == "t3_2" ) {
|
|
this.btns.runAction(cc.sequence(cc.spawn(cc.fadeIn(0.16),cc.scaleTo(0.16,1.1)),cc.scaleTo(0.16,1)));
|
|
return;
|
|
}
|
|
|
|
if( _key == "t4" ) {
|
|
this.harmBtn.runAction( cc.fadeIn( 0.33 ) );
|
|
return;
|
|
}
|
|
|
|
if( _key == "mvp" ) {
|
|
this.sMvp.node.active = true;
|
|
this.sMvp.action( "action1",false, (_key2,_name2)=>{
|
|
if( _key2 == "complete" ) {
|
|
this.sMvp.action( "action2", true);
|
|
return;
|
|
}
|
|
} );
|
|
return;
|
|
}
|
|
|
|
if( _key == "role" ) {
|
|
this.roleNd.runAction( cc.fadeIn(0.3) );
|
|
return;
|
|
}
|
|
|
|
|
|
if( _key == "complete" ) {
|
|
// this.autoNext();
|
|
this.mainSp.action( final_act, true, null );
|
|
return;
|
|
}
|
|
|
|
} );
|
|
}
|
|
});
|
|
},
|
|
|
|
setMainPanel(nd){
|
|
if(this.fight_type == 3){
|
|
this.setDramaInfo(nd);
|
|
this.showDramaProgress(nd);
|
|
}else{
|
|
this.setStarTowerInfo(nd);
|
|
}
|
|
},
|
|
|
|
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.fabHead );
|
|
let cmp = this.head_icon.getComponent( "cmp.common.header" );
|
|
if( this.role_vo ) {
|
|
cmp.rebind( 0, this.role_vo );
|
|
}
|
|
this.head_icon.parent = headNd;
|
|
//經驗值
|
|
let exp = nx.gui.find(nd,"exp");
|
|
nx.gui.setString(exp,"cur_exp",nx.text.getKey("Exp_")+this.data.exp);
|
|
nx.gui.setString(exp,"add_exp"," +"+this.data.new_exp);
|
|
let drama_info = BattleDramaController.getInstance().getModel().getDramaData();
|
|
let drama_key = game.configs.dungeon_data.data_drama_dungeon_info[drama_info.max_dun_id];
|
|
nx.gui.setString(nd,"ti",cc.js.formatStr(nx.text.getKey("DramaBatCross"),drama_key.name));
|
|
},
|
|
|
|
//剧情经验条
|
|
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 ) {//有升级
|
|
let nextCurMaxExp = game.configs.role_data.data_role_attr[ this.data.new_lev ].exp_max;
|
|
if(nextCurMaxExp){
|
|
maxPercent = this.data.new_exp/nextCurMaxExp;
|
|
basePercent = 0;
|
|
}
|
|
}
|
|
|
|
let add_bar = nx.gui.getComponent( par, "bar_bg/add", cc.ProgressBar );
|
|
let normal_bar = nx.gui.getComponent( par, "bar_bg/normal", cc.ProgressBar );
|
|
normal_bar.progress = basePercent;
|
|
add_bar.progress = maxPercent;
|
|
},
|
|
|
|
setStarTowerInfo(nd){
|
|
let str = cc.js.formatStr(nx.text.getKey( "TowerSuccessFloor" ),this.data.max_tower);
|
|
nx.gui.setString( nd, "name", str );
|
|
|
|
StartowerController.getInstance().refrreshNewTower( this.data );
|
|
},
|
|
|
|
setRewards() {
|
|
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 ];
|
|
rewards.push( { bid: item.bid || item.item_id, num: item.num } );
|
|
}
|
|
|
|
this.awardList.rebuild( rewards );
|
|
},
|
|
|
|
//設置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();
|
|
},
|
|
|
|
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,bustid,false);
|
|
this.roleSp.load(bust_res,(_e)=>{
|
|
if(!_e){
|
|
this.roleSp.action("stand2",true);
|
|
}else{
|
|
this.roleSp.stop();
|
|
}
|
|
});
|
|
}
|
|
},
|
|
|
|
//點開統計
|
|
clickHarm(){
|
|
nx.bridge.createPanel("WndSettleDetail",{data:this.data});
|
|
},
|
|
|
|
//返回挂機
|
|
clickBackHook(){
|
|
this.ctrl.requestOpenBattleRelevanceWindow( 3 );
|
|
this.close();
|
|
},
|
|
|
|
//開始下一關
|
|
clickNext(){
|
|
if(this.fight_type == 3){
|
|
BattleDramaController.getInstance().send13003();
|
|
}else{
|
|
StartowerController.getInstance().sender11322(this.data.max_tower+1,0);
|
|
}
|
|
nx.tbox("BatNextStart");
|
|
this.close();
|
|
},
|
|
|
|
autoNext(){
|
|
let timer = 10;
|
|
let str = cc.js.formatStr(nx.text.getKey("BatTimeNext"),timer);
|
|
nx.gui.setString(this.timeTxt,"",str);
|
|
this.schedule(()=>{
|
|
let str = cc.js.formatStr(nx.text.getKey("BatTimeNext"),timer);
|
|
nx.gui.setString(this.timeTxt,"",str);
|
|
timer--;
|
|
if(timer <= 0){
|
|
this.clickNext();
|
|
}
|
|
},1,9);
|
|
}
|
|
|
|
} );
|