diff --git a/Game1/Sources/Crops/Crops.cs b/Game1/Sources/Crops/Crops.cs index 1dba4d6..b89a402 100644 --- a/Game1/Sources/Crops/Crops.cs +++ b/Game1/Sources/Crops/Crops.cs @@ -184,7 +184,7 @@ class Crops } else { - return 10; //Tobacco + return 16; //Tobacco } } } diff --git a/Game1/Sources/Objects/HandleRotation.cs b/Game1/Sources/Objects/HandleRotation.cs index 3cadd22..2d11dde 100644 --- a/Game1/Sources/Objects/HandleRotation.cs +++ b/Game1/Sources/Objects/HandleRotation.cs @@ -4,7 +4,8 @@ using System; class HandleRotation { int rotationSpeed = 5, Rotation = 180; - private float oldSpeed; + private float oldSpeed, movementSpeed; + private Vector2 oldTile; public Vector2 UpdatePosition(int Destination, float tractorSpeed, Vector2 Position, Crops crops) { @@ -17,7 +18,7 @@ class HandleRotation { if (Rotation == 0) { - Direction = new Vector2(0, 1) * crops.getSpeedFactor(tractorSpeed); + Direction = new Vector2(0, 1) * movementSpeed; Position = Position + Direction; } else @@ -40,7 +41,7 @@ class HandleRotation { if (Rotation == 180) { - Direction = new Vector2(0, -1) * crops.getSpeedFactor(tractorSpeed); + Direction = new Vector2(0, -1) * movementSpeed; Position = Position + Direction; } else @@ -60,7 +61,7 @@ class HandleRotation { if (Rotation == 270) { - Direction = new Vector2(1, 0) * crops.getSpeedFactor(tractorSpeed); + Direction = new Vector2(1, 0) * movementSpeed; Position = Position + Direction; } else @@ -83,7 +84,7 @@ class HandleRotation { if (Rotation == 90) { - Direction = new Vector2(-1, 0) * crops.getSpeedFactor(tractorSpeed); + Direction = new Vector2(-1, 0) * movementSpeed; Position = Position + Direction; } else @@ -111,4 +112,19 @@ class HandleRotation { return Rotation; } + + public bool checkTile(Vector2 Position, int tileSize, int Spacing, float tractorSpeed, Crops crop) + { + Vector2 newTile = new Vector2((float)Math.Round(Position.X / (tileSize + Spacing)), (float)Math.Round(Position.Y / (tileSize + Spacing))); + if (oldTile != newTile) + { + oldTile = newTile; + movementSpeed = crop.getSpeedFactor(tractorSpeed); + return true; + } + else + { + return false; + } + } } diff --git a/Game1/Sources/Objects/Tractor.cs b/Game1/Sources/Objects/Tractor.cs index f2768a3..86c9ac1 100644 --- a/Game1/Sources/Objects/Tractor.cs +++ b/Game1/Sources/Objects/Tractor.cs @@ -39,7 +39,7 @@ class Tractor private void updateDirection(Vector2 Size, Vector2 newPosition) { DeltaPosition = TargetPosition - Position; - + handleRotation.checkTile(Position, sizeTile, Spacing, tractorSpeed, smartTractor.getFarm().getCrop((int)Math.Round(Position.X / (sizeTile + Spacing)), (int)Math.Round(Position.Y / (sizeTile + Spacing)))); if (DeltaPosition.X == 0) {