import { playerConfig } from '../../game/gameConfig'; import { arrtoarr } from '../../tools/utilsts'; const { ccclass, property } = cc._decorator; @ccclass export class UIHero extends cc.Component { @property(cc.Node) nd_tableview: cc.Node = null; @property(cc.Node) btnListNode: cc.Node = null; private _data = null; onLoad() { cc.Notifier.on('ongetHeroList', this, this.initdata.bind(this)); } onDestroy() { cc.Notifier.off('ongetHeroList', this); } initdata(data, type = 0) { this._data = data; const list = data.hero_list; let newlist = []; if (type != 0) { list.forEach((element) => { const config = playerConfig[element.hero_id]; if (config.herotype == type) { newlist.push(element); } }); } else { newlist = data.hero_list; } newlist = arrtoarr(newlist, 4); this.nd_tableview .getComponent('tableView') .initTableView(newlist.length, { array: newlist, target: this, }); } onclose() { this.node.destroy(); } onclicktype(data, event) { this.initdata(this._data, event); this.btnListNode.children.forEach((element) => { element.getChildByName('pick_status').opacity = 0; }); this.btnListNode.children[event].getChildByName( 'pick_status' ).opacity = 255; } }