var gameConfig = require("gameConfig") var NetManage = require("NetManage") var Utils = require("Utils") cc.Class({ extends: cc.Component, properties: { nd_items: { default: [], type: cc.Node }, pb_clip: { default: null, type: cc.Prefab }, nd_xiangqing: { default: null, type: cc.Node }, nd_now: { default: null, type: cc.Node }, lb_lv1: { default: null, type: cc.Label }, lb_des1: { default: null, type: cc.Label }, nd_next: { default: null, type: cc.Node }, lb_lv2: { default: null, type: cc.Label }, lb_des2: { default: null, type: cc.Label }, nd_cost: { default: null, type: cc.Node }, nd_suoding: { default: null, type: cc.Node }, nd_max: { default: null, type: cc.Node }, lb_opendes: { default: null, type: cc.Label }, lb_opencondtion: { default: null, type: cc.Label }, pb_itemcost: { default: null, type: cc.Prefab }, nd_costitems: { default: null, type: cc.Node }, sp_biggun: { default: null, type: cc.Sprite }, sp_cicon1: { default: null, type: cc.Sprite }, sp_cicon2: { default: null, type: cc.Sprite }, }, // LIFE-CYCLE CALLBACKS: onLoad() { cc.Notifier.on("clickclip", this, this.clickclip.bind(this)); cc.Notifier.on("ontalent_list", this, this.ontalent_list.bind(this)); }, onDestroy() { cc.Notifier.off("clickclip", this); cc.Notifier.off("ontalent_list", this); }, start() { this.clipslist = [] for (var i = 0; i < this.nd_items.length; i++) { var nd = cc.instantiate(this.pb_clip) var scp = nd.getComponent("pbclip") this.clipslist.push(scp) this.nd_items[i].addChild(nd) } this.refreshxp(1) }, ontalent_list() { this.refreshxp(this.nowtype) }, refreshxp(tp) { this.nowtype = tp // cc.playerData.talent_list var ids = gameConfig.gunTalent[tp].talent_list.split('|') for (var i = 0; i < this.clipslist.length; i++) { if (ids[i] != 0) { this.nd_items[i].active = true this.clipslist[i].initdata(ids[i]) } else { this.nd_items[i].active = false } } this.clipslist[0].onclick() cc.loader.loadRes("itemicon/gun/" + gameConfig.gunTalent[tp].gunicon, cc.SpriteFrame, function(err, res) { if (!err && this.isValid) { this.sp_biggun.spriteFrame = res; } }.bind(this)); }, onclose() { this.node.destroy() }, onclicktype(v1, v2) { this.refreshxp(Number(v2)) cc.Notifier.emit("btnchose",{key: "xinpian" + v2}) }, clickclip(v) { this.nd_next.active = this.nd_now.active = this.nd_suoding.active = this.nd_max.active = this.nd_cost.active = false if (v.open) { this.nd_now.active = true if (v.nextdata) { this.nd_next.active = true this.nd_cost.active = true this.lb_lv2.string = v.nextdata.talent_lv this.lb_des2.string = v.nextdata.des this.nd_costitems.destroyAllChildren() var itemarr = v.nowdata.cost.split('|') for (var i = 0; i < itemarr.length; i++) { var nd = cc.instantiate(this.pb_itemcost) nd.getComponent("itemcount").initdata2(itemarr[i], true) this.nd_costitems.addChild(nd) } } else { this.nd_max.active = true } } else { this.nd_suoding.active = true this.lb_opendes.string = v.nowdata.des this.lb_opencondtion.string = "" + v.nowdata.need_user_level + "" } this.lb_lv1.string = v.nowdata.talent_lv this.lb_des1.string = v.nowdata.des this.nowid = v.nowdata.talent_id cc.loader.loadRes("itemicon/chips/" + v.nowdata.icon, cc.SpriteFrame, function(err, res) { if (!err && this.isValid) { this.sp_cicon1.spriteFrame = res; } }.bind(this)); cc.loader.loadRes("itemicon/chips/" + v.nowdata.nameicon + "2", cc.SpriteFrame, function(err, res) { if (!err && this.isValid) { this.sp_cicon2.spriteFrame = res; } }.bind(this)); }, onclicklvup() { NetManage.upgradeTalentLv(this.nowid) } // update (dt) {}, });