227 lines
6.9 KiB
JavaScript
227 lines
6.9 KiB
JavaScript
const SvcItem = require("nx.fx.sv.expand.item");
|
|
var PathTool = require("pathtool")
|
|
var HeroVo = require("hero_vo");
|
|
const NxSpine = require( "nx.fx.spine" );
|
|
|
|
const Harm_Type = {
|
|
Harm: 1, // 伤害
|
|
Cure: 2 // 治疗
|
|
}
|
|
|
|
const 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( _idx, _data, _key ) {
|
|
|
|
this._super( _idx, _data, _key );
|
|
|
|
// 刷新
|
|
this.setData(_data)
|
|
|
|
},
|
|
|
|
onLoad () {
|
|
},
|
|
|
|
start () {
|
|
|
|
},
|
|
|
|
onFocus(){
|
|
if( nx.dt.objEmpty( this.mdata ) ) {
|
|
return false;
|
|
}
|
|
},
|
|
|
|
outFocus(){
|
|
|
|
},
|
|
|
|
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(let i in this.data.ext_data){
|
|
let 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;
|
|
let cmp = this.hero.getComponent( "cmp.item.base" );
|
|
cmp.setData(vo);
|
|
// cmp.setSelectCall(this.onClickHero);
|
|
|
|
this.updateHarmType();
|
|
},
|
|
|
|
onClickHero(hero){
|
|
|
|
},
|
|
|
|
updateHarmType: function () {
|
|
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(){
|
|
if(this.hero){
|
|
this.hero.destroy();
|
|
}
|
|
// this.openProgressTimer(false);
|
|
}
|
|
|
|
// update (dt) {},
|
|
});
|