| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- import { PastureState } from "../../game/data/GameData";
- import PastureData from "./PastureData";
- import PastureIcon from "./PastureIcon";
- /** 动物移动管理系统 */
- const { ccclass } = cc._decorator;
- @ccclass
- export default class PastureSystem {
- private pastureDataMap: Map<number, PastureData> = new Map<number, PastureData>();
- public pastureIcons: Array<PastureIcon> = [];
- setPastureData(configID) {
- if (this.getPastureData(configID)) {
- return;
- }
- let data = new PastureData();
- this.pastureDataMap.set(configID, data);
- return data;
- }
- getPastureData(configID) {
- return this.pastureDataMap.get(configID);
- }
- addPastureIcon(pasture) {
- this.pastureIcons.push(pasture);
- }
- /** 下一个空置饲养场 */
- nextPasture() {
- let len = this.pastureIcons.length;
- for (var i = 0; i < len; i++) {
- if (this.pastureIcons[i].data.state == PastureState.Empty) {
- gData.gameData.nextCanProduct = gData.gameData.getProductMap(this.pastureIcons[i].data.productID);
- gData.gameData.nextMake = this.pastureIcons[i];
- return this.pastureIcons[i];
- }
- }
- return null;
- }
- btnMake() {
- gData.gameData.nextMake.onEat();
- }
- setHarvest() {
- let len = this.pastureIcons.length;
- for (var i = 0; i < len; i++) {
- if (this.pastureIcons[i].data.state == PastureState.Growing) {
- this.pastureIcons[i].countDown.riped();
- }
- }
- }
- canSpeedUp() {
- let can = false;
- let len = this.pastureIcons.length;
- for (var i = 0; i < len; i++) {
- if (this.pastureIcons[i].data.state == PastureState.Growing) {
- can = true;
- break;
- }
- }
- return can;
- }
- }
|