Files
fc/dev/project/library/imports/56/5638463e-7ed1-42c2-9db8-f7496af8eefb.js
T
2026-05-24 10:21:26 +08:00

208 lines
6.4 KiB
JavaScript

"use strict";
cc._RF.push(module, '56384Y+ftFCwp2490lq+O77', 'cmp.item.battle.harm');
// Scripts/mod/battle/cmp/cmp.item.battle.harm.js
"use strict";
var SvcItem = require("nx.fx.sv.expand.item");
var PathTool = require("pathtool");
var HeroVo = require("hero_vo");
var NxSpine = require("nx.fx.spine");
var Harm_Type = {
Harm: 1,
// 伤害
Cure: 2 // 治疗
};
var Dir_Type = {
Left: 1,
// 左边英雄
Right: 2 // 右边英雄
};
cc.Class({
"extends": SvcItem,
properties: {
progress_pb: {
"default": null,
type: cc.ProgressBar
},
progress_pb2: {
"default": null,
type: cc.ProgressBar
},
progress_value_lb: {
"default": null,
type: cc.Label
},
progress_value_lb2: {
"default": null,
type: cc.Label
},
percent_txt1: {
"default": null,
type: cc.Label
},
percent_txt2: {
"default": null,
type: cc.Label
},
base_partner: {
"default": null,
type: cc.Prefab
}
},
// LIFE-CYCLE CALLBACKS:
// 数据重置
rebind: function rebind(_idx, _data, _key) {
this._super(_idx, _data, _key);
// 刷新
this.setData(_data);
},
onLoad: function onLoad() {},
start: function start() {},
onFocus: function onFocus() {
if (nx.dt.objEmpty(this.mdata)) {
return false;
}
},
outFocus: function outFocus() {},
setData: function setData(data) {
if (nx.dt.objEmpty(data)) {
return false;
}
this.node.x = -(data.idx * 60);
this.data = data.data;
// this.role_dir = data.index || Dir_Type.Left;
if (!this.max_harm_val) {
this.max_harm_val = data.left_max_harm;
}
if (!this.max_cure_val) {
this.max_cure_val = data.left_max_cure;
}
var vo = new HeroVo();
if (game.configs.partner_data.data_partner_base[this.data.bid]) {
vo.bid = this.data.bid;
vo.star = this.data.star;
} else {
var unit_config = Utils.getUnitConfig(this.data.bid);
if (unit_config) {
vo.bid = Number(unit_config.head_icon);
if (unit_config.star && unit_config.star > 0) {
vo.star = unit_config.star;
} else {
var base_config = game.configs.partner_data.data_partner_base[vo.bid];
if (base_config) {
vo.star = base_config.init_star;
}
}
}
}
vo.camp_type = this.data.camp_type;
vo.lev = this.data.lev;
vo.face_id = "";
if (this.data.ext_data) {
for (var i in this.data.ext_data) {
var v = this.data.ext_data[i];
if (v.key == 5) {
vo.use_skin = v.val;
}
}
}
this.hero = cc.instantiate(this.base_partner);
this.hero.parent = this.node;
this.hero.position = cc.v2(20, 40);
this.hero.scale = 0.8;
var cmp = this.hero.getComponent("cmp.item.base");
cmp.setData(vo);
// cmp.setSelectCall(this.onClickHero);
this.updateHarmType();
},
onClickHero: function onClickHero(hero) {},
updateHarmType: function updateHarmType() {
if (this.data) {
// this.harm_type = harm_type || Harm_Type.Harm;
// this.total_val = 0;
// this.cur_val = 0;
// if (this.harm_type == Harm_Type.Harm) {
// this.scheduleOnce(()=>{
// let is_harm_mvp = this.data.dps > 0 && this.data.dps == this.max_harm_val;
// if(is_harm_mvp){
// // this.is_mvp = 1;
// // this.mvp.action("action1",false);
// }
// },1);
// this.total_val = this.max_harm_val;
// this.cur_val = this.data.dps;
// } else {
// this.scheduleOnce(()=>{
// let is_cure_mvp = this.data.cure > 0 && this.data.cure == this.max_cure_val;
// if(is_cure_mvp){
// // this.is_mvp = 2;
// // this.mvp.action("action1",false);
// }
// },1);
// this.total_val = this.max_cure_val;
// this.cur_val = this.data.cure;
// }
// this.is_mvp = 0;
// this.temp_add = this.cur_val / 50;
// this.temp_harm_val = 0;
this.progress_pb.progress = this.max_harm_val == 0 ? 0 : this.data.dps / this.max_harm_val;
this.progress_pb2.progress = this.max_cure_val == 0 ? 0 : this.data.cure / this.max_cure_val;
this.percent_txt1.string = (this.progress_pb.progress * 100).toFixed(0) + "%";
this.percent_txt2.string = (this.progress_pb2.progress * 100).toFixed(0) + "%";
this.progress_value_lb.string = this.data.dps;
this.progress_value_lb2.string = this.data.cure;
// this.openProgressTimer(true)
}
},
// openProgressTimer: function (status) {
// if (status) {
// if (this.progress_timer == null) {
// this.progress_timer = this.schedule(()=>{
// this.temp_harm_val = this.temp_harm_val + this.temp_add;
// if (this.total_val == 0) {
// if(this.harm_type == Harm_Type.Harm){
// this.progress_pb.progress = 0;
// }else{
// this.progress_pb2.progress = 0;
// }
// } else if (this.temp_harm_val < this.cur_val) {
// if(this.harm_type == Harm_Type.Harm){
// this.progress_pb.progress = this.temp_harm_val / this.total_val;
// }else{
// this.progress_pb2.progress = this.temp_harm_val / this.total_val;
// }
// } else {
// if(this.harm_type == Harm_Type.Harm){
// this.progress_pb.progress = this.cur_val / this.total_val;
// }else{
// this.progress_pb2.progress = this.cur_val / this.total_val;
// }
// this.unschedule(this.progress_timer,this);
// this.progress_timer = null;
// }
// },0.03,cc.macro.REPEAT_FOREVER);
// }
// } else {
// if (this.progress_timer != null) {
// this.unschedule(this.progress_timer,this);
// this.progress_timer = null;
// }
// }
// },
onDisable: function onDisable() {
if (this.hero) {
this.hero.destroy();
}
// this.openProgressTimer(false);
} // update (dt) {},
});
cc._RF.pop();