const GameModule = require("../utils/GameModule"); const DWTool = require("../utils/DWTool"); cc.Class({ extends: cc.Component, properties: { nameLabel: cc.Label, conditionLabel: cc.Label, figure: cc.Sprite, //明星图片 countLabel: cc.Label, }, // LIFE-CYCLE CALLBACKS: // onLoad () {}, start () { }, configData(starInfo) { this.starInfo = starInfo; //获取到配置表的明星数据 let imageId = 50000 + starInfo.starId; DWTool.loadResSpriteFrame(`./textures/star_stand/stand_${imageId}`) .then((spriteFrame) => { this.figure.spriteFrame = spriteFrame; }).catch((err) => { console.log(err); }); let star = Global.BuildingManager.getStarInfo(starInfo.starId); this.nameLabel.string = star.name; let roomName = Global.BuildingManager.getRoomName(star.roomId); var descString = `需要 开启${roomName}`; let buyStarCount = GameModule.userInfo.buyStarCount; let needStarCount = starInfo.itemCount; if (needStarCount > 0) { descString += `\n需要 ${star.desc}`; } else { } this.conditionLabel.string = descString; this.countLabel.string = `${starInfo.starCount}个`; }, // update (dt) {}, });