123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- var DWTool = require('../utils/DWTool');
- var {UserJobType, UserInformationType} = require('../utils/GameEnum');
- cc.Class({
- extends: cc.Component,
- properties: {
- levelLabel: cc.Label, //等级
- jobRichText: cc.RichText, //职业称呼
- salaryLabel: cc.RichText, //年薪
- levelProgressBar: cc.ProgressBar, //年薪突破进度条
- propertyLabel1: cc.RichText, //魅力
- propertyLabel2: cc.RichText, //能力
- propertyLabel3: cc.RichText, //影响力
- jobSprite: cc.Sprite, //职业类型icon
- //突破转职按钮
- upgradeButton: cc.Button,
- },
- // LIFE-CYCLE CALLBACKS:
- // onLoad () {},
- start () {
- },
- init() {
- },
- // update (dt) {},
- onDisable() {
- this.levelProgressBar.progress = 0;
- this.upgradeButton.node.active = false;
- },
- setUserData(userInfo, role) {
- this.userInfo = userInfo;
- this.role = role;
- if (this.userInfo.jobLevelName != undefined) {
- this.jobRichText.string = "<outline color=#291c42 width=2><b>"+this.userInfo.jobLevelName+"</b></outline>";
- }
- this.levelLabel.string = this.userInfo.jobLevel;
- this.salaryLabel.string = "<outline color=#291c42 width=2><b>" + DWTool.coinParse(this.userInfo.salary) + "</b></outline>";
- this.propertyLabel1.string = "<b>" + this.userInfo.charm + "</b>";
- this.propertyLabel2.string = "<b>" + this.userInfo.ability + "</b>";
- this.propertyLabel3.string = "<b>" + this.userInfo.effect + "</b>";
- this.upgradeButton.node.active = true;
- if (this.role == UserInformationType.MyArtist) {
- if (this.userInfo.upgradeSalary == 0) {
- this.upgradeButton.node.active = false;
- } else if (this.userInfo.salary >= this.userInfo.upgradeSalary) {
- this.upgradeButton.node.active = true;
- } else {
- this.upgradeButton.node.active = false;
- }
- } else {
- this.upgradeButton.node.active = false;
- }
- if (this.userInfo.jobLevel == 0) {
- this.levelProgressBar.progress = 0;
- } else if (this.userInfo.upgradeSalary == 0) {
- this.levelProgressBar.progress = 1;
- } else if (this.userInfo.salary >= this.userInfo.upgradeSalary) {
- this.levelProgressBar.progress = 1;
- } else {
- this.levelProgressBar.progress = this.userInfo.salary / this.userInfo.upgradeSalary;
- }
- // this.refreshJobIcon();
- },
- refreshJobIcon() {
- this.jobSprite.node.active = true;
- switch (this.userInfo.jobId) {
- case UserJobType.None:
- this.jobSprite.node.active = false;
- break;
- case UserJobType.MC:
- cc.loader.loadRes('userInformation/userinformation_job_mc', cc.SpriteFrame, (err, spriteFrame) => {
- this.jobSprite.spriteFrame = spriteFrame;
- });
- break;
- case UserJobType.Dancer:
- cc.loader.loadRes('userInformation/userinformation_job_dancer', cc.SpriteFrame, (err, spriteFrame) => {
- this.jobSprite.spriteFrame = spriteFrame;
- });
- break;
- case UserJobType.Singer:
- cc.loader.loadRes('userInformation/userinformation_job_singer', cc.SpriteFrame, (err, spriteFrame) => {
- this.jobSprite.spriteFrame = spriteFrame;
- });
- break;
- case UserJobType.Actor:
- cc.loader.loadRes('userInformation/userinformation_job_actor', cc.SpriteFrame, (err, spriteFrame) => {
- this.jobSprite.spriteFrame = spriteFrame;
- });
- break;
- case UserJobType.Electronic:
- cc.loader.loadRes('userInformation/userinformation_job_electronic', cc.SpriteFrame, (err, spriteFrame) => {
- this.jobSprite.spriteFrame = spriteFrame;
- });
- break;
- }
- }
- });
|