1
0
forked from s425077/PotatoPlan
This commit is contained in:
BOTLester 2020-05-25 00:05:11 +02:00
commit 561287f99e
2 changed files with 13 additions and 13 deletions

View File

@ -20,9 +20,9 @@ class Farm
private float[][] whiteNoise; private float[][] whiteNoise;
private float[][] perlinNoise; private float[][] perlinNoise;
private DayNightCycle Time; private DayNightCycle Time;
private float updatePerc = 0.5f; private float updatePerc = 0.10f;
private float updateProgress = 0; private float updateProgress = 0;
private int nextUpdate = 0; private float nextUpdate = 0;
private int productionUpdate = 0; private int productionUpdate = 0;
@ -77,8 +77,8 @@ class Farm
init(Size, housepos); init(Size, housepos);
RainPosition.X = r.Next(0, 1900); RainPosition.X = r.Next(0, 1900);
RainPosition.Y = r.Next(0, 1950); 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\\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/oel/source/repos/Oscars Repo/Game1/Content/Rainfall.png");
} }
public Rectangle getRainPosition(int TileSize, int x, int y, Vector2 Size) public Rectangle getRainPosition(int TileSize, int x, int y, Vector2 Size)
@ -137,18 +137,18 @@ class Farm
Update = 0; Update = 0;
} }
if (productionUpdate == 20) if (productionUpdate == 60)
{ {
nextUpdate = (int)(nextUpdate + Size.X * updatePerc); nextUpdate = updateProgress + updatePerc;
for (int i = (int)(updateProgress * Size.X); i < nextUpdate; i++) for (int i = (int)(updateProgress * Size.X); i < nextUpdate * Size.X; i++)
{ {
for (int j = 0; j < Size.Y; j++) for (int j = 0; j < Size.Y; j++)
{ {
crops[i, j].updateProductionRate(); crops[i, j].updateProductionRate();
} }
} }
updateProgress = updateProgress + nextUpdate; updateProgress = updateProgress + updatePerc;
if (updateProgress > 1) if (updateProgress >= 1)
{ {
updateProgress = 0; updateProgress = 0;
} }
@ -248,7 +248,7 @@ class Farm
public CropTypes getPresetCropTypes(int Index) public CropTypes getPresetCropTypes(int Index)
{ {
return PresetCrops.getPresetCropTypes(Index - 1); return PresetCrops.getPresetCropTypes(Index);
} }
public void setCropType(int x, int y, int Type) public void setCropType(int x, int y, int Type)
@ -273,7 +273,7 @@ class Farm
private int getHighestProductionRate(int x, int y) private int getHighestProductionRate(int x, int y)
{ {
int i = 1, holderIndex = 0; int i = 6, holderIndex = 0;
float holder = 0, SampleHolder = 0; float holder = 0, SampleHolder = 0;
do do
{ {

View File

@ -18,7 +18,7 @@ class SmartTractor
{ {
//System.Threading.ThreadStart tractorThread = new System.Threading.ThreadStart(farm.UpdatePreferedCrops); //System.Threading.ThreadStart tractorThread = new System.Threading.ThreadStart(farm.UpdatePreferedCrops);
ai.update(farm, Size, tractorPos / (tileSize + Spacing), housePos / (tileSize + Spacing), Target / (tileSize + Spacing), Rotation); ai.update(farm, Size, tractorPos / (tileSize + Spacing), housePos / (tileSize + Spacing), Target / (tileSize + Spacing), Rotation);
farm.UpdatePreferedCrops(Size); //farm.UpdatePreferedCrops(Size);
farm = ai.changeCropStatus(); farm = ai.changeCropStatus();
astar.update(farm.getCrops(), Size, tractorPos / (tileSize + Spacing), housePos / (tileSize + Spacing), Rotation); astar.update(farm.getCrops(), Size, tractorPos / (tileSize + Spacing), housePos / (tileSize + Spacing), Rotation);
//getTargetPosition(ai.newTarget()); //getTargetPosition(ai.newTarget());
@ -44,7 +44,6 @@ class SmartTractor
tileSize = newTileSize; tileSize = newTileSize;
Spacing = newSpacing; Spacing = newSpacing;
Rotation = rotation; Rotation = rotation;
} }
public void init(Vector2 nHousePos) public void init(Vector2 nHousePos)
@ -52,6 +51,7 @@ class SmartTractor
ai.init(); ai.init();
housePos = nHousePos; housePos = nHousePos;
farm.init(new Vector2(100, (GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height / tileSize) - 125 / tileSize), housePos / (tileSize + Spacing)); 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) public void drawInventory(Input input, SpriteBatch spriteBatch, SpriteFont Bold, Cargo itemStorageDefined)