const NetManage = require('../../manages/NetManage'); import { UIBase } from '../UIBase'; const { ccclass, property } = cc._decorator; @ccclass export class UpdateChoose extends UIBase { public static prefabPath: string = 'prefabs/UIPrefab/updatechoose'; @property(cc.Node) nd_heroContent: cc.Node = null; @property(cc.Prefab) pb_hero: cc.Prefab = null; private currentChoose: any; private qualityIndex = 0; init(data: any) { this.qualityIndex = data.index; // quality 0 main 1 sec this.nd_heroContent.destroyAllChildren(); NetManage.getHeroList((data) => { var list = data.hero_list; list.forEach((element) => { const node = cc.instantiate(this.pb_hero); var sc = node.getComponent('herochoseone'); sc.initdata(element); // if ( this.qualityIndex && this.qualityIndex == 1 && element.quality > 1 ) { node.getComponent('wantedHero').showCover(); } // node.on('click', () => { this.nd_heroContent.children.forEach((element) => { element.scale = 1; }); node.scale = 1.1; this.currentChoose = element; }); this.nd_heroContent.addChild(node); if (element.lock_type != 0) { node.getComponent('wantedHero').showCover(); } }); }); } onClose() { this.node.destroy(); } onOk() { if (this.currentChoose) { this.node.destroy(); var data = { index: this.qualityIndex, heroInfo: this.currentChoose, }; cc.Notifier.emit('academyCHOOSE', data); } else { cc.uiHelper.showTips('Must Choose a hero'); } } }