153 lines
3.3 KiB
JavaScript
153 lines
3.3 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,
|
|
},
|
|
|
|
wantedNode: {
|
|
default: null,
|
|
type: cc.Node,
|
|
},
|
|
|
|
pveBar: {
|
|
default: null,
|
|
type: cc.ProgressBar,
|
|
},
|
|
pveget: {
|
|
default: null,
|
|
type: cc.Label,
|
|
},
|
|
},
|
|
|
|
showWanted() {
|
|
this.wantedNode.active = true;
|
|
},
|
|
|
|
initdata(v) {
|
|
this._data = v;
|
|
if (v != 0) {
|
|
this.node.active = true;
|
|
} else {
|
|
this.node.active = false;
|
|
return;
|
|
}
|
|
|
|
var lefttime = v.unlock_lefttime;
|
|
|
|
if (v.lock_type == 3) {
|
|
this.showWanted();
|
|
// this.wantedNode.getComponentInChildren(cc.Label).string =
|
|
// this.formatSeconds(lefttime);
|
|
this.schedule(function () {
|
|
this.wantedNode.getComponentInChildren(cc.Label).string =
|
|
this.formatSeconds(lefttime);
|
|
lefttime -= 1;
|
|
}, 1);
|
|
} else {
|
|
this.wantedNode.active = false;
|
|
}
|
|
//
|
|
//pve
|
|
var pveuplimit = v.pve_ceg_uplimit;
|
|
var pveget = v.today_pve_get_ceg;
|
|
if (this.pveBar)
|
|
this.pveBar.progress = (pveuplimit - pveget) / pveuplimit;
|
|
if (this.pveget)
|
|
this.pveget.string = `${pveuplimit - pveget}/${pveuplimit}`;
|
|
//
|
|
//
|
|
var limit = v.ceg_uplimit;
|
|
var get = v.today_get_gold;
|
|
|
|
if (this.limitBar) this.limitBar.progress = (limit - get) / limit;
|
|
if (this.cegget)
|
|
this.cegget.string = `${limit - 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);
|
|
},
|
|
|
|
formatSeconds(value) {
|
|
let result = parseInt(value);
|
|
let h =
|
|
Math.floor(result / 3600) < 10
|
|
? '0' + Math.floor(result / 3600)
|
|
: Math.floor(result / 3600);
|
|
let m =
|
|
Math.floor((result / 60) % 60) < 10
|
|
? '0' + Math.floor((result / 60) % 60)
|
|
: Math.floor((result / 60) % 60);
|
|
let s =
|
|
Math.floor(result % 60) < 10
|
|
? '0' + Math.floor(result % 60)
|
|
: Math.floor(result % 60);
|
|
|
|
let res = '';
|
|
res += `${h}:`;
|
|
res += `${m}:`;
|
|
res += `${s}`;
|
|
return res;
|
|
},
|
|
});
|