From e4d2086bf9d1547a95e175c7afc753742602ce42 Mon Sep 17 00:00:00 2001 From: Joel Date: Sun, 10 May 2020 21:07:03 +0200 Subject: [PATCH] Fix --- Game1/Sources/Objects/HandleRotation.cs | 11 ++++++----- Game1/Sources/Objects/Tractor.cs | 2 +- Game1/Sources/Smart/SmartTractor.cs | 3 ++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Game1/Sources/Objects/HandleRotation.cs b/Game1/Sources/Objects/HandleRotation.cs index 2d11dde..404a4a2 100644 --- a/Game1/Sources/Objects/HandleRotation.cs +++ b/Game1/Sources/Objects/HandleRotation.cs @@ -5,7 +5,7 @@ class HandleRotation { int rotationSpeed = 5, Rotation = 180; private float oldSpeed, movementSpeed; - private Vector2 oldTile; + private Vector2 oldTile, oldPosition; public Vector2 UpdatePosition(int Destination, float tractorSpeed, Vector2 Position, Crops crops) { @@ -14,7 +14,7 @@ class HandleRotation { Position = new Vector2((int)Math.Round(Position.X), (int)Math.Round(Position.Y)); } - if (Destination == 0) + if (Destination == 0) // down { if (Rotation == 0) { @@ -37,7 +37,7 @@ class HandleRotation } } } - else if (Destination == 1) + else if (Destination == 1) // up { if (Rotation == 180) { @@ -57,7 +57,7 @@ class HandleRotation } } - else if (Destination == 2) + else if (Destination == 2) // right { if (Rotation == 270) { @@ -80,7 +80,7 @@ class HandleRotation } } } - else if (Destination == 3) + else if (Destination == 3) // left { if (Rotation == 90) { @@ -105,6 +105,7 @@ class HandleRotation } oldSpeed = crops.getSpeedFactor(tractorSpeed); + oldPosition = Position; return Position; } diff --git a/Game1/Sources/Objects/Tractor.cs b/Game1/Sources/Objects/Tractor.cs index 86c9ac1..66fa73d 100644 --- a/Game1/Sources/Objects/Tractor.cs +++ b/Game1/Sources/Objects/Tractor.cs @@ -32,7 +32,7 @@ class Tractor Spacing = input.getSpacing(); Position = housePos; TargetPosition = new Vector2(house.X, house.Y); - smartTractor.init(); + smartTractor.init(new Vector2(house.X, house.Y)); } // Runs when the tractor reaches a tile diff --git a/Game1/Sources/Smart/SmartTractor.cs b/Game1/Sources/Smart/SmartTractor.cs index 4524778..d111af2 100644 --- a/Game1/Sources/Smart/SmartTractor.cs +++ b/Game1/Sources/Smart/SmartTractor.cs @@ -46,9 +46,10 @@ class SmartTractor } - public void init() + public void init(Vector2 nHousePos) { ai.init(); + housePos = nHousePos; farm.init(new Vector2(100, (GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height / tileSize) - 125 / tileSize), housePos / (tileSize + Spacing)); }