Files
fc/dev/project/library/imports/6a/6ac300c7-5162-4196-b1a1-7729b18b18c8.js
2026-05-24 10:21:26 +08:00

215 lines
7.2 KiB
JavaScript

"use strict";
cc._RF.push(module, '6ac30DHUWJBlrGhdymxixjI', 'cmp.battle.mvp');
// Scripts/mod/battle/cmp/cmp.battle.mvp.js
"use strict";
var PathTool = require("pathtool");
var BattleConst = require("battle_const");
var RoleController = require("role_controller");
var BattleController = require("battle_controller");
var BattleEvent = require("battle_event");
var FxSVC = require("nx.fx.sv.expand");
var BridgeWindow = require("bridge.window");
cc.Class({
"extends": BridgeWindow,
properties: {
svcList: {
"default": null,
type: FxSVC
},
mvp_con: {
"default": null,
type: cc.Node
},
harm_con: {
"default": null,
type: cc.Node
},
progress_pb: {
"default": null,
type: cc.ProgressBar
},
proTxt_lb: {
"default": null,
type: cc.Label
},
roleLvTxt_lb: {
"default": null,
type: cc.Label
},
bust_icon_sp: {
"default": null,
type: cc.Sprite
},
hurtTxt_lb: {
"default": null,
type: cc.Label
},
progressEffect: {
"default": null,
type: sp.Skeleton
},
topNd: {
"default": null,
type: cc.Node
},
fab_head: {
"default": null,
type: cc.Prefab
}
},
// LIFE-CYCLE CALLBACKS:
onLoad: function onLoad() {
this.ani_isover = false;
this.item_list = {};
this.role_vo = RoleController.getInstance().getRoleVo();
this.ctrl = BattleController.getInstance();
this.model = this.ctrl.getModel();
},
start: function start() {
this.head_icon = cc.instantiate(this.fab_head);
var cmp = this.head_icon.getComponent("cmp.common.header");
cmp.rebind(0, this.role_vo);
this.head_icon.parent = this.topNd;
this.head_icon.scale = 0.8;
this.head_icon.position = cc.v2(-200, 20);
nx.audio.playSFX("audios/effects/win");
},
// 重载:关闭前
onPreClosed: function onPreClosed() {
this.svcList.rebuild([]);
require("hero_controller").getInstance().openEquipTips(false);
require("tips_controller").getInstance().closeAllTips();
if (this.fight_type == BattleConst.Fight_Type.Darma) {
gcore.GlobalEvent.fire(BattleEvent.MOVE_DRAMA_EVENT, this.fight_type);
}
this.handleEffect(false);
if (this.model.getBattleScene() && this.ctrl.getIsSameBattleType(this.fight_type)) {
this.model.result(this.data, null);
}
},
onOpenConfigs: function onOpenConfigs(data) {
this.data = data;
this.result = data.result;
this.reward_list = data.item_rewards || [];
this.fight_type = data.combat_type || BattleConst.Fight_Type.Darma;
this.partner_bid = data.partner_bid || 0;
this.partner_hurt = data.partner_hurt || 0;
this.partner_total_hurt = data.partner_total_hurt || 0;
this.role_exp = data.exp || 0;
this.role_lv = data.lev || 1;
this.role_nowlv = data.new_lev || 1;
this.role_nowexp = data.new_exp || 0;
this.use_skin = data.use_skin || 0;
//等级
this.roleLvTxt_lb.string = cc.js.formatStr("Lv.%d", this.role_nowlv);
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) {
// this.roleNameTxt_lb.string = partner_config.name;
var bustid = null;
if (skin_config) {
bustid = skin_config.bustid;
} else {
bustid = partner_config.bustid;
}
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;
// });
}
//伤害统计
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);
this.showProgressEffect();
this.svcList.rebuild(this.reward_list);
},
showProgressEffect: function showProgressEffect() {
var baseCurMaxExp = game.configs.role_data.data_role_attr[this.role_lv].exp_max;
var basePercent = this.role_exp / baseCurMaxExp;
var maxPercent = this.role_nowexp / baseCurMaxExp;
if (this.role_lv != this.role_nowlv) {
//有升级
maxPercent = 1;
}
// if (this.data.auto_num && this.data.auto_num > 0) {
// this.auto_combat_num_lb.node.active = true;
// this.auto_combat_num_lb.string = cc.js.formatStr("Continuous customs clearance times: %s", this.data.auto_num);
// }
this.progress_pb.progress = basePercent;
this.proTxt_lb.string = cc.js.formatStr("%d/%d", Number(this.role_exp), Number(baseCurMaxExp));
var call_back = function () {
basePercent = basePercent + 0.01;
if (basePercent > maxPercent) {
if (this.role_lv == this.role_nowlv) {
baseCurMaxExp = game.configs.role_data.data_role_attr[this.role_nowlv].exp_max;
basePercent = this.role_nowexp / baseCurMaxExp;
this.progress_pb.progress = basePercent;
this.proTxt_lb.string = cc.js.formatStr("%d/%d", this.role_nowexp, Number(baseCurMaxExp));
} else {
//播放升级特效
if (this.progressEffect.skeletonData == null) {
var res = PathTool.getSpinePath(PathTool.getEffectRes(275), null);
this.loadRes(res, function (res_object) {
this.progressEffect.skeletonData = res_object;
// this.progressEffect.setAnimation(0, PlayerAction.action, false)
}.bind(this));
} else {
// this.progressEffect.setAnimation(0, PlayerAction.action, false)
}
this.role_lv = this.role_lv + 1;
basePercent = 0;
maxPercent = 1;
baseCurMaxExp = game.configs.role_data.data_role_attr[this.role_lv].exp_max;
if (this.role_lv == this.role_nowlv) {
maxPercent = this.role_nowexp / game.configs.role_data.data_role_attr[this.role_nowlv].exp_max;
}
}
} else {
this.progress_pb.progress = basePercent;
this.proTxt_lb.string = cc.js.formatStr("%d/%d", Math.ceil(baseCurMaxExp * basePercent), Number(baseCurMaxExp));
}
}.bind(this);
this.scheduleOnce(call_back, 0.1);
},
handleEffect: function handleEffect(status) {
if (!status) {
if (this.progressEffect) {
this.progressEffect.setToSetupPose();
this.progressEffect.clearTracks();
}
}
},
clickHarm: function clickHarm() {
if (this.harm_con.scaleX == 0) {
this.harm_con.scaleX = 1;
this.mvp_con.scaleX = 0;
gcore.GlobalEvent.fire(BattleEvent.BATTLE_HARM_DATA, this.data);
} else {
this.harm_con.scaleX = 0;
this.mvp_con.scaleX = 1;
}
},
clickMvp: function clickMvp() {
if (this.mvp_con.scaleX == 0) {
this.mvp_con.scaleX = 1;
this.harm_con.scaleX = 0;
} else {
this.harm_con.scaleX = 1;
this.mvp_con.scaleX = 0;
}
} // update (dt) {},
});
cc._RF.pop();