const { all_ItemConfig, playerConfig, dropItemConfig, } = require('../../game/gameConfig'); const NetManage = require('../../manages/NetManage'); cc.Class({ extends: cc.Component, properties: { nd_closeBtn: { default: null, type: cc.Node, }, nd_gun: { default: null, type: cc.Node, }, nd_hero: { default: null, type: cc.Node, }, nd_gunContent: { default: null, type: cc.Node, }, nd_heroContent: { default: null, type: cc.Node, }, pb_hero: { default: null, type: cc.Prefab, }, pb_gun: { default: null, type: cc.Prefab, }, // nd_upperNode: { // default: null, // type: cc.Node, // }, }, init(data) { // this.allParam = new Array(); // this.allParam.forEach((param) => { // if (param.toString()[0] == '2') { // var pp = dropItemConfig[param.toString()].link_sort; // this.allParam.push(pp.toString()); // } // }); }, close() { this.nd_heroContent.children.forEach((element) => { element.scale = 1; }); this.nd_gunContent.children.forEach((element) => { element.scale = 1; }); this.node.active = false; this.currentData = null; }, onLoad() { this.nd_gunContent.destroyAllChildren(); 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); node.on('click', () => { this.nd_heroContent.children.forEach((element) => { element.scale = 1; }); this.nd_gunContent.children.forEach((element) => { element.scale = 1; }); node.scale = 1.1; this.currentData = element; }); var type = playerConfig[element.hero_id].herotype; //set cover // if ( // this.allParam.includes(element.hero_id.toString()) || // this.allParam.includes(type.toString()) // ) { // node.getComponent('wantedHero').hideCover(); // } // this.nd_heroContent.addChild(node); }); }); NetManage.gunList((data) => { var list = data.gun_list; list.forEach((element) => { const node = cc.instantiate(this.pb_gun); var sc = node.getComponent('guns_single'); sc.init(element); node.on('click', () => { this.nd_heroContent.children.forEach((element) => { element.scale = 1; }); this.nd_gunContent.children.forEach((element) => { element.scale = 1; }); node.scale = 1.1; this.currentData = element; }); this.nd_gunContent.addChild(node); }); }); }, onClickComfirm() { if (this.currentData != null) { // console.log("current send data:"+JSON.stringify(this.currentData)) cc.Notifier.emit('hasChoose', this.currentData); this.close(); } }, onClickHero() { this.nd_hero.active = true; this.nd_gun.active = false; }, onClickGun() { this.nd_hero.active = false; this.nd_gun.active = true; }, });