1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- 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 = '<b>转职卡</b><color=#f33e35>(0/15)</color>';
- } else {
- leftIcon = './textures/job/level_up_consume_icon';
- secondIcon = './textures/job/level_up_consume_actor';
- this.secondText.string = '<b>转职卡</b><color=#f33e35>(0/15)</color>';
- }
- 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 `<b>${name}</b><color=${color}>(${pack}/${consume})</color>`;
- },
- // update (dt) {},
- });
|