Production System fixed
This commit is contained in:
parent
da7a7822d4
commit
095ccc0fc6
@ -75,7 +75,7 @@ class CropTypesHolder
|
||||
cropTypes[4].Humidity = 57.3f;
|
||||
cropTypes[4].Moisture = 38.5f;
|
||||
cropTypes[4].Nitrogen = 23.2f;
|
||||
cropTypes[4].Potassium = 0;
|
||||
cropTypes[4].Potassium = 0.1f;
|
||||
cropTypes[4].Phosphorous = 14.4f;
|
||||
|
||||
//Oil Seeds
|
||||
|
@ -12,21 +12,23 @@ class Crops
|
||||
private int Status;
|
||||
private int originalStatus;
|
||||
private int cropType = 0;
|
||||
private int Timer = 1;
|
||||
private float Timer = 1;
|
||||
private int UpdateCrop;
|
||||
private int fullTimer;
|
||||
private float fullTimer;
|
||||
private bool housePos = false;
|
||||
private Vector2 Size;
|
||||
private CropTypes DataSet;
|
||||
SoilProperties soilProperties = new SoilProperties();
|
||||
private float ProductionRate = 0;
|
||||
|
||||
|
||||
|
||||
public void updateCrop(Vector2 newSize)
|
||||
{
|
||||
getProductionRate();
|
||||
if (Status == 3 && Timer != 1)
|
||||
{
|
||||
Timer--;
|
||||
Timer = Timer - 1 * ProductionRate;
|
||||
}
|
||||
Size = newSize;
|
||||
UpdateCrop++;
|
||||
@ -35,6 +37,10 @@ class Crops
|
||||
degradeSoil();
|
||||
UpdateCrop = 0;
|
||||
}
|
||||
if (Timer < 1)
|
||||
{
|
||||
Timer = 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -43,7 +49,7 @@ class Crops
|
||||
return soilProperties;
|
||||
}
|
||||
|
||||
public int getCropTimer()
|
||||
public float getCropTimer()
|
||||
{
|
||||
return Timer;
|
||||
}
|
||||
@ -187,38 +193,33 @@ class Crops
|
||||
return housePos;
|
||||
}
|
||||
|
||||
public float getProductionRate()
|
||||
public void getProductionRate()
|
||||
{
|
||||
ProductionRate = 1;
|
||||
if (DataSet != null)
|
||||
{
|
||||
int ProductionRate = 100;
|
||||
ProductionRate = (int)(ProductionRate * compareToDatset(soilProperties.Temperature, DataSet.Temparature));
|
||||
ProductionRate = (int)(ProductionRate * compareToDatset(soilProperties.Moisture , DataSet.Moisture));
|
||||
ProductionRate = (int)(ProductionRate * compareToDatset(soilProperties.Humidity , DataSet.Humidity));
|
||||
ProductionRate = (int)(ProductionRate * compareToDatset(soilProperties.Phosphorous , DataSet.Phosphorous));
|
||||
ProductionRate = (int)(ProductionRate * compareToDatset(soilProperties.Potassium , DataSet.Potassium));
|
||||
ProductionRate = (int)(ProductionRate * compareToDatset(soilProperties.Nitrogen , DataSet.Nitrogen));
|
||||
ProductionRate = (ProductionRate * compareToDatset(soilProperties.Temperature, DataSet.Temparature));
|
||||
ProductionRate = (ProductionRate * compareToDatset(soilProperties.Moisture, DataSet.Moisture));
|
||||
ProductionRate = (ProductionRate * compareToDatset(soilProperties.Humidity, DataSet.Humidity));
|
||||
ProductionRate = (ProductionRate * compareToDatset(soilProperties.Phosphorous, DataSet.Phosphorous));
|
||||
ProductionRate = (ProductionRate * compareToDatset(soilProperties.Potassium, DataSet.Potassium));
|
||||
ProductionRate = (ProductionRate * compareToDatset(soilProperties.Nitrogen, DataSet.Nitrogen));
|
||||
if (ProductionRate < 0)
|
||||
{
|
||||
return 0;
|
||||
ProductionRate = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ProductionRate;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public float compareToDatset(float i, float j)
|
||||
{
|
||||
if (i < j)
|
||||
if (i > j)
|
||||
{
|
||||
return (i / j) * 0.2f;
|
||||
return (i / j) * 0.15f;
|
||||
}
|
||||
else if (i < j / 2)
|
||||
{
|
||||
return (i / j) * 2f;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -276,13 +277,13 @@ class Crops
|
||||
spriteBatch.DrawString(Bold, "Humidity: ", new Vector2(240, Size.Y * (tileSize + Spacing) + 202), Color.DarkRed);
|
||||
spriteBatch.DrawString(Bold, soilProperties.Humidity.ToString(), new Vector2(370, Size.Y * (tileSize + Spacing) + 202), Color.DarkBlue);
|
||||
spriteBatch.DrawString(Bold, "Phosphorous: ", new Vector2(240, Size.Y * (tileSize + Spacing) + 222), Color.DarkRed);
|
||||
spriteBatch.DrawString(Bold, soilProperties.Phosphorous.ToString(), new Vector2(370, Size.Y * (tileSize + Spacing) + 222), Color.DarkBlue);
|
||||
spriteBatch.DrawString(Bold, Math.Round(soilProperties.Phosphorous,1).ToString(), new Vector2(370, Size.Y * (tileSize + Spacing) + 222), Color.DarkBlue);
|
||||
spriteBatch.DrawString(Bold, "Potassium: ", new Vector2(240, Size.Y * (tileSize + Spacing) + 242), Color.DarkRed);
|
||||
spriteBatch.DrawString(Bold, soilProperties.Potassium.ToString(), new Vector2(370, Size.Y * (tileSize + Spacing) + 242), Color.DarkBlue);
|
||||
spriteBatch.DrawString(Bold, Math.Round(soilProperties.Potassium, 1).ToString(), new Vector2(370, Size.Y * (tileSize + Spacing) + 242), Color.DarkBlue);
|
||||
spriteBatch.DrawString(Bold, "Nitrogen: ", new Vector2(240, Size.Y * (tileSize + Spacing) + 262), Color.DarkRed);
|
||||
spriteBatch.DrawString(Bold, soilProperties.Nitrogen.ToString(), new Vector2(370, Size.Y * (tileSize + Spacing) + 262), Color.DarkBlue);
|
||||
spriteBatch.DrawString(Bold, Math.Round(soilProperties.Nitrogen, 1).ToString(), new Vector2(370, Size.Y * (tileSize + Spacing) + 262), Color.DarkBlue);
|
||||
spriteBatch.DrawString(Bold, "Production Rate: ", new Vector2(240, Size.Y * (tileSize + Spacing) + 282), Color.DarkRed);
|
||||
spriteBatch.DrawString(Bold, getProductionRate().ToString(), new Vector2(370, Size.Y * (tileSize + Spacing) + 282), Color.DarkBlue);
|
||||
spriteBatch.DrawString(Bold, Math.Round((ProductionRate * 100), 1).ToString() + "%", new Vector2(370, Size.Y * (tileSize + Spacing) + 282), Color.DarkBlue);
|
||||
spriteBatch.End();
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ class Farm
|
||||
private Crops[,] crops;
|
||||
private Random r;
|
||||
private CropTypesHolder PresetCrops = new CropTypesHolder();
|
||||
private int Update;
|
||||
|
||||
|
||||
//initializes the crops
|
||||
@ -43,6 +44,9 @@ class Farm
|
||||
}
|
||||
|
||||
public void updateFarm(Vector2 Size)
|
||||
{
|
||||
Update++;
|
||||
if (Update == 30)
|
||||
{
|
||||
for (int i = 0; i < Size.X; i++)
|
||||
{
|
||||
@ -52,6 +56,9 @@ class Farm
|
||||
crops[i, j].updateCrop(Size);
|
||||
}
|
||||
}
|
||||
Update = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Changes the properties of the tile when the tractor reaches this tile.
|
||||
|
@ -48,8 +48,8 @@ class SoilProperties
|
||||
Humidity = Temperature * GetRandomNumber(1.9, 2.1);
|
||||
Moisture = GetRandomNumber(20, 70);
|
||||
Nitrogen = GetRandomNumber(4 , 55);
|
||||
Potassium = GetRandomNumber(0, 28);
|
||||
Phosphorous = GetRandomNumber(0, 60);
|
||||
Potassium = GetRandomNumber(0.01f, 28);
|
||||
Phosphorous = GetRandomNumber(0.01f, 60);
|
||||
}
|
||||
|
||||
public float GetRandomNumber(double minimum, double maximum)
|
||||
|
Loading…
Reference in New Issue
Block a user