123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- const JobPageType = require('../utils/GameEnum').JobPageType;
- const GameModel = require('../utils/GameModule');
- const DWTool = require('../utils/DWTool');
- cc.Class({
- extends: cc.Component,
- properties: {
- iconSprite: cc.Sprite,
- firstSprite: cc.Sprite,
- firstText: cc.RichText,
- secondSprite: cc.Sprite,
- secondText: cc.RichText,
- },
- // onLoad () {},
- start() {
- },
- setConfirmButton(button) {
- this.button = button;
- },
- bindData(type) {
- let leftIcon = '';
- let secondIcon = '';
- if (type === JobPageType.ChangeJob) {
- leftIcon = './job/change_job_consume_icon';
- secondIcon = './job/change_job_card';
- this.secondText.string = '<b>转职卡</b><color=#f33e35>(0/15)</color>';
- } else {
- leftIcon = './job/level_up_consume_icon';
- secondIcon = './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(gold, cardInfo, pack) {
- let color = '#ffffff';
- if (gold <= GameModel.userInfo.grossIncome) {
- color = '#ffffff';
- } else {
- color = '#f33e35';
- }
- let coinNumber = DWTool.coinParse(gold);
- this.firstText.string = `<b><color=${color}>${coinNumber}</color></b>`;
- let cardCount = 0;
- if (pack && pack.length > 0) {
- cardCount = pack[0].count;
- }
- this.secondText.string = this.stringFormat(cardInfo.name, cardCount, cardInfo.number);
- cc.loader.loadRes('./job/change_job_consume_icon', cc.SpriteFrame, (error, spriteFrame) => {
- this.iconSprite.spriteFrame = spriteFrame;
- });
- cc.loader.loadRes('./job/change_job_card', cc.SpriteFrame, (error, spriteFrame) => {
- this.secondSprite.spriteFrame = spriteFrame;
- });
- },
- bindDataLevelUp(gold, cardInfo, pack) {
- let color = '#ffffff';
- if (gold <= GameModel.userInfo.grossIncome) {
- color = '#ffffff';
- } else {
- color = '#f33e35';
- }
- let coinNumber = DWTool.coinParse(gold);
- this.firstText.string = `<b><color=${color}>${coinNumber}</color></b>`;
- let cardCount = 0;
- if (pack && pack.length > 0) {
- cardCount = pack[0].count;
- }
- this.secondText.string = this.stringFormat(cardInfo.name, cardCount, cardInfo.number);
- // cc.loader.loadRes('./job/level_up_consume_icon', cc.SpriteFrame, (error, spriteFrame) => {
- // this.iconSprite.spriteFrame = spriteFrame;
- // });
- cc.loader.loadRes('./job/level_up_card', cc.SpriteFrame, (error, spriteFrame) => {
- this.secondSprite.spriteFrame = spriteFrame;
- });
- },
- stringFormat(name, pack, consume) {
- this.button.interactable = pack >= consume;
- let color = consume > pack ? '#f33e35' : '#ffffff'
- return `<b>${name}</b><color=${color}>(${pack}/${consume})</color>`;
- },
- // update (dt) {},
- });
|