pubgv3/assets/scripts/UI/hero/herochoseone.js
guoqing.zhu 9bb0b6fdf0 update
2022-05-31 21:59:21 +08:00

92 lines
2.4 KiB
JavaScript

var SDKManage = require('SDKManage');
var gameConfig = require('gameConfig');
const { uimanger } = require('../UIManger');
cc.Class({
extends: cc.Component,
properties: {
lb_name: {
default: null,
type: cc.Label,
},
nd_weijiesuo: {
default: null,
type: cc.Node,
},
sp_zhiye: {
default: null,
type: cc.Sprite,
},
spine_hero: {
default: null,
type: sp.Skeleton,
},
infoPage: {
default: null,
type: cc.Prefab,
},
limitBar: {
default: null,
type: cc.ProgressBar,
},
cegget: {
default: null,
type: cc.Label,
},
},
initdata(v) {
this._data = v;
if (v != 0) {
this.node.active = true;
} else {
this.node.active = false;
return;
}
//
var limit = v.ceg_uplimit
var get = v.today_get_gold
this.limitBar.progress =(limit-get)/limit
this.cegget.string = `${v.today_get_gold}/${v.ceg_uplimit}`
this.hero_id = v.hero_id;
var self = this;
var cfg = gameConfig.playerConfig[v.hero_id];
var 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_zhiye.spriteFrame = res;
}
}.bind(this)
);
var skinres = cc.playerData.getheroSkinbyId(this.hero_id, 0);
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);
}.bind(this)
);
this.lb_name.string = cfg.name;
this.hasget = cc.playerData.checkhasgethero(v);
},
onclick() {
uimanger.showUI(this.infoPage, this._data);
},
});