This commit is contained in:
BOTLester 2020-05-24 18:50:47 +02:00
commit 0dfef73667
4 changed files with 37 additions and 32 deletions

View File

@ -318,7 +318,7 @@ namespace Game1
{
for (int j = -1; j < input.getSize().Y + 1; j++)
{
spriteBatch.Draw(Rain, tractorUnit.getFarm().getRainPosition(input.getTileSize(), i, j), tractorUnit.getFarm().getDestinationRectangle(i, j, input.getSize()), tractorUnit.getFarm().getRainAmount(i, j, Time.GetTimeOfDay(), input.getSize()));
spriteBatch.Draw(Rain, tractorUnit.getFarm().getRainPosition(input.getTileSize(), i, j, input.getSize()), tractorUnit.getFarm().getDestinationRectangle(i, j, input.getSize()), tractorUnit.getFarm().getRainAmount(i, j, Time.GetTimeOfDay(), input.getSize()));
}
}

View File

@ -272,6 +272,7 @@ class Crops
housePos = state;
if (state)
{
Timer = 1;
Status = 1;
}
else

View File

@ -72,14 +72,20 @@ class Farm
init(Size, housepos);
RainPosition.X = r.Next(0, 1900);
RainPosition.Y = r.Next(0, 1950);
RainPosition.X = 1000;
RainPosition.Y = 1000;
//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");
RainPosition.X = 1970;
RainPosition.Y = 155;
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");
}
public Rectangle getRainPosition(int TileSize, int x, int y)
public Rectangle getRainPosition(int TileSize, int x, int y, Vector2 Size)
{
Vector2 temp = new Vector2((int)Math.Round(RainPosition.X), (int)Math.Round(RainPosition.Y));
if (temp.X >= 1999 - Size.X - 1)
temp.X = x + (1999 - (int)Math.Round(RainPosition.X) - Size.X);
if (temp.Y >= 1999 - Size.Y - 1)
temp.Y = (1999 - (int)Math.Round(RainPosition.Y));
float xtrunc = RainPosition.X - (float)Math.Truncate(RainPosition.X);
float ytrunc = RainPosition.Y - (float)Math.Truncate(RainPosition.Y);
@ -99,14 +105,12 @@ class Farm
public Rectangle getDestinationRectangle(int x, int y, Vector2 Size)
{
Vector2 temp = new Vector2((int)Math.Round(RainPosition.X), (int)Math.Round(RainPosition.Y));
if (RainPosition.X >= 1999 - x)
temp.X = (1999 - (int)Math.Round(RainPosition.X));
//temp.X = temp.X + (x+1);
if (RainPosition.Y >= 1999 - y)
Vector2 temp = new Vector2((int)Math.Round(x + RainPosition.X), y + (int)Math.Round(RainPosition.Y));
if (temp.X >= 1999 - Size.X - 1)
temp.X = x + (1999 - (int)Math.Round(RainPosition.X));
if (temp.Y >= 1999 - Size.Y - 1)
temp.Y = (1999 - (int)Math.Round(RainPosition.Y));
//temp.Y = temp.Y + (y+1);
return new Rectangle(x + (int)temp.X, y + (int)temp.Y, 1, 1);
return new Rectangle((int)temp.X, (int)temp.Y, 1, 1);
}
public void drawWeatherInformation(SpriteBatch spriteBatch, SpriteFont Bold, Input input)
@ -125,12 +129,14 @@ class Farm
{
for (int j = 0; j < Size.Y; j++)
{
Vector2 temp = new Vector2((int)Math.Round(RainPosition.X), (int)Math.Round(RainPosition.Y));
if (RainPosition.X >= 1999 - i)
temp.X = (1999 - (int)Math.Round(RainPosition.X));
if (RainPosition.Y >= 1999 - j)
Vector2 temp = new Vector2((int)Math.Round(i + RainPosition.X), j + (int)Math.Round(RainPosition.Y));
if (temp.X >= 1999 - Size.X - 1)
temp.X = i + ((1999 - (int)Math.Round(RainPosition.X)));
if (temp.Y >= 1999 - Size.Y - 1)
temp.Y = (1999 - (int)Math.Round(RainPosition.Y));
crops[i, j].updateCrop(Size, RainfallMap[(int)Math.Round(temp.X) + i][(int)Math.Round(temp.Y) + j].GetBrightness());
if (temp.X == -1)
temp.X = 1999;
crops[i, j].updateCrop(Size, RainfallMap[(int)Math.Round(temp.X)][(int)Math.Round(temp.Y)].GetBrightness());
}
}
@ -176,7 +182,7 @@ class Farm
float x, y;
x = WindSpeed.X + GetRandomNumber(-1f, 1f) / 2000;
y = WindSpeed.Y + GetRandomNumber(-1f, 1f) / 2000;
//x = 0.02f;
x = 0.02f;
if (x <= 1f && x >= -1f)
{
WindSpeed.X = x;
@ -198,12 +204,12 @@ class Farm
RainPosition.Y = RainPosition.Y + WindSpeed.Y;
if (Math.Round(RainPosition.X) == 1999 && WindSpeed.X > 0)
RainPosition.X = 1;
RainPosition.X = 0;
else if (Math.Round(RainPosition.X) == 1 && WindSpeed.X < 0)
RainPosition.X = 1999;
if (Math.Round(RainPosition.Y) == 1999 - Size.Y - 1 && WindSpeed.Y > 0)
RainPosition.Y = 1;
RainPosition.Y = 0;
if (Math.Round(RainPosition.Y) == 1 && WindSpeed.Y < 0)
RainPosition.Y = 1999 - Size.Y - 1;
}
@ -257,15 +263,13 @@ class Farm
public Color getRainAmount(int x, int y, Color color, Vector2 Size)
{
Vector2 temp = new Vector2((int)Math.Round(RainPosition.X), (int)Math.Round(RainPosition.Y));
if (RainPosition.X >= 1999 - (x + 1))
temp.X = (1999 - (int)Math.Round(RainPosition.X));
temp.X = temp.X + (x + 1);
if (RainPosition.Y >= 1999 - (y + 1))
Vector2 temp = new Vector2(x + (int)Math.Round(RainPosition.X), y + (int)Math.Round(RainPosition.Y));
if (temp.X >= 1999)
temp.X = -(1999 - (int)Math.Round(temp.X));
if (temp.Y >= 1999 - Size.Y - 1)
temp.Y = (1999 - (int)Math.Round(RainPosition.Y));
temp.Y = temp.Y + (y + 1);
if (temp.X == -1)
temp.X = 1999;
if (RainfallMap[(int)temp.X][(int)temp.Y].GetBrightness() < 0.4f)
{
return Color.FromNonPremultiplied(color.R, color.G, color.B, (int)(0));

View File

@ -20,9 +20,9 @@ class MLModel
private static string modelpathBig = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/MLmodelBig";
private static string reportBig = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/report_BigModel";
private static string path = "C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/ML/Fertilizer_Prediction.csv";
private static string modelpath = "C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/ML/MLmodel";
private static string report = "C:/Users/Oskar/source/repos/PotatoPlanFinal/Game1/Content/ML/report";
private static string path = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/Fertilizer_Prediction.csv";
private static string modelpath = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/MLmodel";
private static string report = "C:/Users/Joel/source/repos/Oskars Repo/Game1/Content/ML/report";
// Loading data, creatin and saving ML model for smaller dataset (100)
public static void CreateModel()