diff --git a/Game1/Content/ProgressionBarStatus.png b/Game1/Content/ProgressionBarStatus.png index 45b8979..d7b9361 100644 Binary files a/Game1/Content/ProgressionBarStatus.png and b/Game1/Content/ProgressionBarStatus.png differ diff --git a/Game1/Game1.cs b/Game1/Game1.cs index cbbff67..1a1b4d8 100644 --- a/Game1/Game1.cs +++ b/Game1/Game1.cs @@ -258,7 +258,7 @@ namespace Game1 if ((tractorUnit.getFarm().getCrop(i, j).getStatus() == 3)) { spriteBatch.Draw(ProgressionBar, new Rectangle(i * (input.getSpacingTile()) + input.getTileSize() - input.getTileSize() / 3, j * (input.getSpacingTile()), input.getTileSize() / 3, input.getTileSize()), Color.White); - spriteBatch.Draw(ProgressionBarStatus, new Rectangle(i * (input.getSpacingTile()) + input.getTileSize() - input.getTileSize() / 4, j * (input.getSpacingTile()) + input.getTileSize() / 3, input.getTileSize() / 4, tractorUnit.getFarm().getCrop(i, j).getCropTimerBar((input.getTileSize())) + 1), Color.White); + spriteBatch.Draw(ProgressionBarStatus, new Rectangle(i * (input.getSpacingTile()) + input.getTileSize() - input.getTileSize() / 4, j * (input.getSpacingTile()) + input.getTileSize() / 3, input.getTileSize() / 4, tractorUnit.getFarm().getCrop(i, j).getCropTimerBar((input.getTileSize())) + 1), new Color(tractorUnit.getFarm().getCrop(i, j).getColour())); } spriteBatch.Draw(Crops[tractorUnit.getFarm().getCrop(i, j).getCropType()], new Rectangle((int)(i * (input.getSpacingTile()) + input.getTileSize() - input.getTileSize() / 2.5), j * (input.getSpacingTile()), (int)(input.getTileSize() / 2.5), input.getTileSize() / 3), Color.White); } diff --git a/Game1/Sources/Crops/Crops.cs b/Game1/Sources/Crops/Crops.cs index a8b437f..1dba4d6 100644 --- a/Game1/Sources/Crops/Crops.cs +++ b/Game1/Sources/Crops/Crops.cs @@ -194,15 +194,15 @@ class Crops if (soilProperties.Nitrogen > 4.0f) { - soilProperties.Nitrogen = soilProperties.Nitrogen - soilProperties.NitrogenDegradeRate; + soilProperties.Nitrogen = soilProperties.Nitrogen - (soilProperties.NitrogenDegradeRate * (float)Math.Pow(ProductionRate, 2)); } if (soilProperties.Phosphorous > 0.1f) { - soilProperties.Phosphorous = soilProperties.Phosphorous - soilProperties.PhosphorousDegradeRate; + soilProperties.Phosphorous = soilProperties.Phosphorous - (soilProperties.PhosphorousDegradeRate * (float)Math.Pow(ProductionRate, 2)); } if (soilProperties.Potassium > 0.1f) { - soilProperties.Potassium = soilProperties.Potassium - soilProperties.PotassiumDegradeRate; + soilProperties.Potassium = soilProperties.Potassium - (soilProperties.PotassiumDegradeRate * (float)Math.Pow(ProductionRate, 2)); } } @@ -265,22 +265,46 @@ class Crops return ((int)(soilProperties.Nitrogen + soilProperties.Potassium + soilProperties.Phosphorous)) < soilProperties.Capacity; } + public Vector4 getColour() + { + float r, g, b, a; + float productionRate, overhead; + + if (ProductionRate > 1.0f) + { + productionRate = 1.0f; + overhead = ProductionRate - 1.0f; + } + else + { + productionRate = ProductionRate; + overhead = 0.0f; + } + + r = (1.0f - productionRate) * 2; + g = 0.0f + productionRate; + b = 0.0f + (float)Math.Pow((double)overhead * 10, 2); + a = 255; + + return new Vector4(r, g, b, a); + } + public float getProductionRate(CropTypes Sample) { ProductionRate = 1; float min = 1.0f; if (DataSet != null) { - ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Temperature, Sample.Temparature)); - ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Moisture, Sample.Moisture)); - ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Humidity, Sample.Humidity)); + //ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Temperature, Sample.Temparature)); + //ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Moisture, Sample.Moisture)); + //ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Humidity, Sample.Humidity)); min = Math.Min(compareToDatset(soilProperties.Phosphorous, Sample.Phosphorous), Math.Min(compareToDatset(soilProperties.Potassium, Sample.Potassium), compareToDatset(soilProperties.Nitrogen, Sample.Nitrogen))); ProductionRate = ProductionRate + (ProductionRate * min); if (ProductionRate < 0) { ProductionRate = 0; } - ProductionRate = ProductionRate / 10; + ProductionRate = ProductionRate / 1.5f; } ProductionRate = (float)Math.Pow(ProductionRate, 2.5f); return ProductionRate; diff --git a/Game1/Sources/Pathing/PriorityQueueC5.cs b/Game1/Sources/Pathing/PriorityQueueC5.cs index c318a73..15017ba 100644 --- a/Game1/Sources/Pathing/PriorityQueueC5.cs +++ b/Game1/Sources/Pathing/PriorityQueueC5.cs @@ -46,4 +46,9 @@ class PriorityQueueC5 queue.AddAll(entryList); } + public int getCount() + { + return queue.Count(); + } + } \ No newline at end of file diff --git a/Game1/Sources/Smart/AI.cs b/Game1/Sources/Smart/AI.cs index 44f007e..1910b5d 100644 --- a/Game1/Sources/Smart/AI.cs +++ b/Game1/Sources/Smart/AI.cs @@ -53,6 +53,11 @@ class AI int count = 0; int testsize = 2; Path newTarget; + Nodes nodes; + if (astar.GetAdjacentNodes(tractorPos).Count == 0) + nodes = new Nodes(housePos); + else + nodes = astar.GetAdjacentNodes(tractorPos)[0]; if (tractorPos != housePos) if (inventory.getWeight() == inventory.getMaxWeight() || inventory.isMissingFertilizer()) { @@ -81,9 +86,19 @@ class AI } if (count > 0) break; + else if (queue.getCount() == 0) + { + astar.update(farm.getCrops(), Size, tractorPos, housePos, nodes.getCords(), Rotation); + return newTarget = astar.FindPath(true); + } else //if (tractorPos != housePos) - return newTarget = GetMaxFNode(testsize, queue); + return newTarget = GetMaxFNode(Math.Min(queue.getCount(), testsize), queue); } + if (queue.getCount() == 0) + { + astar.update(farm.getCrops(), Size, tractorPos, housePos, nodes.getCords(), Rotation); + return newTarget = astar.FindPath(true); + } newTarget = GetMinFNode(Math.Min(testsize, count), queue); queue = null;