diff --git a/Game1/Sources/Crops/CropType.cs b/Game1/Sources/Crops/CropType.cs index 07faf17..d796274 100644 --- a/Game1/Sources/Crops/CropType.cs +++ b/Game1/Sources/Crops/CropType.cs @@ -8,13 +8,24 @@ using System.Threading.Tasks; class CropTypes { - public string[] soilType; - public int[] Times; + + public string[] soilType = new string[3]; + public int[] Times = new int[3]; public float Temparature; public float Humidity; public float Moisture; public float Nitrogen; public float Potassium; public float Phosphorous; + + + public CropTypes() + { + soilType = new string[3]; + Times = new int[3]; + } } + + + diff --git a/Game1/Sources/Crops/CropTypesHolder.cs b/Game1/Sources/Crops/CropTypesHolder.cs index 4419ea0..1b09922 100644 --- a/Game1/Sources/Crops/CropTypesHolder.cs +++ b/Game1/Sources/Crops/CropTypesHolder.cs @@ -12,6 +12,7 @@ class CropTypesHolder public void init() { // Barley + cropTypes[0] = new CropTypes(); cropTypes[0].soilType[0] = "Sandy"; cropTypes[0].soilType[1] = null; cropTypes[0].soilType[2] = null; @@ -24,6 +25,7 @@ class CropTypesHolder // Cotton + cropTypes[1] = new CropTypes(); cropTypes[1].soilType[0] = "Red"; cropTypes[1].Times[0] = 5; cropTypes[1].soilType[1] = "Black"; @@ -38,6 +40,7 @@ class CropTypesHolder cropTypes[1].Phosphorous = 23.8f; // Ground Nuts + cropTypes[2] = new CropTypes(); cropTypes[2].soilType[0] = "Red"; cropTypes[2].soilType[1] = null; cropTypes[2].soilType[2] = null; @@ -50,6 +53,7 @@ class CropTypesHolder // Maize + cropTypes[3] = new CropTypes(); cropTypes[3].soilType[0] = "Sandy"; cropTypes[3].soilType[1] = null; cropTypes[3].soilType[2] = null; @@ -61,6 +65,7 @@ class CropTypesHolder cropTypes[3].Phosphorous = 18.7f; // Millets + cropTypes[4] = new CropTypes(); cropTypes[4].soilType[0] = "Sandy"; cropTypes[4].Times[0] = 7; cropTypes[4].soilType[1] = "Black"; @@ -74,6 +79,7 @@ class CropTypesHolder cropTypes[4].Phosphorous = 14.4f; //Oil Seeds + cropTypes[5] = new CropTypes(); cropTypes[5].soilType[0] = "Black"; cropTypes[5].soilType[1] = null; cropTypes[5].soilType[2] = null; @@ -85,6 +91,7 @@ class CropTypesHolder cropTypes[5].Phosphorous = 17.3f; //Paddys + cropTypes[6] = new CropTypes(); cropTypes[6].soilType[0] = "Clayey"; cropTypes[6].soilType[1] = null; cropTypes[6].soilType[2] = null; @@ -96,6 +103,7 @@ class CropTypesHolder cropTypes[6].Phosphorous = 16.3f; //Pulses + cropTypes[7] = new CropTypes(); cropTypes[7].soilType[0] = "Clayey"; cropTypes[7].soilType[1] = null; cropTypes[7].soilType[2] = null; @@ -107,6 +115,7 @@ class CropTypesHolder cropTypes[7].Phosphorous = 17.5f; //Sugarcane + cropTypes[8] = new CropTypes(); cropTypes[8].soilType[0] = "Loamy"; cropTypes[8].Times[0] = 9; cropTypes[8].soilType[1] = "Black"; @@ -121,6 +130,7 @@ class CropTypesHolder //Tobacco + cropTypes[9] = new CropTypes(); cropTypes[9].soilType[0] = "Red"; cropTypes[9].soilType[1] = null; cropTypes[9].soilType[2] = null; @@ -133,6 +143,7 @@ class CropTypesHolder //Wheat + cropTypes[10] = new CropTypes(); cropTypes[10].soilType[0] = "Loamy"; cropTypes[10].soilType[1] = null; cropTypes[10].soilType[2] = null; @@ -144,4 +155,9 @@ class CropTypesHolder cropTypes[10].Phosphorous = 14.4f; } + + public CropTypes getPresetCropTypes(int Index) + { + return cropTypes[Index]; + } } diff --git a/Game1/Sources/Crops/Farm.cs b/Game1/Sources/Crops/Farm.cs index f31b32e..ed4b416 100644 --- a/Game1/Sources/Crops/Farm.cs +++ b/Game1/Sources/Crops/Farm.cs @@ -10,12 +10,13 @@ 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++) @@ -86,22 +87,13 @@ class Farm return crops; } - public void updateSize(Vector2 Size, int tileSize, int Spacing) - { - - for (int i = 0; i < (int)Size.X; i++) - { - for (int j = 0; j < (int)Size.Y; j++) - { - //crops[i, j].x = (tileSize + Spacing) * i; - //crops[i, j].y = (tileSize + Spacing) * j; - } - } - } - 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); + } } diff --git a/Game1/Sources/Crops/SoilProperties.cs b/Game1/Sources/Crops/SoilProperties.cs index b7c534a..160481f 100644 --- a/Game1/Sources/Crops/SoilProperties.cs +++ b/Game1/Sources/Crops/SoilProperties.cs @@ -20,8 +20,29 @@ class SoilProperties public void setSoilProperties() { - Temperature = GetRandomNumber(22, 30); - Humidity = Temperature * GetRandomNumber(1.9, 2.1); + int soilTypeRandomizer = r.Next(0, 1000); + if (soilTypeRandomizer < 210) + { + soilType = "Loamy"; + } + else if (soilTypeRandomizer < 400) + { + soilType = "Red"; + } + else if (soilTypeRandomizer < 600) + { + soilType = "Black"; + } + else if (soilTypeRandomizer < 800) + { + soilType = "Sandy"; + } + else + { + soilType = "Clayey"; + } + Temparature = GetRandomNumber(22, 30); + Humidity = Temparature * 2 + GetRandomNumber(1.9, 2.2); Moisture = GetRandomNumber(20, 70); Nitrogen = GetRandomNumber(4 , 55); Potassium = GetRandomNumber(0, 28); diff --git a/Game1/Sources/Objects/House.cs b/Game1/Sources/Objects/House.cs index 48297da..94a8801 100644 --- a/Game1/Sources/Objects/House.cs +++ b/Game1/Sources/Objects/House.cs @@ -37,7 +37,7 @@ class House housePos = new Rectangle((int)pos.X * (tileSize + Spacing), (int)pos.Y * (tileSize + Spacing), tileSize, tileSize); } - + //Returns house Rectangle public Rectangle GetRectangle() { return housePos;