Files
fc/dev/project/library/imports/dc/dcb77dd5-490b-4b22-a20f-8034d433dee6.js
T
2026-05-24 10:21:26 +08:00

370 lines
10 KiB
JavaScript

"use strict";
cc._RF.push(module, 'dcb773VSQtLIqIPgDTUM97m', 'cmp.battle.settle.fail');
// Scripts/mod/battle/cmp/cmp.battle.settle.fail.js
"use strict";
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");
var BridgeWindow = require("bridge.window");
var NxSpine = require("nx.fx.spine");
var 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: function 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: function start() {},
// 重载:关闭前
onPreClosed: function onPreClosed() {
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: 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 == "WndFailSettle") {
wins++;
}
}
if (wins > 1) {
this.delayClose();
return;
}
var 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(function () {
nx.audio.playSFX("audios/effects/lose", false);
}, 0.1);
},
sendBattleClear: function 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: function doMainStep() {
var _this = this;
this.mainSp.action("action1", false, function (_key, _name) {
console.log(_key, _name);
if (_key == "t1") {
_this.icon.runAction(cc.fadeIn(0.16));
return;
}
if (_key == "t2") {
var index = 0;
_this.schedule(function () {
var 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: 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 partner_config = game.configs.partner_data.data_partner_base[this.hurt_mvp];
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();
}
});
}
},
// 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: 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;
}
}
},
touchGoBtn: function touchGoBtn(_type) {
this.openPanelByConfig(this.cfg_list[_type]);
this.ctrl.openFailFinishView(false, this.fight_type);
},
createButton: function 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 openPanelByConfig(config) {
var BCJ = BattleConst.JumpType;
var 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: function 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: 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;
}
});
} // update (dt) {},
});
cc._RF.pop();