"use strict"; cc._RF.push(module, 'f2a0bb+eQlEwJNPZSAawUCX', 'cmp.battle.settle.win'); // Scripts/mod/battle/cmp/cmp.battle.settle.win.js "use strict"; var PathTool = require("pathtool"); var BattleConst = require("battle_const"); var BattleController = require("battle_controller"); var BattleEvent = require("battle_event"); var RoleController = require("role_controller"); var StartowerController = require("startower.mod"); var StartowerEvent = require("startower.define"); var HTC = require("hero_controller"); var FID = require("bridge.function.ids"); var ItemLay = require("cmp.common.itemlayout"); var NxSpine = require("nx.fx.spine"); var BridgeWindow = require("bridge.window"); var CampFitMod = require("campfight.mod"); var 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: function 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: function start() {}, delayCloss: function delayCloss(_data) { if (!_data) { return; } if (_data && _data == 1) { this.close(); nx.bridge.vset("CloseSpecial", null); } }, // 重载:关闭前 onPreClosed: function onPreClosed() { 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: function onOpenConfigs(params) { var wins = 0; var par = nx.bridge.ui.getSceneNode(5); for (var i in par.children) { if (par.children[i] && par.children[i].name == "WndWinSettle") { wins++; } } if (wins > 1) { this.delayClose(); return; } var 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; var action1 = "action1_1"; var 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(function () { nx.audio.playSFX("audios/effects/win", false); }, 0.1); }, sendBattleClear: function 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: function doMainStep(start_act, final_act) { var _this = this; this.mainSp.action(start_act, false, function (_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(function () { _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: function setMainPanel() { var 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: function setPVPMatchInfo(nd) { // console.log( "顯示相關" ); var cfg = game.configs.arena_elite_data.data_elite_level; var ncfg = cfg[this.data.elite_lev]; var total = ncfg.need_exp; var 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); var exp = this.data.end_score > total ? total : this.data.end_score; nx.gui.setString(nd, "normal/expinfo", exp + "/" + nncfg.need_exp); var mod = PVPRank.getInstance(); var path = mod.dealUI(this.data.elite_lev); var newpath = mod.dealUI(this.data.new_elite_lev); nx.gui.setString(nd, "normal/exp/txt", exp); var 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); var prog = nx.gui.find(nd, "normal/prog"); var progbefore = nx.gui.find(nd, "normal/prognor"); var cmp = prog.getComponent(cc.ProgressBar); if (cmp) { cmp.progress = this.data.score / total; } var 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: function setYearCrossInfo(nd) { var hurt_arr = this.data.hurt_statistics; var partner_hurt = {}; for (var i = 0; i < hurt_arr.length; i++) { var data = hurt_arr[i]; if (data.type == 1) { //我方數據 partner_hurt = data.partner_hurts; } } var all_dmg = 0; for (var a in partner_hurt) { if (partner_hurt[a]) { all_dmg += partner_hurt[a].dps; } } nx.gui.setString(nd, "dps", all_dmg); }, setSBossInfo: function setSBossInfo(nd) { var hurt_arr = this.data.hurt_statistics; var partner_hurt = {}; for (var i = 0; i < hurt_arr.length; i++) { var data = hurt_arr[i]; if (data.type == 1) { //我方數據 partner_hurt = data.partner_hurts; } } var all_dmg = 0; for (var a in partner_hurt) { if (partner_hurt[a]) { all_dmg += partner_hurt[a].dps; } } var all_cure = 0; for (var _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: function setHeavenInfo(nd) { var con_infos = game.configs.dungeon_heaven_data.data_customs[this.data.id][this.data.order_id].cond_info; if (!con_infos) return; for (var i in con_infos) { var cfg = game.configs.dungeon_heaven_data.data_star_cond[con_infos[i][1]]; var item = nd.children[i]; if (item && cfg) { for (var 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: function setEndlessInfo(nd) { nx.gui.setString(nd, "max_lev", this.data.target_role_name); }, setPlanesInfo: function setPlanesInfo(nd) { nx.gui.setString(nd, "dps", this.data.all_dps); var vo = HTC.getInstance().getModel().getHeroById(this.data.best_partner); if (vo) { var heroNd = nx.gui.find(nd, "head"); if (!this.bestPartner) { this.bestPartner = cc.instantiate(this.fabPartner); this.bestPartner.parent = heroNd; } var cmp = nx.gui.getComponent(this.bestPartner, "", "cmp.partner.com"); cmp.setData(vo); } }, setTowerInfo: function setTowerInfo(nd) { var str = nx.text.getKey("lab_eleMaxLev") + this.data.max_tower; nx.gui.setString(nd, "time", str); StartowerController.getInstance().refrreshNewTower(this.data); }, setDramaInfo: function 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); //设置头像 var headNd = nx.gui.find(nd, "head"); this.head_icon = cc.instantiate(this.fab_head); var cmp = this.head_icon.getComponent("cmp.common.header"); if (this.role_vo) { cmp.rebind(0, this.role_vo); } this.head_icon.parent = headNd; }, //剧情经验条 showDramaProgress: function 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; } var 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: function setInfos() { if (nx.dt.arrEmpty(this.data.hurt_statistics)) { return; } var hurt_arr = this.data.hurt_statistics; var partner_hurt = {}; for (var i = 0; i < hurt_arr.length; i++) { var data = hurt_arr[i]; if (data.type == 1) { //我方數據 partner_hurt = data.partner_hurts; } } if (nx.dt.arrEmpty(partner_hurt)) { return; } var total_hurt = 0; var mvp_hurt = 0; this.mvp_skin_id = 0; var svp_cure = 0; this.svp_skin_id = 0; for (var v in partner_hurt) { var info = partner_hurt[v]; //总伤害 total_hurt += info.dps; if (info.dps >= mvp_hurt) { //生成新的dps mvp_hurt = info.dps; this.hurt_mvp = info.bid; for (var 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 (var _key2 in info.ext_data) { if (info.ext_data[_key2].key == 5) { this.svp_skin_id = info.ext_data[_key2].val; } } } } this.setMvpPartner(); // this.setSvpPartner(); //伤害统计 this.hurtTxt.string = total_hurt; }, setMvpPartner: function setMvpPartner() { var _this2 = this; var 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); // } var partner_config = game.configs.partner_data.data_partner_base[mvp_bid]; var skin_config = game.configs.partner_skin_data.data_skin_info[this.mvp_skin_id]; //名称和立绘 if (partner_config) { var 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, function (_e) { if (!_e) { _this2.mvp_icon_sp.action("action1", true); } else { _this2.mvp_icon_sp.stop(); } }); } }, setRewards: function setRewards() { this.rewardNd.active = true; this.rewardNd.runAction(cc.fadeIn(0.16)); var rewards = []; if (this.first_items) { for (var i in this.first_items) { var v = this.first_items[i]; rewards.push({ bid: v.item_id, num: v.num }); } } for (var a = 0; a < this.reward_list.length; a++) { var item = this.reward_list[a]; if (item) { rewards.push({ bid: item.bid || item.item_id, num: item.num }); } } this.list.rebuild(rewards); }, changeMvpDraw: function 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: function clickMain() { this.mvp_icon_sp.node.opacity = 0; this.mainNd.active = true; this.infoNd.scaleX = 0; this.bMvp.node.active = false; }, clickInfo: function clickInfo() { var _this3 = this; this.mainNd.active = false; this.infoNd.active = true; this.infoNd.scaleX = 1; this.infoSp.action("action1_1", false, function (_key, _name) { if (_key == "start") { _this3.changeMvpDraw(1); gcore.GlobalEvent.fire(BattleEvent.BATTLE_HARM_DATA, _this3.data); } if (_key == "complete") { _this3.infoSp.action("action1_2", true); return; } }); }, // ========================================== // 引导相关 // ========================================== // 引导事件 postPlotEvent: function postPlotEvent(_key) { if (nx.bridge.plot && nx.dt.strNEmpty(_key)) { nx.bridge.plot.postKey(_key); } } }); cc._RF.pop();