diff --git a/Game1/Game1.cs b/Game1/Game1.cs index 25187fd..9d5b682 100644 --- a/Game1/Game1.cs +++ b/Game1/Game1.cs @@ -219,6 +219,7 @@ namespace Game1 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, "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, Time.GetTimeOfDayInt().ToString() + "%", new Vector2(140, input.getSize().Y * (input.getTileSize() + input.getSpacing()) + 22), Color.Teal); diff --git a/Game1/Sources/Crops/Crops.cs b/Game1/Sources/Crops/Crops.cs index 012fc76..019c6d9 100644 --- a/Game1/Sources/Crops/Crops.cs +++ b/Game1/Sources/Crops/Crops.cs @@ -22,11 +22,13 @@ class Crops SoilProperties soilProperties = new SoilProperties(); private float ProductionRate; 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; getProductionRate(DataSet); if (UpdateCrop == 60) @@ -237,9 +239,15 @@ class Crops public void setCropType(int Type, CropTypes nCropType) { + DataSet = nCropType; - soilProperties.Area = r.Next(nCropType.AreaMin, nCropType.AreaMax); cropType = Type; + + if (Status == 3) + { + soilProperties.Area = r.Next(nCropType.AreaMin, nCropType.AreaMax); + } + } public int getStatus() diff --git a/Game1/Sources/Crops/Farm.cs b/Game1/Sources/Crops/Farm.cs index 36cd5de..ad7204e 100644 --- a/Game1/Sources/Crops/Farm.cs +++ b/Game1/Sources/Crops/Farm.cs @@ -19,6 +19,7 @@ class Farm private System.Drawing.Color[][] RainfallMap; private float[][] whiteNoise; private float[][] perlinNoise; + private DayNightCycle Time; //initializes the crops @@ -126,7 +127,7 @@ class Farm temp.X = i + ((1999 - (int)Math.Round(RainPosition.X))); if (temp.Y >= 1999 - Size.Y - 1) 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); } - 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++) { diff --git a/Game1/Sources/Objects/DayNightCycle.cs b/Game1/Sources/Objects/DayNightCycle.cs index 1ffb44c..d86e74a 100644 --- a/Game1/Sources/Objects/DayNightCycle.cs +++ b/Game1/Sources/Objects/DayNightCycle.cs @@ -40,7 +40,7 @@ class DayNightCycle DaysOfYear++; } } - if (DaysOfYear == 365) + if (DaysOfYear == 48) { DaysOfYear = 0; } @@ -55,16 +55,16 @@ class DayNightCycle //3 - Autumn //4 - Winter - public int getTimeOfYear() + public string getTimeOfYear() { - if (DaysOfYear < 93) - return 1; - else if (DaysOfYear < 187) - return 2; - else if (DaysOfYear < 276) - return 3; + if (DaysOfYear < 12) + return "Spring"; + else if (DaysOfYear < 24) + return "Summer"; + else if (DaysOfYear < 36) + return "Autumn"; else - return 4; + return "Winter"; } public Color GetTimeOfDay() diff --git a/Game1/Sources/Objects/Tractor.cs b/Game1/Sources/Objects/Tractor.cs index db4745b..f49a3f6 100644 --- a/Game1/Sources/Objects/Tractor.cs +++ b/Game1/Sources/Objects/Tractor.cs @@ -22,8 +22,7 @@ class Tractor Size = input.getSize(); updatePosition(input.getSize(), Status); housePos = newHousePos; - smartTractor.UpdateCrops(Speed, Time.nDay()); - + smartTractor.UpdateCrops(Speed, Time); } public void init(Rectangle house, Input input) diff --git a/Game1/Sources/Smart/SmartTractor.cs b/Game1/Sources/Smart/SmartTractor.cs index e0bc9b5..810d106 100644 --- a/Game1/Sources/Smart/SmartTractor.cs +++ b/Game1/Sources/Smart/SmartTractor.cs @@ -74,13 +74,13 @@ class SmartTractor 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++) { farm.updateFarm(Size); } - farm.updateRainFall(Size, nDay); + farm.updateRainFall(Size, Time); } public Inventory getInventory()