merge
This commit is contained in:
commit
5a208e116f
BIN
Game1/Content/Clouds
Normal file
BIN
Game1/Content/Clouds
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 MiB |
Binary file not shown.
Before Width: | Height: | Size: 160 KiB After Width: | Height: | Size: 1.4 MiB |
@ -311,16 +311,6 @@ namespace Game1
|
||||
|
||||
}
|
||||
}
|
||||
/*cloudFrame++;
|
||||
if (cloudFrame > cloudAnimationSpeed)
|
||||
{
|
||||
cloudSprite++;
|
||||
if (cloudSprite > 4)
|
||||
{
|
||||
cloudSprite = 0;
|
||||
}
|
||||
cloudFrame = 0;
|
||||
}*/
|
||||
spriteBatch.Draw(house, houseUnit.GetRectangle(), Time.GetTimeOfDay());
|
||||
spriteBatch.Draw(tractor, new Vector2((int)tractorUnit.getPos().X + input.getTileSize() / 2, (int)tractorUnit.getPos().Y + input.getTileSize() / 2), new Rectangle(0, 0, input.getTileSize(), input.getTileSize()), Time.GetTimeOfDay(), tractorUnit.getRotation(), new Vector2(input.getTileSize() / 2, input.getTileSize() / 2), 1.0f, SpriteEffects.None, 1);
|
||||
|
||||
@ -328,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), tractorUnit.getFarm().getRainAmount(i, 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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,6 @@ class Farm
|
||||
private System.Drawing.Color[][] RainfallMap;
|
||||
private float[][] whiteNoise;
|
||||
private float[][] perlinNoise;
|
||||
private int resetBitMap = 0;
|
||||
|
||||
|
||||
//initializes the crops
|
||||
@ -64,7 +63,6 @@ class Farm
|
||||
{
|
||||
if (!astar.isReachable(crops, new Vector2((int)i, (int)j), housepos))
|
||||
{
|
||||
//crops[i, j].setStatus(1);
|
||||
dirtCount--;
|
||||
}
|
||||
}
|
||||
@ -74,23 +72,46 @@ class Farm
|
||||
init(Size, housepos);
|
||||
RainPosition.X = r.Next(0, 1900);
|
||||
RainPosition.Y = r.Next(0, 1950);
|
||||
RainPosition.X = 5;
|
||||
RainPosition.Y = 5;
|
||||
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)
|
||||
{
|
||||
return new Rectangle(x * TileSize, y * TileSize, TileSize, TileSize);
|
||||
float xtrunc = RainPosition.X - (float)Math.Truncate(RainPosition.X);
|
||||
float ytrunc = RainPosition.Y - (float)Math.Truncate(RainPosition.Y);
|
||||
|
||||
if (xtrunc > 0.5)
|
||||
xtrunc = xtrunc - 1;
|
||||
|
||||
if (ytrunc > 0.5)
|
||||
ytrunc = ytrunc - 1;
|
||||
xtrunc = -xtrunc;
|
||||
ytrunc = -ytrunc;
|
||||
|
||||
|
||||
|
||||
//return new Rectangle((int)(xtrunc * TileSize) + x * TileSize,(int)(ytrunc * TileSize) + y * TileSize, TileSize, TileSize);
|
||||
return new Rectangle((int)(xtrunc * TileSize) + x * TileSize, (int)(ytrunc * TileSize) + y * TileSize, TileSize, TileSize);
|
||||
}
|
||||
|
||||
public Rectangle getDestinationRectangle(int x, int y)
|
||||
public Rectangle getDestinationRectangle(int x, int y, Vector2 Size)
|
||||
{
|
||||
return new Rectangle(x + (int)Math.Round(RainPosition.X), y + (int)Math.Round(RainPosition.Y), 1, 1);
|
||||
//return new Rectangle(0, 0, 112, 112);
|
||||
Vector2 temp = new Vector2((int)Math.Round(RainPosition.X), (int)Math.Round(RainPosition.Y));
|
||||
if (RainPosition.X >= 1999 - Size.X)
|
||||
temp.X = (Size.X) - (1999 - (int)Math.Round(RainPosition.X));
|
||||
if (RainPosition.Y >= 1999 - Size.Y)
|
||||
temp.Y = (Size.Y) - (1999 - (int)Math.Round(RainPosition.Y));
|
||||
return new Rectangle(x + (int)temp.X, y + (int)temp.Y, 1, 1);
|
||||
}
|
||||
|
||||
public void drawWeatherInformation(SpriteBatch spriteBatch, SpriteFont Bold, Input input)
|
||||
{
|
||||
spriteBatch.DrawString(Bold, "Wind Speed: X:" + WindSpeed.X + "Y" + WindSpeed.Y, new Vector2(10, input.getSize().Y * (input.getTileSize() + input.getSpacing()) + 282), Color.DarkBlue);
|
||||
spriteBatch.DrawString(Bold, "WindSpeed: " + Math.Round(WindSpeed.X, 4), new Vector2(10, input.getSize().Y * (input.getTileSize() + input.getSpacing()) + 282), Color.DarkBlue);
|
||||
spriteBatch.DrawString(Bold, " : ", new Vector2(153, input.getSize().Y * (input.getTileSize() + input.getSpacing()) + 282), Color.DarkBlue);
|
||||
spriteBatch.DrawString(Bold, Math.Round(WindSpeed.Y, 4).ToString(), new Vector2(163, input.getSize().Y * (input.getTileSize() + input.getSpacing()) + 282), Color.DarkBlue);
|
||||
}
|
||||
|
||||
public void updateFarm(Vector2 Size, int nDay)
|
||||
@ -102,14 +123,18 @@ class Farm
|
||||
{
|
||||
for (int j = 0; j < Size.Y; j++)
|
||||
{
|
||||
|
||||
crops[i, j].updateCrop(Size, RainfallMap[(int)Math.Round(RainPosition.X) + i][(int)Math.Round(RainPosition.Y) + j].GetBrightness());
|
||||
Vector2 temp = new Vector2((int)Math.Round(RainPosition.X), (int)Math.Round(RainPosition.Y));
|
||||
if (RainPosition.X >= 1999 - Size.X)
|
||||
temp.X = (Size.X) - (1999 - (int)Math.Round(RainPosition.X));
|
||||
if (RainPosition.Y >= 1999 - Size.Y)
|
||||
temp.Y = (Size.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());
|
||||
}
|
||||
}
|
||||
|
||||
Update = 0;
|
||||
}
|
||||
updateRainMapPosition();
|
||||
updateRainMapPosition(Size);
|
||||
}
|
||||
|
||||
|
||||
@ -144,13 +169,13 @@ class Farm
|
||||
return crops;
|
||||
}
|
||||
|
||||
private void updateRainMapPosition()
|
||||
private void updateRainMapPosition(Vector2 Size)
|
||||
{
|
||||
float x, y;
|
||||
x = WindSpeed.X + GetRandomNumber(-1f, 1f) / 1000;
|
||||
y = WindSpeed.Y + GetRandomNumber(-1f, 1f) / 1000;
|
||||
|
||||
if (x < 0.02f && x > -0.02f)
|
||||
x = WindSpeed.X + GetRandomNumber(-1f, 1f) / 2000;
|
||||
y = WindSpeed.Y + GetRandomNumber(-1f, 1f) / 2000;
|
||||
x = -0.02f;
|
||||
if (x <= 1f && x >= -1f)
|
||||
{
|
||||
WindSpeed.X = x;
|
||||
}
|
||||
@ -160,31 +185,25 @@ class Farm
|
||||
WindSpeed.Y = y;
|
||||
}
|
||||
|
||||
if (WindSpeed.X > 0 && RainPosition.X < 1900)
|
||||
{
|
||||
if (WindSpeed.X > 0 && RainPosition.X < 2000)
|
||||
RainPosition.X = RainPosition.X + WindSpeed.X;
|
||||
}
|
||||
else if (WindSpeed.X < 0 && RainPosition.X > 1)
|
||||
{
|
||||
else if (WindSpeed.X < 0 && RainPosition.X > 0)
|
||||
RainPosition.X = RainPosition.X + WindSpeed.X;
|
||||
}
|
||||
|
||||
if (WindSpeed.Y > 0 && RainPosition.Y < 1900)
|
||||
{
|
||||
if (WindSpeed.Y > 0 && RainPosition.Y < 2000)
|
||||
RainPosition.Y = RainPosition.Y + WindSpeed.Y;
|
||||
}
|
||||
else if (WindSpeed.Y < 0 && RainPosition.Y > 1)
|
||||
{
|
||||
else if (WindSpeed.Y < 0 && RainPosition.Y > 0)
|
||||
RainPosition.Y = RainPosition.Y + WindSpeed.Y;
|
||||
}
|
||||
resetBitMap++;
|
||||
if (resetBitMap == 100000)
|
||||
{
|
||||
RainPosition.X = r.Next(700, 1300);
|
||||
RainPosition.Y = r.Next(700, 1300);
|
||||
resetBitMap = 0;
|
||||
}
|
||||
|
||||
if (Math.Round(RainPosition.X) == 1999 && WindSpeed.X > 0)
|
||||
RainPosition.X = 1;
|
||||
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;
|
||||
if (Math.Round(RainPosition.Y) == 1 && WindSpeed.Y < 0)
|
||||
RainPosition.Y = 1999 - Size.Y - 1;
|
||||
}
|
||||
|
||||
public void setNewHousePos(Vector2 pos, bool newState)
|
||||
@ -234,10 +253,21 @@ class Farm
|
||||
return holderIndex;
|
||||
}
|
||||
|
||||
public Color getRainAmount(int x, int y)
|
||||
public Color getRainAmount(int x, int y, Color color, Vector2 Size)
|
||||
{
|
||||
return Color.FromNonPremultiplied(255, 255, 255, (int)(255 * RainfallMap[x + (int)Math.Round(RainPosition.X)][y + (int)Math.Round(RainPosition.Y)].GetBrightness()));
|
||||
|
||||
Vector2 temp = new Vector2(x + (int)Math.Round(RainPosition.X), y + (int)Math.Round(RainPosition.Y));
|
||||
if (RainPosition.X >= 1999 - Size.X)
|
||||
temp.X = (Size.X) - (1999 - (int)Math.Round(RainPosition.X));
|
||||
if (RainPosition.Y >= 1999 - Size.Y)
|
||||
temp.Y = (Size.Y) - (1999 - (int)Math.Round(RainPosition.Y));
|
||||
if (RainfallMap[(int)temp.X][(int)temp.Y].GetBrightness() < 0.4f)
|
||||
{
|
||||
return Color.FromNonPremultiplied(color.R, color.G, color.B, (int)(0));
|
||||
}
|
||||
else
|
||||
{
|
||||
return Color.FromNonPremultiplied(color.R, color.G, color.B, (int)(255 * RainfallMap[(int)temp.X][(int)temp.Y].GetBrightness()));
|
||||
}
|
||||
}
|
||||
|
||||
public float getProductionRate(int x, int y, int Type)
|
||||
|
Loading…
Reference in New Issue
Block a user