using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; class Farm { private Crops[,] crops; private Random r; private CropTypesHolder PresetCrops = new CropTypesHolder(); //initializes the crops public void init(Vector2 Size, Vector2 housepos) { PresetCrops.init(); r = new Random(); crops = new Crops[100, 100]; for (int i = 0; i < Size.X; i++) { for (int j = 0; j < Size.Y; j++) { int x = r.Next(0, 3); if (x == 0) { x = r.Next(0, 2); } if (x == 2) { x = r.Next(1, 3); } crops[i, j] = new Crops(); crops[i, j].setStatus(x); crops[i, j].setOriginalStatus(); crops[i, j].setCropType(x = r.Next(0, 4)); crops[i, j].init(); } } } public void updateFarm(Vector2 Size) { for (int i = 0; i < Size.X; i++) { for (int j = 0; j < Size.Y; j++) { crops[i, j].updateCrop(Size); } } } //Changes the properties of the tile when the tractor reaches this tile. public void setCropStatus(float xfloat, float yfloat) { int x = (int)xfloat; int y = (int)yfloat; if (crops[x, y].getStatus() >= 4) { crops[x, y].setStatus(2); } else if(crops[x, y].getStatus() == 0) { //do nothing } else if (crops[x, y].getStatus() == 2) { crops[x, y].setStatus(3); } else if (crops[x, y].getStatus() == 3) { crops[x, y].setStatus(4); crops[x, y].setCropTimer(); } } public Crops getCrop(int x, int y) { return crops[x,y]; } public Crops[,] getCrops() { return crops; } public void setNewHousePos(Vector2 pos, bool newState) { crops[(int)pos.X, (int)pos.Y].setHousePos(newState); } public CropTypes getPresetCropTypes(int Index) { return PresetCrops.getPresetCropTypes(Index); } }