LevelUp.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. const ArtistManager = require('../utils/ArtistManager');
  2. const DWTool = require('../utils/DWTool');
  3. cc.Class({
  4. extends: cc.Component,
  5. properties: {
  6. levelBgBefor: cc.Sprite,
  7. levelBgAfter: cc.Sprite,
  8. levelBefor: cc.RichText,
  9. levelAfter: cc.RichText,
  10. nameBefor: cc.RichText,
  11. nameAfter: cc.RichText,
  12. role: sp.Skeleton,
  13. salaryLabel: cc.Label,
  14. progressbar: cc.ProgressBar,
  15. blessings: cc.RichText,
  16. levelSpriteFrame: [cc.SpriteFrame],
  17. },
  18. bind(userInfo, upgradeInfo, wish) {
  19. this.levelBgBefor.spriteFrame = this.levelSpriteFrame[userInfo.jobLevel - 1];
  20. this.levelBgAfter.spriteFrame = this.levelSpriteFrame[userInfo.jobLevel];
  21. // this.levelBefor.string = this.numberString(userInfo.jobLevel);
  22. this.nameBefor.string = this.nameString(userInfo.jobLevelName);
  23. // this.levelAfter.string = this.numberString(upgradeInfo.level);
  24. this.nameAfter.string = this.nameString(upgradeInfo.name);
  25. this.salaryLabel.string = DWTool.coinParse(userInfo.salary);
  26. this.blessings.string = this.nameString('祝福值:' + wish);
  27. this.progressbar.progress = wish * this.progressbar.totalLength / 100;
  28. //现在只有舞者有骨骼动画,默认jodId为2
  29. ArtistManager.loadArtist(true, userInfo.gender, userInfo.jobId)
  30. .then((skeletonData) => {
  31. this.role.skeletonData = skeletonData;
  32. this.role.animation = "stand";
  33. }).catch((err) => {
  34. console.log(err);
  35. });
  36. },
  37. numberString(level) {
  38. return '<outline color=#000000 width=1><b>' + level + '</b></outline>'
  39. },
  40. nameString(name) {
  41. return '<outline color=#000000 width=1><b>' + name + '</b></outline>'
  42. },
  43. });