106 lines
2.8 KiB
JavaScript
106 lines
2.8 KiB
JavaScript
var gameConfig = require("gameConfig")
|
|
|
|
cc.Class({
|
|
extends: cc.Component,
|
|
|
|
properties: {
|
|
nd_lvup: {
|
|
default: null,
|
|
type: cc.Node
|
|
},
|
|
nd_close: {
|
|
default: null,
|
|
type: cc.Node
|
|
},
|
|
nd_open: {
|
|
default: null,
|
|
type: cc.Node
|
|
},
|
|
sp_icon: {
|
|
default: null,
|
|
type: cc.Sprite
|
|
},
|
|
lb_close: {
|
|
default: null,
|
|
type: cc.Label
|
|
},
|
|
lb_open: {
|
|
default: null,
|
|
type: cc.Label
|
|
},
|
|
lb_lv: {
|
|
default: null,
|
|
type: cc.Label
|
|
},
|
|
},
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
onLoad() {
|
|
cc.Notifier.on("talent_lvup", this, this.talent_lvup.bind(this));
|
|
},
|
|
|
|
onDestroy() {
|
|
cc.Notifier.off("talent_lvup", this);
|
|
},
|
|
talent_lvup(v){
|
|
if(v==this.tid){
|
|
this.initdata(v)
|
|
this.onclick()
|
|
}
|
|
},
|
|
initdata(id) {
|
|
this.tid = id
|
|
this.nd_close.active = this.nd_lvup.active = this.nd_open.active = false
|
|
var leanxp = cc.playerData.getLearnedTalent(id)
|
|
this.nowlv = 1
|
|
this.open = false
|
|
if (leanxp) {
|
|
this.open = true
|
|
this.nd_open.active = true
|
|
this.nowlv = leanxp.talent_lv
|
|
} else {
|
|
this.nd_close.active = true
|
|
}
|
|
this.nowdata = cc.playerData.xinpian[id][this.nowlv - 1]
|
|
this.lb_close.string = this.nowdata.name
|
|
this.lb_open.string = this.nowdata.name
|
|
this.lb_lv.string = "LV." + this.nowlv
|
|
this.nextdata = cc.playerData.xinpian[id][this.nowlv]
|
|
|
|
cc.loader.loadRes("itemicon/chips/" + this.nowdata.icon, cc.SpriteFrame, function(err, res) {
|
|
if (!err && this.isValid) {
|
|
this.sp_icon.spriteFrame = res;
|
|
}
|
|
}.bind(this));
|
|
|
|
|
|
if(this.open){
|
|
if(this.nextdata){
|
|
var isenough = true
|
|
var itemarr = this.nowdata.cost.split('|')
|
|
for(var i=0;i<itemarr.length;i++){
|
|
var oneitem = itemarr[i].split(':')
|
|
if(!cc.playerData.checkItemEnough(oneitem[0],oneitem[1])){
|
|
isenough = false
|
|
break
|
|
}
|
|
}
|
|
this.nd_lvup.active = isenough
|
|
}else{
|
|
this.lb_lv.string = "Lvmax"
|
|
}
|
|
}
|
|
|
|
},
|
|
onclick() {
|
|
var data = {
|
|
nowdata: this.nowdata,
|
|
nextdata: this.nextdata,
|
|
open: this.open
|
|
}
|
|
|
|
cc.Notifier.emit("clickclip", data)
|
|
},
|
|
// update (dt) {},
|
|
}); |