var RoleController = require("role_controller"); var BattleController = require("battle_controller"); var BattleDramaController = require("battle_drama_controller"); var BattleConst = require("battle_const"); var BattleEvent = require("battle_event"); const BridgeWindow = require("bridge.window"); const NxSpine = require( "nx.fx.spine" ); const FID = require( "bridge.function.ids" ); cc.Class({ extends: BridgeWindow, properties: { mainNd:{ default:null, type:cc.Node }, icon:{ default:null, type:cc.Node }, confirm:{ default:null, type:cc.Node }, infoNd:{ default:null, type:cc.Node }, 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 }, btns:{ default:[], type:[cc.Node] }, mainSp:{ default:null, type:NxSpine }, infoSp:{ default:null, type:NxSpine }, bMvp:{ default:null, type:NxSpine } }, // LIFE-CYCLE CALLBACKS: onLoad () { this.role_vo = RoleController.getInstance().getRoleVo(); this.ctrl = BattleController.getInstance(); this.model = this.ctrl.getModel(); this.drama_ctrl = BattleDramaController.getInstance(); this.is_running = false; this.is_result = false; this.effect_list = {}; this.x = 100; this.cfg_list = []; this.bindGEvent( BattleEvent.BATTLE_HARM_MVP, this.changeMvpDraw.bind( this ) ); }, start () { }, // 重载:关闭前 onPreClosed: function() { nx.bridge.vset( "ResultInfo", {} ); this.ctrl.delSpecialRetInfo(this.fight_type); if (this.model.getBattleScene() && this.ctrl.getIsSameBattleType(this.fight_type)) { if(this.is_result)return; var data = { combat_type: this.fight_type, result: this.result }; this.model.result(data, null); this.is_result = true; } if(this.fight_type == BattleConst.Fight_Type.newHeroUse){ nx.bridge.jumper.jump2Window(FID.StarUserTramp); } }, 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 == "WndFailSettle"){ wins++; } } if(wins > 1){ this.delayClose(); return; } let data = nx.bridge.vget("ResultInfo"); if(nx.dt.objEmpty(data)){ return; } //需要提前隐藏下层的战斗场景 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; //總傷害,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; } this.createButton(); this.doMainStep(); // this.scheduleOnce(()=>{ // this.sendBattleClear(); // },0.3); this.scheduleOnce(()=>{ nx.audio.playSFX("audios/effects/lose",false); },0.1); }, sendBattleClear(){ if (this.model.getBattleScene() && this.ctrl.getIsSameBattleType(this.fight_type)) { if(this.is_result)return; var data = { combat_type: this.fight_type, result: this.result }; this.model.result(data, null); this.is_result = true; } }, doMainStep(){ this.mainSp.action( "action1", false, ( _key, _name ) => { console.log( _key, _name ); if( _key == "t1" ) { this.icon.runAction(cc.fadeIn(0.16)); return; } if( _key == "t2" ) { let index = 0; this.schedule(()=>{ let btn = this.btns[index]; btn.runAction(cc.sequence(cc.spawn(cc.scaleTo(0.16,1.1),cc.fadeIn(0.16)),cc.scaleTo(0.16,1))); index++; },0.06,3); return; } if(_key == "t3"){ this.confirm.runAction(cc.sequence(cc.spawn(cc.scaleTo(0.16,1.1),cc.fadeIn(0.16)),cc.scaleTo(0.16,1))); return; } if( _key == "t4" ) { this.harm_btn.runAction(cc.fadeIn(0.33)); return; } if( _key == "complete" ) { this.mainSp.action("action2",true,null); return; } } ); }, 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= 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 partner_config = game.configs.partner_data.data_partner_base[this.hurt_mvp]; 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(); } }); } }, // setSvpPartner(){ // let partner_config = game.configs.partner_data.data_partner_base[this.cure_mvp]; // let skin_config = game.configs.partner_skin_data.data_skin_info[this.svp_skin_id]; // //名称和立绘 // if (partner_config) { // let bustid = partner_config.bustid; // if(skin_config){ // bustid = skin_config.bustid; // } // var bust_res = PathTool.getIconPath("models/"+bustid,"half_show"); // cc.loader.loadRes(bust_res, cc.SpriteFrame,(err,bg_sf)=> { // if(err){ // let emp = PathTool.getIconPath("empty","half_show"); // nx.gui.setSpriteFrame(this.svp_icon_sp.node,"",emp); // } // this.svp_icon_sp.spriteFrame = bg_sf; // }); // } // }, 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; } } }, touchGoBtn(_type){ this.openPanelByConfig(this.cfg_list[_type]); this.ctrl.openFailFinishView(false, this.fight_type); }, createButton(){ var config = game.configs.battle_act_data.data_get_fail_data; if (this.fight_type == BattleConst.Fight_Type.Darma) { var base_data = this.drama_ctrl.getModel().getDramaData(); var max_dun_id = base_data.max_dun_id; for (var i in config) { var v = config[i]; if (v.open_dungeon > max_dun_id) { this.btns[i-1].active = false; }else{ this.cfg_list.push(v); nx.gui.setString(this.btns[i-1],"label",v.icon_name); } } }else{ for (var i in config) { var v = config[i]; this.cfg_list.push(v); nx.gui.setString(this.btns[i-1],"label",v.icon_name); } } }, openPanelByConfig: function (config) { let BCJ = BattleConst.JumpType; let type = 0; switch( config.val_key ) { case BCJ.Summon: { type = 1; } break; case BCJ.HeroBag: { type = 19; } break; case BCJ.Forge: { type = 26; } break; case BCJ.Hallows: { type = 20; } break; default: return; } nx.bridge.jumper.jump2Window( type ); }, clickMain(){ this.mvp_icon_sp.node.opacity = 0; // this.svp_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; } }); } // update (dt) {}, });