113 lines
3.1 KiB
JavaScript
113 lines
3.1 KiB
JavaScript
var SDKManage = require("SDKManage")
|
|
var gameConfig = require("gameConfig")
|
|
cc.Class({
|
|
extends: cc.Component,
|
|
|
|
properties: {
|
|
nd_yz: {
|
|
default: null,
|
|
type: cc.Node
|
|
},
|
|
lb_name: {
|
|
default: null,
|
|
type: cc.Label
|
|
},
|
|
spine_hero: {
|
|
default: null,
|
|
type: sp.Skeleton
|
|
},
|
|
sp_type: {
|
|
default: null,
|
|
type: cc.Sprite
|
|
},
|
|
nd_ready: {
|
|
default: null,
|
|
type: cc.Node
|
|
},
|
|
nd_selfnode: {
|
|
default: null,
|
|
type: cc.Node
|
|
},
|
|
|
|
pb_skin: {
|
|
default: null,
|
|
type: cc.Prefab
|
|
},
|
|
nd_skinview: {
|
|
default: null,
|
|
type: cc.Node
|
|
},
|
|
|
|
nd_processbar:{
|
|
default: null,
|
|
type: cc.ProgressBar
|
|
},
|
|
|
|
nd_remainceg:{
|
|
default: null,
|
|
type: cc.Label
|
|
},
|
|
},
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
onLoad() {
|
|
this.sp_type.spriteFrame = null
|
|
},
|
|
|
|
initdata(opt) {
|
|
this.lb_name.string = opt.name
|
|
this.nd_ready.active = opt.state != 0
|
|
if (opt.hero_id != 0 && this.hero_id != opt.hero_id) {
|
|
this.hero_id = opt.hero_id
|
|
let heroType = gameConfig.playerConfig[this.hero_id].herotype
|
|
let url = "textures/heroType/ht_s_" + heroType;
|
|
|
|
cc.loader.loadRes(url, cc.SpriteFrame, function(err, res) {
|
|
if (!err && this.isValid) {
|
|
this.sp_type.spriteFrame = res;
|
|
}
|
|
}.bind(this));
|
|
|
|
}
|
|
|
|
if (opt.hero_skin != 0 && this.hero_skin != opt.hero_skin) {
|
|
this.hero_skin = opt.hero_skin
|
|
var skinres = gameConfig.all_ItemConfig[this.hero_skin].skinid
|
|
cc.loader.loadRes("spine/heropic/pic_hero" + skinres, sp.SkeletonData, function(err, sp) {
|
|
this.spine_hero.skeletonData = sp;
|
|
this.spine_hero._updateSkeletonData();
|
|
this.spine_hero.setAnimation(0, "animation", true);
|
|
this.nd_yz.active = false
|
|
}.bind(this));
|
|
}
|
|
|
|
|
|
this.nd_selfnode.active = opt.account_id == SDKManage.account_id
|
|
|
|
if (this.nd_selfnode.active) {
|
|
this.target.doready(opt.state)
|
|
this.nd_skinview.active = true
|
|
this.nd_skinview.destroyAllChildren()
|
|
|
|
if (opt.hero_id != 0) {
|
|
var skinsarr = cc.playerData.getskinarrbyId(this.hero_id)
|
|
this.skinscparr = []
|
|
for (var i = 0; i < skinsarr.length; i++) {
|
|
var nd = cc.instantiate(this.pb_skin)
|
|
var scp = nd.getComponent("skinitem")
|
|
scp.initdata(skinsarr[i])
|
|
this.nd_skinview.addChild(nd)
|
|
}
|
|
}
|
|
|
|
|
|
} else {
|
|
this.nd_skinview.active = false
|
|
}
|
|
|
|
|
|
},
|
|
|
|
// update (dt) {},
|
|
}); |