UserInformationProperty.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. jobLevelSprite: cc.Sprite, //职业等级对应图片
  8. jobRichText: cc.RichText, //职业称呼
  9. salaryLabel: cc.RichText, //年薪
  10. levelProgressBar: cc.ProgressBar, //年薪突破进度条
  11. propertyLabel1: cc.RichText, //魅力
  12. propertyLabel2: cc.RichText, //能力
  13. propertyLabel3: cc.RichText, //影响力
  14. jobSprite: cc.Sprite, //职业类型icon
  15. //突破转职按钮
  16. upgradeButton: cc.Button,
  17. },
  18. // LIFE-CYCLE CALLBACKS:
  19. // onLoad () {},
  20. start () {
  21. },
  22. init() {
  23. },
  24. // update (dt) {},
  25. onDisable() {
  26. this.levelProgressBar.progress = 0;
  27. this.upgradeButton.node.active = false;
  28. this.jobLevelSprite.node.active = false;
  29. },
  30. setUserData(userInfo, role) {
  31. this.userInfo = userInfo;
  32. this.role = role;
  33. if (this.userInfo.jobLevelName != undefined) {
  34. this.jobRichText.string = "<outline color=#291c42 width=2><b>"+this.userInfo.jobLevelName+"</b></outline>";
  35. }
  36. this.salaryLabel.string = "<outline color=#291c42 width=2><b>" + DWTool.coinParse(this.userInfo.salary) + "</b></outline>";
  37. this.propertyLabel1.string = "<b>" + this.userInfo.charm + "</b>";
  38. this.propertyLabel2.string = "<b>" + this.userInfo.ability + "</b>";
  39. this.propertyLabel3.string = "<b>" + this.userInfo.effect + "</b>";
  40. this.upgradeButton.node.active = true;
  41. if (this.role == UserInformationType.MyArtist) {
  42. if (this.userInfo.upgradeSalary == 0) {
  43. this.upgradeButton.node.active = false;
  44. } else if (this.userInfo.salary >= this.userInfo.upgradeSalary) {
  45. this.upgradeButton.node.active = true;
  46. } else {
  47. this.upgradeButton.node.active = false;
  48. }
  49. } else {
  50. this.upgradeButton.node.active = false;
  51. }
  52. if (this.userInfo.jobLevel == 0) {
  53. this.levelProgressBar.progress = 0;
  54. } else if (this.userInfo.upgradeSalary == 0) {
  55. this.levelProgressBar.progress = 1;
  56. } else if (this.userInfo.salary >= this.userInfo.upgradeSalary) {
  57. this.levelProgressBar.progress = 1;
  58. } else {
  59. this.levelProgressBar.progress = this.userInfo.salary / this.userInfo.upgradeSalary;
  60. }
  61. if (this.userInfo.jobLevel == 0) {
  62. this.jobLevelSprite.node.active = false;
  63. } else {
  64. let jobLevel = `jobLevel/job_level_${this.userInfo.jobLevel}`;
  65. cc.loader.loadRes(jobLevel, cc.SpriteFrame, (err, spriteFrame) => {
  66. if (err) {
  67. this.jobLevelSprite.node.active = false;
  68. } else {
  69. this.jobLevelSprite.node.active = true;
  70. this.jobLevelSprite.spriteFrame = spriteFrame;
  71. }
  72. });
  73. }
  74. // this.refreshJobIcon();
  75. },
  76. refreshJobIcon() {
  77. this.jobSprite.node.active = true;
  78. switch (this.userInfo.jobId) {
  79. case UserJobType.None:
  80. this.jobSprite.node.active = false;
  81. break;
  82. case UserJobType.MC:
  83. cc.loader.loadRes('userInformation/userinformation_job_mc', cc.SpriteFrame, (err, spriteFrame) => {
  84. this.jobSprite.spriteFrame = spriteFrame;
  85. });
  86. break;
  87. case UserJobType.Dancer:
  88. cc.loader.loadRes('userInformation/userinformation_job_dancer', cc.SpriteFrame, (err, spriteFrame) => {
  89. this.jobSprite.spriteFrame = spriteFrame;
  90. });
  91. break;
  92. case UserJobType.Singer:
  93. cc.loader.loadRes('userInformation/userinformation_job_singer', cc.SpriteFrame, (err, spriteFrame) => {
  94. this.jobSprite.spriteFrame = spriteFrame;
  95. });
  96. break;
  97. case UserJobType.Actor:
  98. cc.loader.loadRes('userInformation/userinformation_job_actor', cc.SpriteFrame, (err, spriteFrame) => {
  99. this.jobSprite.spriteFrame = spriteFrame;
  100. });
  101. break;
  102. case UserJobType.Electronic:
  103. cc.loader.loadRes('userInformation/userinformation_job_electronic', cc.SpriteFrame, (err, spriteFrame) => {
  104. this.jobSprite.spriteFrame = spriteFrame;
  105. });
  106. break;
  107. }
  108. }
  109. });