PotatoPlan/Game1/Sources/Crops/SoilProperties.cs
2020-06-15 00:59:39 +02:00

68 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class SoilProperties
{
static Random r = new Random();
public string soilType = "potato";
public float Temperature;
public float Humidity;
public float Moisture;
public float Nitrogen;
public float Potassium;
public float Phosphorous;
public float Rainfall;
public float prevRainfall;
public float NitrogenDegradeRate = 0.8f;
public float PotassiumDegradeRate = 0.3f;
public float PhosphorousDegradeRate = 0.6f;
public int Capacity = 80;
public int Area;
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";
}
Temperature = GetRandomNumber(22, 30);
Humidity = Temperature * GetRandomNumber(1.9f, 2.1f);
Moisture = GetRandomNumber(20, 70);
Nitrogen = GetRandomNumber(4 , 42); //was 4, 60
Potassium = GetRandomNumber(0.01f, 19); // was 0, 28
Phosphorous = GetRandomNumber(0.01f, 42); // was 0, 60
prevRainfall = r.Next(247, 3617);
Area = r.Next(1, 270000);
}
public float GetRandomNumber(double minimum, double maximum)
{
return (float)(Math.Round(r.NextDouble() * (maximum - minimum) + minimum, 2));
}
}