This commit is contained in:
Joel 2020-05-06 22:37:04 +02:00
parent e14d4c3602
commit a439485bf2
4 changed files with 61 additions and 21 deletions

View File

@ -8,13 +8,24 @@ using System.Threading.Tasks;
class CropTypes 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 Temparature;
public float Humidity; public float Humidity;
public float Moisture; public float Moisture;
public float Nitrogen; public float Nitrogen;
public float Potassium; public float Potassium;
public float Phosphorous; public float Phosphorous;
public CropTypes()
{
soilType = new string[3];
Times = new int[3];
}
} }

View File

@ -12,6 +12,7 @@ class CropTypesHolder
public void init() public void init()
{ {
// Barley // Barley
cropTypes[0] = new CropTypes();
cropTypes[0].soilType[0] = "Sandy"; cropTypes[0].soilType[0] = "Sandy";
cropTypes[0].soilType[1] = null; cropTypes[0].soilType[1] = null;
cropTypes[0].soilType[2] = null; cropTypes[0].soilType[2] = null;
@ -24,6 +25,7 @@ class CropTypesHolder
// Cotton // Cotton
cropTypes[1] = new CropTypes();
cropTypes[1].soilType[0] = "Red"; cropTypes[1].soilType[0] = "Red";
cropTypes[1].Times[0] = 5; cropTypes[1].Times[0] = 5;
cropTypes[1].soilType[1] = "Black"; cropTypes[1].soilType[1] = "Black";
@ -38,6 +40,7 @@ class CropTypesHolder
cropTypes[1].Phosphorous = 23.8f; cropTypes[1].Phosphorous = 23.8f;
// Ground Nuts // Ground Nuts
cropTypes[2] = new CropTypes();
cropTypes[2].soilType[0] = "Red"; cropTypes[2].soilType[0] = "Red";
cropTypes[2].soilType[1] = null; cropTypes[2].soilType[1] = null;
cropTypes[2].soilType[2] = null; cropTypes[2].soilType[2] = null;
@ -50,6 +53,7 @@ class CropTypesHolder
// Maize // Maize
cropTypes[3] = new CropTypes();
cropTypes[3].soilType[0] = "Sandy"; cropTypes[3].soilType[0] = "Sandy";
cropTypes[3].soilType[1] = null; cropTypes[3].soilType[1] = null;
cropTypes[3].soilType[2] = null; cropTypes[3].soilType[2] = null;
@ -61,6 +65,7 @@ class CropTypesHolder
cropTypes[3].Phosphorous = 18.7f; cropTypes[3].Phosphorous = 18.7f;
// Millets // Millets
cropTypes[4] = new CropTypes();
cropTypes[4].soilType[0] = "Sandy"; cropTypes[4].soilType[0] = "Sandy";
cropTypes[4].Times[0] = 7; cropTypes[4].Times[0] = 7;
cropTypes[4].soilType[1] = "Black"; cropTypes[4].soilType[1] = "Black";
@ -74,6 +79,7 @@ class CropTypesHolder
cropTypes[4].Phosphorous = 14.4f; cropTypes[4].Phosphorous = 14.4f;
//Oil Seeds //Oil Seeds
cropTypes[5] = new CropTypes();
cropTypes[5].soilType[0] = "Black"; cropTypes[5].soilType[0] = "Black";
cropTypes[5].soilType[1] = null; cropTypes[5].soilType[1] = null;
cropTypes[5].soilType[2] = null; cropTypes[5].soilType[2] = null;
@ -85,6 +91,7 @@ class CropTypesHolder
cropTypes[5].Phosphorous = 17.3f; cropTypes[5].Phosphorous = 17.3f;
//Paddys //Paddys
cropTypes[6] = new CropTypes();
cropTypes[6].soilType[0] = "Clayey"; cropTypes[6].soilType[0] = "Clayey";
cropTypes[6].soilType[1] = null; cropTypes[6].soilType[1] = null;
cropTypes[6].soilType[2] = null; cropTypes[6].soilType[2] = null;
@ -96,6 +103,7 @@ class CropTypesHolder
cropTypes[6].Phosphorous = 16.3f; cropTypes[6].Phosphorous = 16.3f;
//Pulses //Pulses
cropTypes[7] = new CropTypes();
cropTypes[7].soilType[0] = "Clayey"; cropTypes[7].soilType[0] = "Clayey";
cropTypes[7].soilType[1] = null; cropTypes[7].soilType[1] = null;
cropTypes[7].soilType[2] = null; cropTypes[7].soilType[2] = null;
@ -107,6 +115,7 @@ class CropTypesHolder
cropTypes[7].Phosphorous = 17.5f; cropTypes[7].Phosphorous = 17.5f;
//Sugarcane //Sugarcane
cropTypes[8] = new CropTypes();
cropTypes[8].soilType[0] = "Loamy"; cropTypes[8].soilType[0] = "Loamy";
cropTypes[8].Times[0] = 9; cropTypes[8].Times[0] = 9;
cropTypes[8].soilType[1] = "Black"; cropTypes[8].soilType[1] = "Black";
@ -121,6 +130,7 @@ class CropTypesHolder
//Tobacco //Tobacco
cropTypes[9] = new CropTypes();
cropTypes[9].soilType[0] = "Red"; cropTypes[9].soilType[0] = "Red";
cropTypes[9].soilType[1] = null; cropTypes[9].soilType[1] = null;
cropTypes[9].soilType[2] = null; cropTypes[9].soilType[2] = null;
@ -133,6 +143,7 @@ class CropTypesHolder
//Wheat //Wheat
cropTypes[10] = new CropTypes();
cropTypes[10].soilType[0] = "Loamy"; cropTypes[10].soilType[0] = "Loamy";
cropTypes[10].soilType[1] = null; cropTypes[10].soilType[1] = null;
cropTypes[10].soilType[2] = null; cropTypes[10].soilType[2] = null;
@ -144,4 +155,9 @@ class CropTypesHolder
cropTypes[10].Phosphorous = 14.4f; cropTypes[10].Phosphorous = 14.4f;
} }
public CropTypes getPresetCropTypes(int Index)
{
return cropTypes[Index];
}
} }

View File

@ -10,12 +10,13 @@ class Farm
{ {
private Crops[,] crops; private Crops[,] crops;
private Random r; private Random r;
private CropTypesHolder PresetCrops = new CropTypesHolder();
//initializes the crops //initializes the crops
public void init(Vector2 Size, Vector2 housepos) public void init(Vector2 Size, Vector2 housepos)
{ {
PresetCrops.init();
r = new Random(); r = new Random();
crops = new Crops[100, 100]; crops = new Crops[100, 100];
for (int i = 0; i < Size.X; i++) for (int i = 0; i < Size.X; i++)
@ -86,22 +87,13 @@ class Farm
return crops; 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) public void setNewHousePos(Vector2 pos, bool newState)
{ {
crops[(int)pos.X, (int)pos.Y].setHousePos(newState); crops[(int)pos.X, (int)pos.Y].setHousePos(newState);
} }
public CropTypes getPresetCropTypes(int Index)
{
return PresetCrops.getPresetCropTypes(Index);
}
} }

View File

@ -20,12 +20,33 @@ class SoilProperties
public void setSoilProperties() public void setSoilProperties()
{ {
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); Temparature = GetRandomNumber(22, 30);
Humidity = GetRandomNumber(1, 5); Humidity = Temparature * 2 + GetRandomNumber(1.9, 2.2);
Moisture = GetRandomNumber(1, 10); Moisture = GetRandomNumber(20, 70);
Nitrogen = GetRandomNumber(0.5 , 1); Nitrogen = GetRandomNumber(4 , 55);
Potassium = GetRandomNumber(5, 20); Potassium = GetRandomNumber(0, 28);
Phosphorous = GetRandomNumber(4, 50); Phosphorous = GetRandomNumber(0, 60);
} }
public float GetRandomNumber(double minimum, double maximum) public float GetRandomNumber(double minimum, double maximum)