PotatoPlan/Game1/Sources/Crops/SoilProperties.cs

68 lines
1.8 KiB
C#
Raw Normal View History

2020-05-06 16:22:30 +02:00
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";
2020-05-07 01:55:52 +02:00
public float Temperature;
2020-05-06 16:22:30 +02:00
public float Humidity;
public float Moisture;
public float Nitrogen;
public float Potassium;
public float Phosphorous;
2020-05-23 20:37:11 +02:00
public float Rainfall;
public float prevRainfall;
2020-05-09 15:54:53 +02:00
public float NitrogenDegradeRate = 1.0f - (1.0f/55 * 40);
public float PotassiumDegradeRate = 1.0f - (1.0f/28 * 23);
public float PhosphorousDegradeRate = 1.0f - (1.0f/60 * 37);
2020-05-10 12:55:13 +02:00
public int Capacity = 80;
2020-05-24 21:00:24 +02:00
public int Area;
2020-05-06 16:22:30 +02:00
public void setSoilProperties()
{
2020-05-06 22:37:04 +02:00
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";
}
2020-05-07 01:55:52 +02:00
Temperature = GetRandomNumber(22, 30);
2020-05-11 01:11:00 +02:00
Humidity = Temperature * GetRandomNumber(1.9f, 2.1f);
2020-05-06 22:37:04 +02:00
Moisture = GetRandomNumber(20, 70);
2020-05-10 12:55:13 +02:00
Nitrogen = GetRandomNumber(4 , 42); //was 4, 60
Potassium = GetRandomNumber(0.01f, 19); // was 0, 28
Phosphorous = GetRandomNumber(0.01f, 42); // was 0, 60
2020-05-23 20:37:11 +02:00
prevRainfall = r.Next(247, 3617);
2020-05-24 21:00:24 +02:00
Area = r.Next(1, 270000);
2020-05-06 16:22:30 +02:00
}
public float GetRandomNumber(double minimum, double maximum)
{
return (float)(Math.Round(r.NextDouble() * (maximum - minimum) + minimum, 2));
}
}