Fixed tile speed
This commit is contained in:
parent
b083ae4293
commit
c17adf52cd
@ -184,7 +184,7 @@ class Crops
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return 10; //Tobacco
|
return 16; //Tobacco
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,8 @@ using System;
|
|||||||
class HandleRotation
|
class HandleRotation
|
||||||
{
|
{
|
||||||
int rotationSpeed = 5, Rotation = 180;
|
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)
|
public Vector2 UpdatePosition(int Destination, float tractorSpeed, Vector2 Position, Crops crops)
|
||||||
{
|
{
|
||||||
@ -17,7 +18,7 @@ class HandleRotation
|
|||||||
{
|
{
|
||||||
if (Rotation == 0)
|
if (Rotation == 0)
|
||||||
{
|
{
|
||||||
Direction = new Vector2(0, 1) * crops.getSpeedFactor(tractorSpeed);
|
Direction = new Vector2(0, 1) * movementSpeed;
|
||||||
Position = Position + Direction;
|
Position = Position + Direction;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -40,7 +41,7 @@ class HandleRotation
|
|||||||
{
|
{
|
||||||
if (Rotation == 180)
|
if (Rotation == 180)
|
||||||
{
|
{
|
||||||
Direction = new Vector2(0, -1) * crops.getSpeedFactor(tractorSpeed);
|
Direction = new Vector2(0, -1) * movementSpeed;
|
||||||
Position = Position + Direction;
|
Position = Position + Direction;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -60,7 +61,7 @@ class HandleRotation
|
|||||||
{
|
{
|
||||||
if (Rotation == 270)
|
if (Rotation == 270)
|
||||||
{
|
{
|
||||||
Direction = new Vector2(1, 0) * crops.getSpeedFactor(tractorSpeed);
|
Direction = new Vector2(1, 0) * movementSpeed;
|
||||||
Position = Position + Direction;
|
Position = Position + Direction;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -83,7 +84,7 @@ class HandleRotation
|
|||||||
{
|
{
|
||||||
if (Rotation == 90)
|
if (Rotation == 90)
|
||||||
{
|
{
|
||||||
Direction = new Vector2(-1, 0) * crops.getSpeedFactor(tractorSpeed);
|
Direction = new Vector2(-1, 0) * movementSpeed;
|
||||||
Position = Position + Direction;
|
Position = Position + Direction;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -111,4 +112,19 @@ class HandleRotation
|
|||||||
{
|
{
|
||||||
return Rotation;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ class Tractor
|
|||||||
private void updateDirection(Vector2 Size, Vector2 newPosition)
|
private void updateDirection(Vector2 Size, Vector2 newPosition)
|
||||||
{
|
{
|
||||||
DeltaPosition = TargetPosition - Position;
|
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)
|
if (DeltaPosition.X == 0)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user