1
0

StarHandbookDesc.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. const GameModule = require("../utils/GameModule");
  2. const DWTool = require("../utils/DWTool");
  3. cc.Class({
  4. extends: cc.Component,
  5. properties: {
  6. nameLabel: cc.Label,
  7. conditionLabel: cc.Label,
  8. figure: cc.Sprite, //明星图片
  9. countLabel: cc.Label,
  10. },
  11. // LIFE-CYCLE CALLBACKS:
  12. // onLoad () {},
  13. start () {
  14. },
  15. configData(starInfo) {
  16. this.starInfo = starInfo;
  17. //获取到配置表的明星数据
  18. let imageId = 50000 + starInfo.starId;
  19. DWTool.loadResSpriteFrame(`./textures/star_stand/stand_${imageId}`)
  20. .then((spriteFrame) => {
  21. this.figure.spriteFrame = spriteFrame;
  22. }).catch((err) => {
  23. console.log(err);
  24. });
  25. let star = Global.BuildingManager.getStarInfo(starInfo.starId);
  26. this.nameLabel.string = star.name;
  27. let roomName = Global.BuildingManager.getRoomName(star.roomId);
  28. var descString = `需要 开启${roomName}`;
  29. let buyStarCount = GameModule.userInfo.buyStarCount;
  30. let needStarCount = starInfo.itemCount;
  31. if (needStarCount > 0) {
  32. descString += `\n需要 ${star.desc}`;
  33. } else {
  34. }
  35. this.conditionLabel.string = descString;
  36. this.countLabel.string = `${starInfo.starCount}个`;
  37. },
  38. // update (dt) {},
  39. });