| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- /** 工厂数据类 */
- import { FactroyState } from "../../game/data/GameData";
- import { FactoryIcon } from "./FactoryIcon";
- const { ccclass } = cc._decorator;
- @ccclass
- export default class FactorySystem {
- private _currSelectFactory: FactoryIcon = null;
- public factoryIcons: Array<FactoryIcon> = [];
- public set currSelectFactory(factory: FactoryIcon) {
- this._currSelectFactory = factory;
- }
- public get currSelectFactory(): FactoryIcon {
- return this._currSelectFactory;
- }
- public make(id: number): void {
- this._currSelectFactory && this._currSelectFactory.make(id);
- }
- public addFactory(factory) {
- this.factoryIcons.push(factory);
- }
- public nextFactory() {
- let len = this.factoryIcons.length;
- for (var i = 0; i < len; i++) {
- if (this.factoryIcons[i].data.state == FactroyState.Empty) {
- gData.gameData.nextCanProduct = gData.gameData.getRandomFactoryConfig(this.factoryIcons[i].configID);
- gData.gameData.nextMake = this.factoryIcons[i];
- return this.factoryIcons[i];
- }
- }
- }
- public btnMake() {
- gData.gameData.nextMake.make(gData.gameData.nextCanProduct.picture);
- }
- setHarvest() {
- let len = this.factoryIcons.length;
- for (var i = 0; i < len; i++) {
- if (this.factoryIcons[i].data.state == FactroyState.Producting) {
- this.factoryIcons[i].countDown.riped();
- }
- }
- }
- canSpeedUp() {
- let can = false;
- let len = this.factoryIcons.length;
- for (var i = 0; i < len; i++) {
- if (this.factoryIcons[i].data.state == FactroyState.Producting) {
- can = true;
- break;
- }
- }
- return can;
- }
- }
|