UserInformationProperty.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. var DWTool = require('../utils/DWTool');
  2. var {UserJobType, UserInformationType} = require('../utils/GameEnum');
  3. cc.Class({
  4. extends: cc.Component,
  5. properties: {
  6. levelLabel: cc.Label, //等级
  7. jobRichText: cc.RichText, //职业称呼
  8. salaryLabel: cc.Label, //年薪
  9. levelProgressBar: cc.ProgressBar, //年薪突破进度条
  10. propertyLabel1: cc.Label, //魅力
  11. propertyLabel2: cc.Label, //能力
  12. propertyLabel3: cc.Label, //影响力
  13. jobSprite: cc.Sprite, //职业类型icon
  14. //突破转职按钮
  15. upgradeButton: cc.Button,
  16. },
  17. // LIFE-CYCLE CALLBACKS:
  18. // onLoad () {},
  19. start () {
  20. },
  21. init(information) {
  22. this.information = information;
  23. },
  24. // update (dt) {},
  25. setUserData(userInfo, role) {
  26. this.userInfo = userInfo;
  27. this.role = role;
  28. if (this.userInfo.jobLevelName != undefined) {
  29. this.jobRichText.string = "<outline color=white width=3><b>"+this.userInfo.jobLevelName+"</b></outline>";
  30. }
  31. this.levelLabel.string = this.userInfo.jobLevel;
  32. this.salaryLabel.string = DWTool.coinParse(this.userInfo.salary);
  33. this.propertyLabel1.string = this.userInfo.charm;
  34. this.propertyLabel2.string = this.userInfo.ability;
  35. this.propertyLabel3.string = this.userInfo.effect;
  36. if (this.role == UserInformationType.MyArtist) {
  37. if (this.userInfo.upgradeSalary == 0) {
  38. this.upgradeButton.node.active = false;
  39. } else if (this.userInfo.salary >= this.userInfo.upgradeSalary) {
  40. this.upgradeButton.node.active = true;
  41. } else {
  42. this.upgradeButton.node.active = false;
  43. }
  44. } else {
  45. this.upgradeButton.node.active = false;
  46. }
  47. if (this.userInfo.jobLevel == 0) {
  48. this.levelProgressBar.progress = 0;
  49. } else if (this.userInfo.upgradeSalary == 0) {
  50. this.levelProgressBar.progress = 1;
  51. } else if (this.userInfo.salary >= this.userInfo.upgradeSalary) {
  52. this.levelProgressBar.progress = 1;
  53. } else {
  54. this.levelProgressBar.progress = this.userInfo.salary / this.userInfo.upgradeSalary;
  55. }
  56. this.refreshJobIcon();
  57. },
  58. refreshJobIcon() {
  59. this.jobSprite.node.active = true;
  60. switch (this.userInfo.jobId) {
  61. case UserJobType.None:
  62. this.jobSprite.node.active = false;
  63. break;
  64. case UserJobType.MC:
  65. cc.loader.loadRes('userInformation/userinformation_job_mc', cc.SpriteFrame, (err, spriteFrame) => {
  66. this.jobSprite.spriteFrame = spriteFrame;
  67. });
  68. break;
  69. case UserJobType.Dancer:
  70. cc.loader.loadRes('userInformation/userinformation_job_dancer', cc.SpriteFrame, (err, spriteFrame) => {
  71. this.jobSprite.spriteFrame = spriteFrame;
  72. });
  73. break;
  74. case UserJobType.Singer:
  75. cc.loader.loadRes('userInformation/userinformation_job_singer', cc.SpriteFrame, (err, spriteFrame) => {
  76. this.jobSprite.spriteFrame = spriteFrame;
  77. });
  78. break;
  79. case UserJobType.Actor:
  80. cc.loader.loadRes('userInformation/userinformation_job_actor', cc.SpriteFrame, (err, spriteFrame) => {
  81. this.jobSprite.spriteFrame = spriteFrame;
  82. });
  83. break;
  84. case UserJobType.Electronic:
  85. cc.loader.loadRes('userInformation/userinformation_job_electronic', cc.SpriteFrame, (err, spriteFrame) => {
  86. this.jobSprite.spriteFrame = spriteFrame;
  87. });
  88. break;
  89. }
  90. }
  91. });