const SVCItem = require("nx.fx.sv.expand.item") var BattleController = require("battle_controller"); var HeroVo = require("hero_vo"); const 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(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; // } let info = data.role.role_data // -- 头像 let 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{ let config = (id)=>{ return gunitdata("data_unit",id)// || gunitdata("data_unit2",id) ||gunitdata("data_unit3",id) } let 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{ let 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; let cmp = this.hero_head.getComponent("cmp.partner.com"); cmp.rebind( 0,hero_vo,"") // -- buff 图标 let temp_list = {}; let temp_group_list = {}; this.buff_list_item = {}; for(let i in data.role.buff_list){ let v = data.role.buff_list[i] if(v == null){ continue } let buff_config = v.config; let buff = v.buff; let 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(let k in temp_list){ let 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(let k=0;k