This commit is contained in:
Joel 2020-05-24 21:22:17 +02:00
parent 5e907deca7
commit 14e0e92f9b
6 changed files with 28 additions and 18 deletions

View File

@ -219,6 +219,7 @@ namespace Game1
tractorUnit.drawInventory(input, spriteBatch, Bold, inventory.getPredefinedItems()); tractorUnit.drawInventory(input, spriteBatch, Bold, inventory.getPredefinedItems());
spriteBatch.DrawString(Bold, "Time: ", new Vector2(10, input.getSize().Y * (input.getTileSize() + input.getSpacing()) + 2), Color.DarkRed); spriteBatch.DrawString(Bold, "Time: ", new Vector2(10, input.getSize().Y * (input.getTileSize() + input.getSpacing()) + 2), Color.DarkRed);
spriteBatch.DrawString(Bold, "Days " + Time.getDays(), new Vector2(60, input.getSize().Y * (input.getTileSize() + input.getSpacing()) + 2), Color.Teal); spriteBatch.DrawString(Bold, "Days " + Time.getDays(), new Vector2(60, input.getSize().Y * (input.getTileSize() + input.getSpacing()) + 2), Color.Teal);
spriteBatch.DrawString(Bold, Time.getTimeOfYear(), new Vector2(120, input.getSize().Y * (input.getTileSize() + input.getSpacing()) + 2), Color.Teal);
spriteBatch.DrawString(Bold, "Day Progression: ", new Vector2(10, input.getSize().Y * (input.getTileSize() + input.getSpacing()) + 22), Color.DarkRed); spriteBatch.DrawString(Bold, "Day Progression: ", new Vector2(10, input.getSize().Y * (input.getTileSize() + input.getSpacing()) + 22), Color.DarkRed);
spriteBatch.DrawString(Bold, Time.GetTimeOfDayInt().ToString() + "%", new Vector2(140, input.getSize().Y * (input.getTileSize() + input.getSpacing()) + 22), Color.Teal); spriteBatch.DrawString(Bold, Time.GetTimeOfDayInt().ToString() + "%", new Vector2(140, input.getSize().Y * (input.getTileSize() + input.getSpacing()) + 22), Color.Teal);

View File

@ -22,11 +22,13 @@ class Crops
SoilProperties soilProperties = new SoilProperties(); SoilProperties soilProperties = new SoilProperties();
private float ProductionRate; private float ProductionRate;
private float tempRain; private float tempRain;
public DayNightCycle Time { get; set; }
public void updateCrop(Vector2 newSize, float Rain) public void updateCrop(Vector2 newSize, float Rain, DayNightCycle nTime)
{ {
Time = nTime;
tempRain = Rain; tempRain = Rain;
getProductionRate(DataSet); getProductionRate(DataSet);
if (UpdateCrop == 60) if (UpdateCrop == 60)
@ -237,9 +239,15 @@ class Crops
public void setCropType(int Type, CropTypes nCropType) public void setCropType(int Type, CropTypes nCropType)
{ {
DataSet = nCropType; DataSet = nCropType;
soilProperties.Area = r.Next(nCropType.AreaMin, nCropType.AreaMax);
cropType = Type; cropType = Type;
if (Status == 3)
{
soilProperties.Area = r.Next(nCropType.AreaMin, nCropType.AreaMax);
}
} }
public int getStatus() public int getStatus()

View File

@ -19,6 +19,7 @@ class Farm
private System.Drawing.Color[][] RainfallMap; private System.Drawing.Color[][] RainfallMap;
private float[][] whiteNoise; private float[][] whiteNoise;
private float[][] perlinNoise; private float[][] perlinNoise;
private DayNightCycle Time;
//initializes the crops //initializes the crops
@ -126,7 +127,7 @@ class Farm
temp.X = i + ((1999 - (int)Math.Round(RainPosition.X))); temp.X = i + ((1999 - (int)Math.Round(RainPosition.X)));
if (temp.Y >= 1999 - Size.Y - 1) if (temp.Y >= 1999 - Size.Y - 1)
temp.Y = i + ((1999 - (int)Math.Round(RainPosition.Y))); temp.Y = i + ((1999 - (int)Math.Round(RainPosition.Y)));
crops[i, j].updateCrop(Size, RainfallMap[(int)Math.Round(temp.X)][(int)Math.Round(temp.Y)].GetBrightness()); crops[i, j].updateCrop(Size, RainfallMap[(int)Math.Round(temp.X)][(int)Math.Round(temp.Y)].GetBrightness(), Time);
} }
} }
@ -135,9 +136,10 @@ class Farm
updateRainMapPosition(Size); updateRainMapPosition(Size);
} }
public void updateRainFall(Vector2 Size, bool nDay) public void updateRainFall(Vector2 Size, DayNightCycle nTime)
{ {
if (nDay) Time = nTime;
if (nTime.nDay())
{ {
for (int i = 0; i < Size.X; i++) for (int i = 0; i < Size.X; i++)
{ {

View File

@ -40,7 +40,7 @@ class DayNightCycle
DaysOfYear++; DaysOfYear++;
} }
} }
if (DaysOfYear == 365) if (DaysOfYear == 48)
{ {
DaysOfYear = 0; DaysOfYear = 0;
} }
@ -55,16 +55,16 @@ class DayNightCycle
//3 - Autumn //3 - Autumn
//4 - Winter //4 - Winter
public int getTimeOfYear() public string getTimeOfYear()
{ {
if (DaysOfYear < 93) if (DaysOfYear < 12)
return 1; return "Spring";
else if (DaysOfYear < 187) else if (DaysOfYear < 24)
return 2; return "Summer";
else if (DaysOfYear < 276) else if (DaysOfYear < 36)
return 3; return "Autumn";
else else
return 4; return "Winter";
} }
public Color GetTimeOfDay() public Color GetTimeOfDay()

View File

@ -22,8 +22,7 @@ class Tractor
Size = input.getSize(); Size = input.getSize();
updatePosition(input.getSize(), Status); updatePosition(input.getSize(), Status);
housePos = newHousePos; housePos = newHousePos;
smartTractor.UpdateCrops(Speed, Time.nDay()); smartTractor.UpdateCrops(Speed, Time);
} }
public void init(Rectangle house, Input input) public void init(Rectangle house, Input input)

View File

@ -74,13 +74,13 @@ class SmartTractor
farm.setNewHousePos(pos, newState); farm.setNewHousePos(pos, newState);
} }
public void UpdateCrops(int Speed, bool nDay) public void UpdateCrops(int Speed, DayNightCycle Time)
{ {
for (int i = 0; i < Speed; i++) for (int i = 0; i < Speed; i++)
{ {
farm.updateFarm(Size); farm.updateFarm(Size);
} }
farm.updateRainFall(Size, nDay); farm.updateRainFall(Size, Time);
} }
public Inventory getInventory() public Inventory getInventory()