| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- 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();
- }
- }
- }
- }
|