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 itemInfo = itemConsume.itemInfo[0];
this.firstText.string = coinNumber + '';
this.secondText.string = this.stringFormat('转职卡', pack[0].count, itemInfo.count);
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 itemInfo = itemConsume.itemInfo[0];
this.firstText.string = coinNumber + '';
this.secondText.string = this.stringFormat(itemInfo.name, pack[0].count, itemInfo.count);
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) {},
});