1
0
forked from s425077/PotatoPlan
This commit is contained in:
Joel 2020-05-23 20:55:45 +02:00
parent 4a786a166e
commit ba557d98f6
2 changed files with 12 additions and 6 deletions

View File

@ -44,7 +44,7 @@ namespace Game1
MouseState state; MouseState state;
private int cloudAnimationSpeed = 2; private int cloudAnimationSpeed = 3;
private int cloudFrame = 0; private int cloudFrame = 0;
private int cloudSprite; private int cloudSprite;
@ -326,7 +326,7 @@ namespace Game1
{ {
for (int j = -1; j < input.getSize().Y + 1; j++) for (int j = -1; j < input.getSize().Y + 1; j++)
{ {
spriteBatch.Draw(Rain, tractorUnit.getFarm().getRainPosition(input.getTileSize(), i, j), new Rectangle(0, cloudSprite * 96, input.getTileSize(), input.getTileSize()), Color.White); spriteBatch.Draw(Rain, tractorUnit.getFarm().getRainPosition(input.getTileSize(), i, j), new Rectangle(0, cloudSprite * 96, input.getTileSize(), input.getTileSize()), tractorUnit.getFarm().getRainAmount(i, j));
} }
} }
} }

View File

@ -15,7 +15,7 @@ class Farm
private Astar astar = new Astar(); private Astar astar = new Astar();
private PerlinNoise perlin = new PerlinNoise(); private PerlinNoise perlin = new PerlinNoise();
private Vector2 RainPosition; private Vector2 RainPosition;
private Vector2 WindSpeed; private Vector2 WindSpeed = new Vector2(0,0);
private System.Drawing.Color[][] RainfallMap; private System.Drawing.Color[][] RainfallMap;
private float[][] whiteNoise; private float[][] whiteNoise;
private float[][] perlinNoise; private float[][] perlinNoise;
@ -137,8 +137,9 @@ class Farm
private void updateRainMapPosition() private void updateRainMapPosition()
{ {
float x = WindSpeed.X + (float)r.Next(-5, 5) / 3000; float x, y;
float y = WindSpeed.Y + (float)r.Next(-5, 5) / 3000; x = WindSpeed.X + GetRandomNumber(-0.02, 0.02);
y = WindSpeed.Y + GetRandomNumber(-0.02, 0.02);
if (x < 0.02f && x > -0.02f) if (x < 0.02f && x > -0.02f)
{ {
@ -168,7 +169,7 @@ class Farm
RainPosition.Y = RainPosition.Y + WindSpeed.Y; RainPosition.Y = RainPosition.Y + WindSpeed.Y;
} }
resetBitMap++; resetBitMap++;
if (resetBitMap == 20000) if (resetBitMap == 100000)
{ {
RainPosition.X = r.Next(700, 1300); RainPosition.X = r.Next(700, 1300);
RainPosition.Y = r.Next(700, 1300); RainPosition.Y = r.Next(700, 1300);
@ -241,4 +242,9 @@ class Farm
{ {
return crops[x, y].getProductionRate(PresetCrops.getPresetCropTypes(Type)); return crops[x, y].getProductionRate(PresetCrops.getPresetCropTypes(Type));
} }
public float GetRandomNumber(double minimum, double maximum)
{
return (float)(Math.Round(r.NextDouble() * (maximum - minimum) + minimum, 2));
}
} }