Files
fc/dev/project/library/imports/00/00100e97-cf5f-46d7-8424-56222be00803.js
2026-05-24 10:21:26 +08:00

198 lines
6.0 KiB
JavaScript

"use strict";
cc._RF.push(module, '001006Xz19G14QkViIr4AgD', 'cmp.item.battle.buffinfo');
// Scripts/mod/battle/cmp/cmp.item.battle.buffinfo.js
"use strict";
var SVCItem = require("nx.fx.sv.expand.item");
var BattleController = require("battle_controller");
var HeroVo = require("hero_vo");
var Dir_Type = {
Left: 1,
// 左边英雄
Right: 2 // 右边英雄
};
cc.Class({
"extends": SVCItem,
properties: {
container: {
"default": null,
type: cc.Node
},
fab_partner: {
"default": null,
type: cc.Prefab
},
head: {
"default": null,
type: cc.Node
},
touch_layout: {
"default": null,
type: cc.Node
},
buff_item: {
"default": null,
type: cc.Node
},
list: {
"default": null,
type: cc.Node
}
},
// LIFE-CYCLE CALLBACKS:
// onLoad () {},
// // 数据重置
// rebind: function( _idx, _data, _key ) {
// this._super( _idx, _data, _key );
// // 刷新
// this.ctrl = BattleController.getInstance();
// this.setData(_data)
// },
// update (dt) {},
setData: function setData(data) {
if (nx.dt.objEmpty(data)) {
return;
}
this.data = data;
nx.bridge.NodeChidrenDestroy(this.list);
//英雄头像
if (!this.hero_head) {
this.hero_head = cc.instantiate(this.fab_partner);
this.hero_head.parent = this.head;
this.hero_head.position = cc.v2(0, -5);
this.hero_head.children[1].active = false;
}
// this.head.x = 35;
// this.list.x = 80;
// if(data.dir == Dir_Type.Right){
// this.head.x = 245;
// this.list.x = 10;
// }
var info = data.role.role_data;
// -- 头像
var hero_vo = new HeroVo();
hero_vo.face_id = "";
if (game.configs.partner_data.data_partner_base[info.object_bid]) {
hero_vo.bid = info.object_bid;
hero_vo.star = info.star;
} else {
var config = function config(id) {
return gunitdata("data_unit", id); // || gunitdata("data_unit2",id) ||gunitdata("data_unit3",id)
};
var unit_config = config(data.role.role_data.object_bid);
if (unit_config) {
hero_vo.bid = Number(unit_config.head_icon);
if (unit_config.star && unit_config.star > 0) {
hero_vo.star = unit_config.star;
} else {
var base_config = game.configs.partner_data.data_partner_base[hero_vo.bid];
if (base_config) {
hero_vo.star = base_config.init_star;
}
}
hero_vo.master_head_id = hero_vo.bid;
}
}
hero_vo.camp_type = info.camp_type;
hero_vo.lev = info.lev;
hero_vo.use_skin = info.fashion;
var cmp = this.hero_head.getComponent("cmp.partner.com");
cmp.rebind(0, hero_vo, "");
// -- buff 图标
var temp_list = {};
var temp_group_list = {};
this.buff_list_item = {};
for (var i in data.role.buff_list) {
var v = data.role.buff_list[i];
if (v == null) {
continue;
}
var buff_config = v.config;
var buff = v.buff;
var res_id = buff_config.icon;
// -- 根据配置表判断一下,如果角色死亡,buff是否为需要清除的
if (res_id != null && res_id != 0 && (info.hp > 0 || buff_config.clean_when_dead != null && buff_config.clean_when_dead == "false")) {
if (temp_list[res_id] == null) {
temp_list[res_id] = {
res_id: res_id,
num: 0,
name: buff_config.name,
remain_round: buff.remain_round,
desc: buff_config.desc,
buff_infos: []
};
}
if (temp_list[res_id].num == 0 || buff_config.join_type && buff_config.join_type != 3) {
temp_list[res_id].num = temp_list[res_id].num + 1;
temp_list[res_id].buff_infos.push({
buff_id: buff_config.bid,
remain_round: buff.remain_round
});
if (buff_config.group) {
temp_group_list[buff_config.group] = true;
}
} else if (buff_config.join_type && buff_config.join_type == 3 && buff_config.group && !temp_group_list[buff_config.group]) {
temp_group_list[buff_config.group] = true;
temp_list[res_id].num = temp_list[res_id].num + 1;
temp_list[res_id].buff_infos.push({
buff_id: buff_config.bid,
remain_round: buff.remain_round
});
}
}
}
this.buff_list_data = [];
for (var k in temp_list) {
var _v = temp_list[k];
this.buff_list_data.push(_v);
}
this.buff_list_data.sort(function (a, b) {
return a.res_id - b.res_id;
});
BattleController.getInstance().updateBattleBuffListView(this.buff_list_data, info.group, info.object_bid);
for (var _k = 0; _k < this.buff_list_item.length; ++_k) {
var buff_object = this.buff_list_item[_k];
if (buff_object) {
buff_object.active = false;
}
}
for (var _i = 0; _i < this.buff_list_data.length; ++_i) {
var bData = this.buff_list_data[_i];
var num = _i + 1;
if (num <= 8) {
//-- 最多显示8个
var _buff_object = this.buff_list_item[_i];
if (_buff_object == null) {
_buff_object = this.createBuffItem();
_buff_object.parent = this.list;
this.buff_list_item[_i] = _buff_object;
}
_buff_object.active = true;
_buff_object.getChildByName("num").getComponent(cc.Label).string = bData.num;
// -- 位置
var buff_icon_id = bData.res_id;
var buff_path = PathTool.queryIconPath(buff_icon_id);
nx.gui.setSpriteFrame(_buff_object, "", buff_path);
}
}
},
createBuffItem: function createBuffItem() {
var node = cc.instantiate(this.buff_item);
return node;
},
openBuffList: function openBuffList() {
if (this.buff_list_data && Utils.next(this.buff_list_data) != null) {
BattleController.getInstance().openBattleBuffListView(true, this.buff_list_data, this.data.group, this.data.object_bid);
}
}
});
cc._RF.pop();