From 8ab1d77d9c8907dd02b16b71d7271b1b45fdb661 Mon Sep 17 00:00:00 2001 From: Joel Date: Sun, 24 May 2020 23:10:51 +0200 Subject: [PATCH 1/2] asd --- Game1/Sources/Crops/Farm.cs | 19 ++++++++++--------- Game1/Sources/Smart/SmartTractor.cs | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Game1/Sources/Crops/Farm.cs b/Game1/Sources/Crops/Farm.cs index c99cfa1..dcb59b7 100644 --- a/Game1/Sources/Crops/Farm.cs +++ b/Game1/Sources/Crops/Farm.cs @@ -20,9 +20,9 @@ class Farm private float[][] whiteNoise; private float[][] perlinNoise; private DayNightCycle Time; - private float updatePerc = 0.25f; + private float updatePerc = 0.10f; private float updateProgress = 0; - private int nextUpdate = 0; + private float nextUpdate = 0; private int productionUpdate = 0; @@ -77,8 +77,8 @@ class Farm init(Size, housepos); RainPosition.X = r.Next(0, 1900); RainPosition.Y = r.Next(0, 1950); - //RainfallMap = PerlinNoise.LoadImage("C:\\Users\\Joel\\source\\repos\\Oskars Repo\\Game1\\Content\\Rainfall.png"); - RainfallMap = PerlinNoise.LoadImage("C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/Rainfall.png"); + RainfallMap = PerlinNoise.LoadImage("C:\\Users\\Joel\\source\\repos\\Oskars Repo\\Game1\\Content\\Rainfall.png"); + //RainfallMap = PerlinNoise.LoadImage("C:/Users/oel/source/repos/Oscars Repo/Game1/Content/Rainfall.png"); } public Rectangle getRainPosition(int TileSize, int x, int y, Vector2 Size) @@ -137,10 +137,10 @@ class Farm Update = 0; } - if (productionUpdate == 20) + if (productionUpdate == 60) { - nextUpdate = (int)(nextUpdate + Size.X * updatePerc); - for (int i = (int)(updateProgress * Size.X); i < nextUpdate; i++) + nextUpdate = updateProgress + updatePerc; + for (int i = (int)(updateProgress * Size.X); i < nextUpdate * Size.X; i++) { for (int j = 0; j < Size.Y; j++) { @@ -148,12 +148,13 @@ class Farm } } updateProgress = updateProgress + updatePerc; - if (updateProgress > 1) + if (updateProgress >= 1) { updateProgress = 0; } updateRainMapPosition(Size); productionUpdate = 0; + nextUpdate = 0; } productionUpdate++; } @@ -247,7 +248,7 @@ class Farm public CropTypes getPresetCropTypes(int Index) { - return PresetCrops.getPresetCropTypes(Index - 1); + return PresetCrops.getPresetCropTypes(Index); } public void setCropType(int x, int y, int Type) diff --git a/Game1/Sources/Smart/SmartTractor.cs b/Game1/Sources/Smart/SmartTractor.cs index 1eba621..5347c9f 100644 --- a/Game1/Sources/Smart/SmartTractor.cs +++ b/Game1/Sources/Smart/SmartTractor.cs @@ -18,7 +18,7 @@ class SmartTractor { //System.Threading.ThreadStart tractorThread = new System.Threading.ThreadStart(farm.UpdatePreferedCrops); ai.update(farm, Size, tractorPos / (tileSize + Spacing), housePos / (tileSize + Spacing), Target / (tileSize + Spacing), Rotation); - farm.UpdatePreferedCrops(Size); + //farm.UpdatePreferedCrops(Size); farm = ai.changeCropStatus(); astar.update(farm.getCrops(), Size, tractorPos / (tileSize + Spacing), housePos / (tileSize + Spacing), Rotation); //getTargetPosition(ai.newTarget()); From c89fee6b0589855652ad7b84d6e4c156885eebff Mon Sep 17 00:00:00 2001 From: Joel Date: Mon, 25 May 2020 00:03:26 +0200 Subject: [PATCH 2/2] asd --- Game1/Sources/Crops/Farm.cs | 2 +- Game1/Sources/Smart/SmartTractor.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Game1/Sources/Crops/Farm.cs b/Game1/Sources/Crops/Farm.cs index dcb59b7..93ff002 100644 --- a/Game1/Sources/Crops/Farm.cs +++ b/Game1/Sources/Crops/Farm.cs @@ -273,7 +273,7 @@ class Farm private int getHighestProductionRate(int x, int y) { - int i = 1, holderIndex = 0; + int i = 6, holderIndex = 0; float holder = 0, SampleHolder = 0; do { diff --git a/Game1/Sources/Smart/SmartTractor.cs b/Game1/Sources/Smart/SmartTractor.cs index 5347c9f..c7c5688 100644 --- a/Game1/Sources/Smart/SmartTractor.cs +++ b/Game1/Sources/Smart/SmartTractor.cs @@ -44,7 +44,6 @@ class SmartTractor tileSize = newTileSize; Spacing = newSpacing; Rotation = rotation; - } public void init(Vector2 nHousePos) @@ -52,6 +51,7 @@ class SmartTractor ai.init(); housePos = nHousePos; farm.init(new Vector2(100, (GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height / tileSize) - 125 / tileSize), housePos / (tileSize + Spacing)); + farm.UpdatePreferedCrops(Size); } public void drawInventory(Input input, SpriteBatch spriteBatch, SpriteFont Bold, Cargo itemStorageDefined)