123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- 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.Label, //年薪
- levelProgressBar: cc.ProgressBar, //年薪突破进度条
- propertyLabel1: cc.Label, //魅力
- propertyLabel2: cc.Label, //能力
- propertyLabel3: cc.Label, //影响力
- jobSprite: cc.Sprite, //职业类型icon
- //突破转职按钮
- upgradeButton: cc.Button,
- },
- // LIFE-CYCLE CALLBACKS:
- // onLoad () {},
- start () {
- },
- init(information) {
- this.information = information;
- },
- // update (dt) {},
- setUserData(userInfo, role) {
- this.userInfo = userInfo;
- this.role = role;
- if (this.userInfo.jobLevelName != undefined) {
- this.jobRichText.string = "<outline color=white width=3><b>"+this.userInfo.jobLevelName+"</b></outline>";
- }
- this.levelLabel.string = this.userInfo.jobLevel;
- this.salaryLabel.string = DWTool.coinParse(this.userInfo.salary);
- this.propertyLabel1.string = this.userInfo.charm;
- this.propertyLabel2.string = this.userInfo.ability;
- this.propertyLabel3.string = this.userInfo.effect;
- 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;
- }
- }
- });
|