const JobPageType = require('../utils/GameEnum').JobPageType;
cc.Class({
extends: cc.Component,
properties: {
iconSprite: cc.Sprite,
firstSprite: cc.Sprite,
firstText: cc.RichText,
secondSprite: cc.Sprite,
secondText: cc.RichText,
},
// onLoad () {},
start() {
},
bindData(type) {
let leftIcon = '';
let secondIcon = '';
if (type === JobPageType.ChangeJob) {
leftIcon = './textures/job/change_job_consume_icon';
secondIcon = './textures/job/change_job_card';
this.secondText.string = '转职卡(0/15)';
} else {
leftIcon = './textures/job/level_up_consume_icon';
secondIcon = './textures/job/level_up_consume_actor';
this.secondText.string = '转职卡(0/15)';
}
cc.loader.loadRes(leftIcon, cc.SpriteFrame, (error, spriteFrame) => {
this.iconSprite.spriteFrame = spriteFrame;
});
cc.loader.loadRes(secondIcon, cc.SpriteFrame, (error, spriteFrame) => {
this.secondSprite.spriteFrame = spriteFrame;
});
},
bindChangeJob(itemConsume, pack) {
let coinNumber = itemConsume.coin;
let itemInfoCount = itemConsume.itemInfo ? itemConsume.itemInfo[0].count : 0;
this.firstText.string = coinNumber + '';
let cardCount = 0;
if (pack && pack.length > 0) {
cardCount = pack[0].count;
}
this.secondText.string = this.stringFormat('转职卡', cardCount, itemInfoCount);
cc.loader.loadRes('./textures/job/change_job_consume_icon', cc.SpriteFrame, (error, spriteFrame) => {
this.iconSprite.spriteFrame = spriteFrame;
});
cc.loader.loadRes('./textures/job/change_job_card', cc.SpriteFrame, (error, spriteFrame) => {
this.secondSprite.spriteFrame = spriteFrame;
});
},
bindDataLevelUp(itemConsume, pack) {
let coinNumber = itemConsume.coin;
let itemInfoCount = itemConsume.itemInfo ? itemConsume.itemInfo[0].count : 0;
this.firstText.string = coinNumber + '';
let cardCount = 0;
if (pack && pack.length > 0) {
cardCount = pack[0].count;
}
this.secondText.string = this.stringFormat(itemConsume.itemInfo[0].name, cardCount, itemInfoCount);
cc.loader.loadRes('./textures/job/level_up_consume_icon', cc.SpriteFrame, (error, spriteFrame) => {
this.iconSprite.spriteFrame = spriteFrame;
});
cc.loader.loadRes('./textures/job/level_up_consume_actor', cc.SpriteFrame, (error, spriteFrame) => {
this.secondSprite.spriteFrame = spriteFrame;
});
},
stringFormat(name, pack, consume) {
let color = consume > pack ? '#f33e35' : '#ffffff'
return `${name}(${pack}/${consume})`;
},
// update (dt) {},
});