Files
fc/dev/project/library/imports/55/5513d361-8d7f-4e6b-83e5-3c7e2a748a4e.js
2026-05-24 10:21:26 +08:00

226 lines
6.4 KiB
JavaScript

"use strict";
cc._RF.push(module, '5513dNhjX9Oa4PlPH4qdIpO', 'cmp.battle.fail');
// Scripts/mod/battle/cmp/cmp.battle.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");
cc.Class({
"extends": BridgeWindow,
properties: {
svp_con: {
"default": null,
type: cc.Node
},
harm_con: {
"default": null,
type: cc.Node
},
bust_icon_sp: {
"default": null,
type: cc.Sprite
},
hurtTxt_lb: {
"default": null,
type: cc.Label
},
special_sk: {
"default": null,
type: sp.Skeleton
},
harm_btn: {
"default": null,
type: cc.Node
},
btns: {
"default": [],
type: [cc.Node]
}
},
// 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.effect_list = {};
this.x = 100;
this.cfg_list = [];
},
start: function start() {
nx.audio.playSFX("audios/effects/lose");
},
touchClose: function touchClose() {
this.ctrl.openFailFinishView(false, this.fight_type);
},
// 重载:关闭前
onPreClosed: function onPreClosed() {
this.handleEffect(false);
if (this.model.getBattleScene() && this.ctrl.getIsSameBattleType(this.fight_type)) {
var data = {
combat_type: this.fight_type,
result: this.result
};
this.model.result(data, null);
}
},
onOpenConfigs: function onOpenConfigs(params) {
this.data = params[2];
this.result = params[1];
this.fight_type = params[0] || BattleConst.Fight_Type.Darma;
var svp_partner = 0;
var total_hurt = 0;
var svp_hurt = 0;
for (var i in this.data.hurt_statistics) {
var v = this.data.hurt_statistics[i];
var partner_list = v.partner_hurts; //计算dps
for (var hurt in partner_list) {
var partner = partner_list[hurt];
if (partner.srvid == this.role_vo.srv_id && partner.rid == this.role_vo.rid) {
total_hurt += partner.dps;
if (partner.dps > svp_hurt) {
svp_hurt = partner.dps;
svp_partner = partner.bid;
}
} else {
break;
}
}
}
this.partner_bid = svp_partner || 0;
this.partner_hurt = svp_hurt || 0;
this.partner_total_hurt = total_hurt || 0;
this.use_skin = this.data.use_skin || 0;
//等级
var partner_config = game.configs.partner_data.data_partner_base[this.partner_bid];
var skin_config = game.configs.partner_skin_data.data_skin_info[this.use_skin];
//名称和立绘
if (partner_config) {
var bustid = null;
if (skin_config) {
bustid = skin_config.bustid;
} else {
bustid = partner_config.bustid; //h30001
}
var bust_res = PathTool.getIconPath("models/" + bustid, "half_show");
nx.gui.setSpriteFrame(this.bust_icon_sp.node, "", bust_res);
// cc.loader.loadRes(bust_res, cc.SpriteFrame,(err,bg_sf)=> {
// if(err){
// let emp = PathTool.getIconPath("empty","half_show");
// nx.gui.setSpriteFrame(this.bust_icon_sp.node,"",emp);
// }
// this.bust_icon_sp.spriteFrame = bg_sf;
// });
}
if (this.data && this.data.hurt_statistics) {
this.harm_btn.active = true;
} else {
this.harm_btn.active = false;
}
this.handleEffect(true);
this.createButton();
//伤害统计
var hurtPercent = cc.js.formatStr("%s", Math.floor(this.partner_hurt / this.partner_total_hurt * 100)) + "%";
this.hurtTxt_lb.string = cc.js.formatStr("%d(%s)", Math.ceil(Number(this.partner_hurt)), hurtPercent);
},
touchGoBtn: function touchGoBtn(_type) {
this.openPanelByConfig(this.cfg_list[_type]);
this.ctrl.openFailFinishView(false, this.fight_type);
},
createButton: function createButton() {
var base_data = this.drama_ctrl.getModel().getDramaData();
var config = game.configs.battle_act_data.data_get_fail_data;
if (config && base_data) {
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);
var lb = nx.gui.getComponent(this.btns[i - 1], "label", cc.Label);
lb.string = v.icon_name;
}
}
}
},
handleEffect: function handleEffect(status) {
if (!status) {
if (this.special_sk) {
// this.special_sk.setToSetupPose();
// this.special_sk.clearTracks();
// this.special_sk.node.active = false;
}
} else {
if (this.special_sk) {
// this.special_sk.node.active = false;
// var res = PathTool.getSpinePath(PathTool.getEffectRes(104))
// cc.loader.loadRes(res, sp.SkeletonData ,(res_object)=> {
// this.special_sk.skeletonData = res_object;
// this.special_sk.setAnimation(1, PlayerAction.action, false)
// })
}
}
},
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);
},
clickHarm: function clickHarm() {
if (this.harm_con.scaleX == 0) {
this.harm_con.scaleX = 1;
this.svp_con.scaleX = 0;
gcore.GlobalEvent.fire(BattleEvent.BATTLE_HARM_DATA, this.data);
} else {
this.harm_con.scaleX = 0;
this.svp_con.scaleX = 1;
}
},
clickMvp: function clickMvp() {
if (this.svp_con.scaleX == 0) {
this.svp_con.scaleX = 1;
this.harm_con.scaleX = 0;
} else {
this.harm_con.scaleX = 1;
this.svp_con.scaleX = 0;
}
} // update (dt) {},
});
cc._RF.pop();