UserInformationProperty.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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() {
  22. },
  23. // update (dt) {},
  24. onDisable() {
  25. this.levelProgressBar.progress = 0;
  26. this.upgradeButton.node.active = false;
  27. },
  28. setUserData(userInfo, role) {
  29. this.userInfo = userInfo;
  30. this.role = role;
  31. if (this.userInfo.jobLevelName != undefined) {
  32. this.jobRichText.string = "<outline color=white width=3><b>"+this.userInfo.jobLevelName+"</b></outline>";
  33. }
  34. this.levelLabel.string = this.userInfo.jobLevel;
  35. this.salaryLabel.string = DWTool.coinParse(this.userInfo.salary);
  36. this.propertyLabel1.string = this.userInfo.charm;
  37. this.propertyLabel2.string = this.userInfo.ability;
  38. this.propertyLabel3.string = this.userInfo.effect;
  39. this.upgradeButton.node.active = true;
  40. if (this.role == UserInformationType.MyArtist) {
  41. if (this.userInfo.upgradeSalary == 0) {
  42. this.upgradeButton.node.active = false;
  43. } else if (this.userInfo.salary >= this.userInfo.upgradeSalary) {
  44. this.upgradeButton.node.active = true;
  45. } else {
  46. this.upgradeButton.node.active = false;
  47. }
  48. } else {
  49. this.upgradeButton.node.active = false;
  50. }
  51. if (this.userInfo.jobLevel == 0) {
  52. this.levelProgressBar.progress = 0;
  53. } else if (this.userInfo.upgradeSalary == 0) {
  54. this.levelProgressBar.progress = 1;
  55. } else if (this.userInfo.salary >= this.userInfo.upgradeSalary) {
  56. this.levelProgressBar.progress = 1;
  57. } else {
  58. this.levelProgressBar.progress = this.userInfo.salary / this.userInfo.upgradeSalary;
  59. }
  60. this.refreshJobIcon();
  61. },
  62. refreshJobIcon() {
  63. this.jobSprite.node.active = true;
  64. switch (this.userInfo.jobId) {
  65. case UserJobType.None:
  66. this.jobSprite.node.active = false;
  67. break;
  68. case UserJobType.MC:
  69. cc.loader.loadRes('userInformation/userinformation_job_mc', cc.SpriteFrame, (err, spriteFrame) => {
  70. this.jobSprite.spriteFrame = spriteFrame;
  71. });
  72. break;
  73. case UserJobType.Dancer:
  74. cc.loader.loadRes('userInformation/userinformation_job_dancer', cc.SpriteFrame, (err, spriteFrame) => {
  75. this.jobSprite.spriteFrame = spriteFrame;
  76. });
  77. break;
  78. case UserJobType.Singer:
  79. cc.loader.loadRes('userInformation/userinformation_job_singer', cc.SpriteFrame, (err, spriteFrame) => {
  80. this.jobSprite.spriteFrame = spriteFrame;
  81. });
  82. break;
  83. case UserJobType.Actor:
  84. cc.loader.loadRes('userInformation/userinformation_job_actor', cc.SpriteFrame, (err, spriteFrame) => {
  85. this.jobSprite.spriteFrame = spriteFrame;
  86. });
  87. break;
  88. case UserJobType.Electronic:
  89. cc.loader.loadRes('userInformation/userinformation_job_electronic', cc.SpriteFrame, (err, spriteFrame) => {
  90. this.jobSprite.spriteFrame = spriteFrame;
  91. });
  92. break;
  93. }
  94. }
  95. });