import { _decorator, Component, Label, JsonAsset } from 'cc'; import { ResourcesUtils } from '../../core/resourceManager/ResourcesUtils'; import { Sound } from '../../core/sound/Sound'; import { ConfigData } from '../../Data/ConfigData'; import { g } from '../../Data/g'; import { FactoryWindow } from './FactoryWindow'; const { ccclass, property } = _decorator; @ccclass('FactroyMaker') export class FactroyMaker extends Component { @property({ type: Label, tooltip: "时间描述" }) timeLabel: Label; @property({ type: Label, tooltip: "次数描述" }) countLabel: Label; public countData: any; private productID: number; private window: FactoryWindow; private count = 0; public async setData(data: number, window: FactoryWindow) { this.productID = data; this.window = window; let config = ConfigData.configMap.get("product")[this.productID]; this.timeLabel.string = "制作需要的时长:" + config["time"] / 60 + "分钟"; this.count = config["reap"] - (this.countData ? (this.countData[this.productID] ? this.countData[this.productID] : 0) : 0); this.countLabel.string = "剩余次数:" + this.count + "次"; } public onMakeButton(): void { if (this.count > 0 && g.gameData.getProductingList(this.window.buildID).length < g.gameData.getUnlock(this.window.buildID)) { this.count--; this.countLabel.string = "剩余次数:" + this.count + "次"; this.window.make(this.productID); this.getComponent(Sound).play(); } } }