Somewhat finished
This commit is contained in:
parent
f39f27ba4e
commit
913f813895
@ -45,6 +45,11 @@ class Crops
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float getSpeedFactor(float tractorSpeed)
|
||||||
|
{
|
||||||
|
return 1f / getCostOnMovement();
|
||||||
|
}
|
||||||
|
|
||||||
public SoilProperties getSoilProperties()
|
public SoilProperties getSoilProperties()
|
||||||
{
|
{
|
||||||
return soilProperties;
|
return soilProperties;
|
||||||
@ -103,7 +108,7 @@ class Crops
|
|||||||
// Changes the time required for the crops to be harvestable
|
// Changes the time required for the crops to be harvestable
|
||||||
public void setCropTimer()
|
public void setCropTimer()
|
||||||
{
|
{
|
||||||
if (cropType == 0) // Carrots
|
if (cropType == 1) // Barley
|
||||||
{
|
{
|
||||||
Timer = 300;
|
Timer = 300;
|
||||||
fullTimer = Timer;
|
fullTimer = Timer;
|
||||||
@ -133,25 +138,53 @@ class Crops
|
|||||||
}
|
}
|
||||||
else if (Status == 2) //dirt
|
else if (Status == 2) //dirt
|
||||||
{
|
{
|
||||||
return 16;
|
return 8;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (cropType == 0)
|
if (cropType == 1)
|
||||||
{
|
{
|
||||||
return 15; //Carrots
|
return 16; //Barley
|
||||||
}
|
|
||||||
else if (cropType == 1)
|
|
||||||
{
|
|
||||||
return 30; //Wheat
|
|
||||||
}
|
}
|
||||||
else if (cropType == 2)
|
else if (cropType == 2)
|
||||||
{
|
{
|
||||||
return 40; //Berries
|
return 16; //Cotton
|
||||||
|
}
|
||||||
|
else if (cropType == 3)
|
||||||
|
{
|
||||||
|
return 16; //Ground Nuts
|
||||||
|
}
|
||||||
|
else if (cropType == 4)
|
||||||
|
{
|
||||||
|
return 16; //Maize
|
||||||
|
}
|
||||||
|
else if (cropType == 5)
|
||||||
|
{
|
||||||
|
return 16; //Millets
|
||||||
|
}
|
||||||
|
else if (cropType == 6)
|
||||||
|
{
|
||||||
|
return 16; //Oil Seeds
|
||||||
|
}
|
||||||
|
else if (cropType == 7)
|
||||||
|
{
|
||||||
|
return 16; //Paddy
|
||||||
|
}
|
||||||
|
else if (cropType == 8)
|
||||||
|
{
|
||||||
|
return 16; //Pulses
|
||||||
|
}
|
||||||
|
else if (cropType == 9)
|
||||||
|
{
|
||||||
|
return 16; //Sugarcane
|
||||||
|
}
|
||||||
|
else if (cropType == 10)
|
||||||
|
{
|
||||||
|
return 16; //Wheat
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return 50; //Fruit Trees
|
return 10; //Tobacco
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,9 +112,12 @@ class Farm
|
|||||||
for (int i = 0; i < Size.X; i++)
|
for (int i = 0; i < Size.X; i++)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < Size.X; j++)
|
for (int j = 0; j < Size.X; j++)
|
||||||
|
{
|
||||||
|
if (crops[i, j].getStatus() != 3)
|
||||||
{
|
{
|
||||||
int x = getHighestProductionRate(i, j);
|
int x = getHighestProductionRate(i, j);
|
||||||
crops[i,j].setCropType(x, PresetCrops.getPresetCropTypes(x));
|
crops[i, j].setCropType(x, PresetCrops.getPresetCropTypes(x));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,23 @@
|
|||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
|
using System;
|
||||||
|
|
||||||
class HandleRotation
|
class HandleRotation
|
||||||
{
|
{
|
||||||
int rotationSpeed = 5, Rotation = 180;
|
int rotationSpeed = 5, Rotation = 180;
|
||||||
|
private float oldSpeed;
|
||||||
|
|
||||||
public Vector2 UpdatePosition(int Destination, float tractorSpeed, Vector2 Position)
|
public Vector2 UpdatePosition(int Destination, float tractorSpeed, Vector2 Position, Crops crops)
|
||||||
{
|
{
|
||||||
Vector2 Direction;
|
Vector2 Direction;
|
||||||
|
if (oldSpeed != crops.getSpeedFactor(tractorSpeed))
|
||||||
|
{
|
||||||
|
Position = new Vector2((int)Math.Round(Position.X), (int)Math.Round(Position.Y));
|
||||||
|
}
|
||||||
if (Destination == 0)
|
if (Destination == 0)
|
||||||
{
|
{
|
||||||
if (Rotation == 0)
|
if (Rotation == 0)
|
||||||
{
|
{
|
||||||
Direction = new Vector2(0, 1) * tractorSpeed;
|
Direction = new Vector2(0, 1) * crops.getSpeedFactor(tractorSpeed);
|
||||||
Position = Position + Direction;
|
Position = Position + Direction;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -34,7 +40,7 @@ class HandleRotation
|
|||||||
{
|
{
|
||||||
if (Rotation == 180)
|
if (Rotation == 180)
|
||||||
{
|
{
|
||||||
Direction = new Vector2(0, -1) * tractorSpeed;
|
Direction = new Vector2(0, -1) * crops.getSpeedFactor(tractorSpeed);
|
||||||
Position = Position + Direction;
|
Position = Position + Direction;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -54,7 +60,7 @@ class HandleRotation
|
|||||||
{
|
{
|
||||||
if (Rotation == 270)
|
if (Rotation == 270)
|
||||||
{
|
{
|
||||||
Direction = new Vector2(1, 0) * tractorSpeed;
|
Direction = new Vector2(1, 0) * crops.getSpeedFactor(tractorSpeed);
|
||||||
Position = Position + Direction;
|
Position = Position + Direction;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -77,7 +83,7 @@ class HandleRotation
|
|||||||
{
|
{
|
||||||
if (Rotation == 90)
|
if (Rotation == 90)
|
||||||
{
|
{
|
||||||
Direction = new Vector2(-1, 0) * tractorSpeed;
|
Direction = new Vector2(-1, 0) * crops.getSpeedFactor(tractorSpeed);
|
||||||
Position = Position + Direction;
|
Position = Position + Direction;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -97,6 +103,7 @@ class HandleRotation
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
oldSpeed = crops.getSpeedFactor(tractorSpeed);
|
||||||
return Position;
|
return Position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using System;
|
||||||
|
|
||||||
class Tractor
|
class Tractor
|
||||||
{
|
{
|
||||||
private int Spacing, sizeTile, Speed = 1;
|
private int Spacing, sizeTile, Speed = 1;
|
||||||
private float tractorSpeed = 1;
|
private float tractorSpeed = 1;
|
||||||
private Vector2 Position, TargetPosition, Size, housePos;
|
private Vector2 Position, TargetPosition, Size, housePos, oldDeltaPosition, DeltaPosition;
|
||||||
private Path path = new Path();
|
private Path path = new Path();
|
||||||
private SmartTractor smartTractor = new SmartTractor();
|
private SmartTractor smartTractor = new SmartTractor();
|
||||||
private HandleRotation handleRotation = new HandleRotation();
|
private HandleRotation handleRotation = new HandleRotation();
|
||||||
@ -22,6 +23,7 @@ class Tractor
|
|||||||
updatePosition(input.getSize(), Status);
|
updatePosition(input.getSize(), Status);
|
||||||
housePos = newHousePos;
|
housePos = newHousePos;
|
||||||
smartTractor.UpdateCrops(Speed);
|
smartTractor.UpdateCrops(Speed);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(Rectangle house, Input input)
|
public void init(Rectangle house, Input input)
|
||||||
@ -36,7 +38,8 @@ class Tractor
|
|||||||
// Runs when the tractor reaches a tile
|
// Runs when the tractor reaches a tile
|
||||||
private void updateDirection(Vector2 Size, Vector2 newPosition)
|
private void updateDirection(Vector2 Size, Vector2 newPosition)
|
||||||
{
|
{
|
||||||
Vector2 DeltaPosition = TargetPosition - Position;
|
DeltaPosition = TargetPosition - Position;
|
||||||
|
|
||||||
|
|
||||||
if (DeltaPosition.X == 0)
|
if (DeltaPosition.X == 0)
|
||||||
{
|
{
|
||||||
@ -46,23 +49,24 @@ class Tractor
|
|||||||
}
|
}
|
||||||
else if (DeltaPosition.Y > 0)
|
else if (DeltaPosition.Y > 0)
|
||||||
{
|
{
|
||||||
Position = handleRotation.UpdatePosition(0, tractorSpeed, Position);
|
Position = handleRotation.UpdatePosition(0, tractorSpeed, Position, smartTractor.getFarm().getCrop((int)Math.Round(Position.X / (sizeTile + Spacing)), (int)Math.Round(Position.Y / (sizeTile + Spacing))));
|
||||||
}
|
}
|
||||||
else if (DeltaPosition.Y < 0)
|
else if (DeltaPosition.Y < 0)
|
||||||
{
|
{
|
||||||
Position = handleRotation.UpdatePosition(1, tractorSpeed, Position);
|
Position = handleRotation.UpdatePosition(1, tractorSpeed, Position, smartTractor.getFarm().getCrop((int)Math.Round(Position.X / (sizeTile + Spacing)), (int)Math.Round(Position.Y / (sizeTile + Spacing))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (DeltaPosition.X > 0)
|
else if (DeltaPosition.X > 0)
|
||||||
{
|
{
|
||||||
Position = handleRotation.UpdatePosition(2, tractorSpeed, Position);
|
Position = handleRotation.UpdatePosition(2, tractorSpeed, Position, smartTractor.getFarm().getCrop((int)Math.Round(Position.X / (sizeTile + Spacing)), (int)Math.Round(Position.Y / (sizeTile + Spacing))));
|
||||||
}
|
}
|
||||||
else if (DeltaPosition.X < 0)
|
else if (DeltaPosition.X < 0)
|
||||||
{
|
{
|
||||||
Position = handleRotation.UpdatePosition(3, tractorSpeed, Position);
|
Position = handleRotation.UpdatePosition(3, tractorSpeed, Position, smartTractor.getFarm().getCrop((int)Math.Round(Position.X / (sizeTile + Spacing)), (int)Math.Round(Position.Y / (sizeTile + Spacing))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void updatePosition(Vector2 Size, int Status) // updates the position
|
public void updatePosition(Vector2 Size, int Status) // updates the position
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user