merge Joel to dev

This commit is contained in:
BOTLester 2020-05-07 22:12:30 +02:00
commit 3e034cf958
20 changed files with 452 additions and 198 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -13,6 +13,18 @@
#---------------------------------- Content ---------------------------------#
#begin BarleyIcon.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:BarleyIcon.png
#begin BerriesIcon.png
/importer:TextureImporter
/processor:TextureProcessor
@ -37,6 +49,18 @@
/processorParam:TextureFormat=Color
/build:CarronIcon.png;CarrotIcon.png
#begin CottonIcon.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:CottonIcon.png
#begin Crop.png
/importer:TextureImporter
/processor:TextureProcessor
@ -56,6 +80,18 @@
/processorParam:TextureFormat=Compressed
/build:Font.spritefont
#begin GroundNutsIcon.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:GroundNutsIcon.png
#begin house.png
/importer:TextureImporter
/processor:TextureProcessor
@ -68,6 +104,18 @@
/processorParam:TextureFormat=Color
/build:house.png
#begin MaizeIcon.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:MaizeIcon.png
#begin Markers.png
/importer:TextureImporter
/processor:TextureProcessor
@ -80,6 +128,18 @@
/processorParam:TextureFormat=Color
/build:Markers.png
#begin MilletsIcon.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:MilletsIcon.png
#begin Mountain.png
/importer:TextureImporter
/processor:TextureProcessor
@ -104,6 +164,18 @@
/processorParam:TextureFormat=Color
/build:MouseCursor.png
#begin PaddyIcon.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:PaddyIcon.png
#begin Plantable.png
/importer:TextureImporter
/processor:TextureProcessor
@ -152,6 +224,42 @@
/processorParam:TextureFormat=Color
/build:ProgressionBarStatus.png
#begin PulsesIcon.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:PulsesIcon.png
#begin SeedOilIcon.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:SeedOilIcon.png
#begin SugarcaneIcon.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:SugarcaneIcon.png
#begin Tile.png
/importer:TextureImporter
/processor:TextureProcessor
@ -176,6 +284,18 @@
/processorParam:TextureFormat=Color
/build:tileunplantable.png
#begin TobaccoIcon.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:TobaccoIcon.png
#begin Tractor.png
/importer:TextureImporter
/processor:TextureProcessor

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
Game1/Content/MaizeIcon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
Game1/Content/PaddyIcon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 631 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 747 B

View File

@ -14,7 +14,7 @@ namespace Game1
SpriteBatch spriteBatch;
SpriteFont Bold;
private Texture2D[] tile = new Texture2D[5];
private Texture2D[] Crops = new Texture2D[5];
private Texture2D[] Crops = new Texture2D[12];
private Texture2D tractor;
private Texture2D house;
private Texture2D markers;
@ -50,17 +50,18 @@ namespace Game1
// TODO: Add your initialization logic here
base.Initialize();
cropTypesNames[0] = "Barley";
cropTypesNames[1] = "Cotton";
cropTypesNames[2] = "Ground Nuts";
cropTypesNames[3] = "Maize";
cropTypesNames[4] = "Millets";
cropTypesNames[5] = "Oil Seeds";
cropTypesNames[6] = "Paddy";
cropTypesNames[7] = "Pulses";
cropTypesNames[8] = "Sugarcane";
cropTypesNames[9] = "Tobacco";
cropTypesNames[10] = "Wheat";
cropTypesNames[0] = "None";
cropTypesNames[1] = "Barley";
cropTypesNames[2] = "Cotton";
cropTypesNames[3] = "Ground Nuts";
cropTypesNames[4] = "Maize";
cropTypesNames[5] = "Millets";
cropTypesNames[6] = "Oil Seeds";
cropTypesNames[7] = "Paddy";
cropTypesNames[8] = "Pulses";
cropTypesNames[9] = "Sugarcane";
cropTypesNames[10] = "Tobacco";
cropTypesNames[11] = "Wheat";
@ -95,13 +96,25 @@ namespace Game1
tile[0] = Content.Load<Texture2D>("Mountain");
tile[1] = Content.Load<Texture2D>("tileunplantable");
tile[2] = Content.Load<Texture2D>("Plantable");
tile[3] = Content.Load<Texture2D>("Planted");
tile[4] = Content.Load<Texture2D>("Crop");
tile[3] = Content.Load<Texture2D>("Crop");
Crops[0] = Content.Load<Texture2D>("Markers");
Crops[1] = Content.Load<Texture2D>("BarleyIcon");
Crops[2] = Content.Load<Texture2D>("CottonIcon");
Crops[3] = Content.Load<Texture2D>("GroundNutsIcon");
Crops[4] = Content.Load<Texture2D>("MaizeIcon");
Crops[5] = Content.Load<Texture2D>("MilletsIcon");
Crops[6] = Content.Load<Texture2D>("SeedOilIcon");
Crops[7] = Content.Load<Texture2D>("PaddyIcon");
Crops[8] = Content.Load<Texture2D>("PulsesIcon");
Crops[9] = Content.Load<Texture2D>("SugarcaneIcon");
Crops[10] = Content.Load<Texture2D>("TobaccoIcon");
Crops[11] = Content.Load<Texture2D>("WheatIcon");
Crops[0] = Content.Load<Texture2D>("CarrotIcon");
Crops[1] = Content.Load<Texture2D>("WheatIcon");
Crops[2] = Content.Load<Texture2D>("BerriesIcon"); //Replace 2 and 3 with the new crop Textures
Crops[3] = Content.Load<Texture2D>("TreePlantationIcon");
ProgressionBar = Content.Load<Texture2D>("ProgressionBar");
ProgressionBarStatus = Content.Load<Texture2D>("ProgressionBarStatus");
@ -217,6 +230,9 @@ namespace Game1
for (int j = 0; j < input.getSize().Y; j++)
{
Rectangle tilePos = new Rectangle(i * (input.getSpacingTile()), j * (input.getSpacingTile()), input.getTileSize(), input.getTileSize());
spriteBatch.Draw(tile[tractorUnit.getFarm().getCrop(i, j).getStatus()], tilePos, Time.GetTimeOfDay());
if (tilePos.Intersects(mousePosition))
{
@ -232,15 +248,22 @@ namespace Game1
x = i;
y = j;
}
if (tractorUnit.getFarm().getCrop(i, j).getStatus() != 0 && tractorUnit.getFarm().getCrop(i, j).getStatus() != 1)
{
spriteBatch.Draw(Crops[tractorUnit.getFarm().getCrop(i, j).getCropType()], new Rectangle(i * input.getSpacingTile(), j * input.getSpacingTile(), input.getTileSize(), input.getTileSize()), Color.White);
}
}
if ((tractorUnit.getFarm().getCrop(i, j).getStatus() == 4))
else
{
spriteBatch.Draw(ProgressionBar, new Rectangle(i * (input.getSpacingTile()) + input.getTileSize() - input.getTileSize() / 3, j * (input.getSpacingTile()), input.getTileSize() / 3, input.getTileSize()), Color.White);
spriteBatch.Draw(ProgressionBarStatus, new Rectangle(i * (input.getSpacingTile()) + input.getTileSize() - input.getTileSize() / 4, j * (input.getSpacingTile()) + input.getTileSize() / 3, input.getTileSize() / 4, tractorUnit.getFarm().getCrop(i, j).getCropTimerBar((input.getTileSize())) + 1), Color.White);
}
if (tractorUnit.getFarm().getCrop(i, j).getStatus() != 0 && tractorUnit.getFarm().getCrop(i, j).getStatus() != 1)
{
spriteBatch.Draw(Crops[tractorUnit.getFarm().getCrop(i, j).getCropType()], new Rectangle(i * (input.getSpacingTile()) + input.getTileSize() - input.getTileSize() / 3, j * (input.getSpacingTile()), input.getTileSize() / 3, input.getTileSize() / 3), Color.White);
if (tractorUnit.getFarm().getCrop(i, j).getStatus() != 0 && tractorUnit.getFarm().getCrop(i, j).getStatus() != 1)
{
if ((tractorUnit.getFarm().getCrop(i, j).getStatus() == 3))
{
spriteBatch.Draw(ProgressionBar, new Rectangle(i * (input.getSpacingTile()) + input.getTileSize() - input.getTileSize() / 3, j * (input.getSpacingTile()), input.getTileSize() / 3, input.getTileSize()), Color.White);
spriteBatch.Draw(ProgressionBarStatus, new Rectangle(i * (input.getSpacingTile()) + input.getTileSize() - input.getTileSize() / 4, j * (input.getSpacingTile()) + input.getTileSize() / 3, input.getTileSize() / 4, tractorUnit.getFarm().getCrop(i, j).getCropTimerBar((input.getTileSize())) + 1), Color.White);
}
spriteBatch.Draw(Crops[tractorUnit.getFarm().getCrop(i, j).getCropType()], new Rectangle((int)(i * (input.getSpacingTile()) + input.getTileSize() - input.getTileSize() / 2.5), j * (input.getSpacingTile()), (int)(input.getTileSize() / 2.5), input.getTileSize() / 3), Color.White);
}
}
}

View File

@ -59,7 +59,7 @@ class Controller
public int controllSpeed(int Speed)
{
KeyboardState state = Keyboard.GetState();
if (state.IsKeyDown(Keys.Right))
if (state.IsKeyDown(Keys.Right) && Speed < 350)
{
Speed++;
}

View File

@ -7,152 +7,164 @@ using System.Threading.Tasks;
class CropTypesHolder
{
private CropTypes[] cropTypes = new CropTypes[11];
private CropTypes[] cropTypes = new CropTypes[12];
public void init()
{
// Barley
// None
cropTypes[0] = new CropTypes();
cropTypes[0].soilType[0] = "Sandy";
cropTypes[0].soilType[0] = "None";
cropTypes[0].soilType[1] = null;
cropTypes[0].soilType[2] = null;
cropTypes[0].Temparature = 30.1f;
cropTypes[0].Humidity = 59.0f;
cropTypes[0].Moisture = 41.7f;
cropTypes[0].Nitrogen = 12.6f;
cropTypes[0].Potassium = 5.3f;
cropTypes[0].Phosphorous = 26.0f;
cropTypes[0].Temparature = 0f;
cropTypes[0].Humidity = 0f;
cropTypes[0].Moisture = 0f;
cropTypes[0].Nitrogen = 0f;
cropTypes[0].Potassium = 0f;
cropTypes[0].Phosphorous = 0f;
// Barley
cropTypes[1] = new CropTypes();
cropTypes[1].soilType[0] = "Sandy";
cropTypes[1].soilType[1] = null;
cropTypes[1].soilType[2] = null;
cropTypes[1].Temparature = 30.1f;
cropTypes[1].Humidity = 59.0f;
cropTypes[1].Moisture = 41.7f;
cropTypes[1].Nitrogen = 12.6f;
cropTypes[1].Potassium = 5.3f;
cropTypes[1].Phosphorous = 26.0f;
// Cotton
cropTypes[1] = new CropTypes();
cropTypes[1].soilType[0] = "Red";
cropTypes[1].Times[0] = 5;
cropTypes[1].soilType[1] = "Black";
cropTypes[1].Times[1] = 4;
cropTypes[1].soilType[2] = "Loamy";
cropTypes[1].Times[2] = 3;
cropTypes[1].Temparature = 30.4f;
cropTypes[1].Humidity = 59.6f;
cropTypes[1].Moisture = 63.2f;
cropTypes[1].Nitrogen = 16.4f;
cropTypes[1].Potassium = 3.3f;
cropTypes[1].Phosphorous = 23.8f;
// Ground Nuts
cropTypes[2] = new CropTypes();
cropTypes[2].soilType[0] = "Red";
cropTypes[2].soilType[1] = null;
cropTypes[2].soilType[2] = null;
cropTypes[2].Temparature = 30.1f;
cropTypes[2].Humidity = 59.1f;
cropTypes[2].Moisture = 33.1f;
cropTypes[2].Nitrogen = 23.3f;
cropTypes[2].Potassium = 2.0f;
cropTypes[2].Phosphorous = 21.6f;
cropTypes[2].Times[0] = 5;
cropTypes[2].soilType[1] = "Black";
cropTypes[2].Times[1] = 4;
cropTypes[2].soilType[2] = "Loamy";
cropTypes[2].Times[2] = 3;
cropTypes[2].Temparature = 30.4f;
cropTypes[2].Humidity = 59.6f;
cropTypes[2].Moisture = 63.2f;
cropTypes[2].Nitrogen = 16.4f;
cropTypes[2].Potassium = 3.3f;
cropTypes[2].Phosphorous = 23.8f;
// Ground Nuts
cropTypes[3] = new CropTypes();
cropTypes[3].soilType[0] = "Red";
cropTypes[3].soilType[1] = null;
cropTypes[3].soilType[2] = null;
cropTypes[3].Temparature = 30.1f;
cropTypes[3].Humidity = 59.1f;
cropTypes[3].Moisture = 33.1f;
cropTypes[3].Nitrogen = 23.3f;
cropTypes[3].Potassium = 2.0f;
cropTypes[3].Phosphorous = 21.6f;
// Maize
cropTypes[3] = new CropTypes();
cropTypes[3].soilType[0] = "Sandy";
cropTypes[3].soilType[1] = null;
cropTypes[3].soilType[2] = null;
cropTypes[3].Temparature = 29.0f;
cropTypes[3].Humidity = 57.3f;
cropTypes[3].Moisture = 42.2f;
cropTypes[3].Nitrogen = 18.3f;
cropTypes[3].Potassium = 5.7f;
cropTypes[3].Phosphorous = 18.7f;
// Millets
cropTypes[4] = new CropTypes();
cropTypes[4].soilType[0] = "Sandy";
cropTypes[4].Times[0] = 7;
cropTypes[4].soilType[1] = "Black";
cropTypes[4].Times[0] = 4;
cropTypes[4].soilType[1] = null;
cropTypes[4].soilType[2] = null;
cropTypes[4].Temparature = 29.5f;
cropTypes[4].Temparature = 29.0f;
cropTypes[4].Humidity = 57.3f;
cropTypes[4].Moisture = 38.5f;
cropTypes[4].Nitrogen = 23.2f;
cropTypes[4].Potassium = 0;
cropTypes[4].Phosphorous = 14.4f;
cropTypes[4].Moisture = 42.2f;
cropTypes[4].Nitrogen = 18.3f;
cropTypes[4].Potassium = 5.7f;
cropTypes[4].Phosphorous = 18.7f;
// Millets
cropTypes[5] = new CropTypes();
cropTypes[5].soilType[0] = "Sandy";
cropTypes[5].Times[0] = 7;
cropTypes[5].soilType[1] = "Black";
cropTypes[5].Times[0] = 4;
cropTypes[5].soilType[2] = null;
cropTypes[5].Temparature = 29.5f;
cropTypes[5].Humidity = 57.3f;
cropTypes[5].Moisture = 38.5f;
cropTypes[5].Nitrogen = 23.2f;
cropTypes[5].Potassium = 0.1f;
cropTypes[5].Phosphorous = 14.4f;
//Oil Seeds
cropTypes[5] = new CropTypes();
cropTypes[5].soilType[0] = "Black";
cropTypes[5].soilType[1] = null;
cropTypes[5].soilType[2] = null;
cropTypes[5].Temparature = 30.3f;
cropTypes[5].Humidity = 59.1f;
cropTypes[5].Moisture = 32.1f;
cropTypes[5].Nitrogen = 19.0f;
cropTypes[5].Potassium = 2.3f;
cropTypes[5].Phosphorous = 17.3f;
//Paddys
cropTypes[6] = new CropTypes();
cropTypes[6].soilType[0] = "Clayey";
cropTypes[6].soilType[0] = "Black";
cropTypes[6].soilType[1] = null;
cropTypes[6].soilType[2] = null;
cropTypes[6].Temparature = 31.2f;
cropTypes[6].Humidity = 60.4f;
cropTypes[6].Moisture = 41.5f;
cropTypes[6].Nitrogen = 20.8f;
cropTypes[6].Potassium = 3.7f;
cropTypes[6].Phosphorous = 16.3f;
cropTypes[6].Temparature = 30.3f;
cropTypes[6].Humidity = 59.1f;
cropTypes[6].Moisture = 32.1f;
cropTypes[6].Nitrogen = 19.0f;
cropTypes[6].Potassium = 2.3f;
cropTypes[6].Phosphorous = 17.3f;
//Pulses
//Paddys
cropTypes[7] = new CropTypes();
cropTypes[7].soilType[0] = "Clayey";
cropTypes[7].soilType[1] = null;
cropTypes[7].soilType[2] = null;
cropTypes[7].Temparature = 27.8f;
cropTypes[7].Humidity = 54.9f;
cropTypes[7].Moisture = 34.1f;
cropTypes[7].Nitrogen = 18.4f;
cropTypes[7].Potassium = 4.2f;
cropTypes[7].Phosphorous = 17.5f;
cropTypes[7].Temparature = 31.2f;
cropTypes[7].Humidity = 60.4f;
cropTypes[7].Moisture = 41.5f;
cropTypes[7].Nitrogen = 20.8f;
cropTypes[7].Potassium = 3.7f;
cropTypes[7].Phosphorous = 16.3f;
//Pulses
cropTypes[8] = new CropTypes();
cropTypes[8].soilType[0] = "Clayey";
cropTypes[8].soilType[1] = null;
cropTypes[8].soilType[2] = null;
cropTypes[8].Temparature = 27.8f;
cropTypes[8].Humidity = 54.9f;
cropTypes[8].Moisture = 34.1f;
cropTypes[8].Nitrogen = 18.4f;
cropTypes[8].Potassium = 4.2f;
cropTypes[8].Phosphorous = 17.5f;
//Sugarcane
cropTypes[8] = new CropTypes();
cropTypes[8].soilType[0] = "Loamy";
cropTypes[8].Times[0] = 9;
cropTypes[8].soilType[1] = "Black";
cropTypes[8].Times[0] = 4;
cropTypes[8].soilType[2] = null;
cropTypes[8].Temparature = 30.0f;
cropTypes[8].Humidity = 58.6f;
cropTypes[8].Moisture = 51.2f;
cropTypes[8].Nitrogen = 14.6f;
cropTypes[8].Potassium = 4.2f;
cropTypes[8].Phosphorous = 17.6f;
cropTypes[9] = new CropTypes();
cropTypes[9].soilType[0] = "Loamy";
cropTypes[9].Times[0] = 9;
cropTypes[9].soilType[1] = "Black";
cropTypes[9].Times[0] = 4;
cropTypes[9].soilType[2] = null;
cropTypes[9].Temparature = 30.0f;
cropTypes[9].Humidity = 58.6f;
cropTypes[9].Moisture = 51.2f;
cropTypes[9].Nitrogen = 14.6f;
cropTypes[9].Potassium = 4.2f;
cropTypes[9].Phosphorous = 17.6f;
//Tobacco
cropTypes[9] = new CropTypes();
cropTypes[9].soilType[0] = "Red";
cropTypes[9].soilType[1] = null;
cropTypes[9].soilType[2] = null;
cropTypes[9].Temparature = 31.9f;
cropTypes[9].Humidity = 62.4f;
cropTypes[9].Moisture = 31.6f;
cropTypes[9].Nitrogen = 19.1f;
cropTypes[9].Potassium = 4.9f;
cropTypes[9].Phosphorous = 19.3f;
cropTypes[10] = new CropTypes();
cropTypes[10].soilType[0] = "Red";
cropTypes[10].soilType[1] = null;
cropTypes[10].soilType[2] = null;
cropTypes[10].Temparature = 31.9f;
cropTypes[10].Humidity = 62.4f;
cropTypes[10].Moisture = 31.6f;
cropTypes[10].Nitrogen = 19.1f;
cropTypes[10].Potassium = 4.9f;
cropTypes[10].Phosphorous = 19.3f;
//Wheat
cropTypes[10] = new CropTypes();
cropTypes[10].soilType[0] = "Loamy";
cropTypes[10].soilType[1] = null;
cropTypes[10].soilType[2] = null;
cropTypes[10].Temparature = 33.1f;
cropTypes[10].Humidity = 63.8f;
cropTypes[10].Moisture = 50.0f;
cropTypes[10].Nitrogen = 23.3f;
cropTypes[10].Potassium = 2.9f;
cropTypes[10].Phosphorous = 14.4f;
cropTypes[11] = new CropTypes();
cropTypes[11].soilType[0] = "Loamy";
cropTypes[11].soilType[1] = null;
cropTypes[11].soilType[2] = null;
cropTypes[11].Temparature = 33.1f;
cropTypes[11].Humidity = 63.8f;
cropTypes[11].Moisture = 50.0f;
cropTypes[11].Nitrogen = 23.3f;
cropTypes[11].Potassium = 2.9f;
cropTypes[11].Phosphorous = 14.4f;
}

View File

@ -12,25 +12,45 @@ class Crops
private int Status;
private int originalStatus;
private int cropType = 0;
private int Timer = 1;
private int fullTimer;
private float Timer = 1;
private int UpdateCrop;
private float fullTimer;
private bool housePos = false;
private Vector2 Size;
private CropTypes DataSet;
SoilProperties soilProperties = new SoilProperties();
private float ProductionRate;
public void updateCrop(Vector2 newSize)
{
if (Status == 4 && Timer != 1)
getProductionRate(DataSet);
if (UpdateCrop == 60)
{
Timer--;
degradeSoil();
UpdateCrop = 0;
}
if (Status == 3 && Timer != 1)
{
Timer = Timer - 1f * ProductionRate;
}
Size = newSize;
UpdateCrop++;
if (Timer < 1)
{
Timer = 1;
}
}
public int getCropTimer()
public SoilProperties getSoilProperties()
{
return soilProperties;
}
public float getCropTimer()
{
return Timer;
}
@ -47,13 +67,6 @@ class Crops
soilProperties.setSoilProperties();
}
public SoilProperties getSoilProperties()
{
return soilProperties;
}
// Changes the time required for the crops to be harvestable
public void setCropTimer()
{
@ -89,7 +102,7 @@ class Crops
{
return 8;
}
else if (Status == 3) //crops
else
{
if (cropType == 0)
{
@ -108,36 +121,36 @@ class Crops
return 50; //Fruit Trees
}
}
else //Harvestable Crops
}
public void degradeSoil()
{
if (soilProperties.Nitrogen > 4.0f)
{
if (cropType == 0)
{
return 30; //Carrots
}
else if (cropType == 1)
{
return 40; //Wheat
}
else if (cropType == 2)
{
return 50; //Berries
}
else
{
return 100; //Fruit Trees
}
soilProperties.Nitrogen = soilProperties.Nitrogen - soilProperties.NitrogenDegradeRate;
}
if (soilProperties.Phosphorous > 0.1f)
{
soilProperties.Phosphorous = soilProperties.Phosphorous - soilProperties.PhosphorousDegradeRate;
}
if (soilProperties.Potassium > 0.1f)
{
soilProperties.Potassium = soilProperties.Potassium - soilProperties.PotassiumDegradeRate;
}
}
public void setCropType(int Type)
public void setCropType(int Type, CropTypes nCropType)
{
DataSet = nCropType;
cropType = Type;
}
public int getStatus()
{
if (Status != 4)
if (Status != 3)
{
return Status;
}
@ -181,6 +194,41 @@ class Crops
return housePos;
}
public float getProductionRate(CropTypes Sample)
{
ProductionRate = 1;
if (DataSet != null)
{
ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Temperature, Sample.Temparature));
ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Moisture, Sample.Moisture));
ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Humidity, Sample.Humidity));
ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Phosphorous, Sample.Phosphorous));
ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Potassium, Sample.Potassium));
ProductionRate = ProductionRate + (ProductionRate * compareToDatset(soilProperties.Nitrogen, Sample.Nitrogen));
if (ProductionRate < 0)
{
ProductionRate = 0;
}
ProductionRate = ProductionRate / 20;
}
return ProductionRate;
}
public float compareToDatset(float i, float j)
{
if (i < j)
{
return (i / j);
}
else
{
return (j / i);
}
}
public void Inspect(int tileSize, int Spacing, SpriteFont Bold, SpriteBatch spriteBatch, string[] cropTypesNames)
{
spriteBatch.Begin();
@ -201,17 +249,13 @@ class Crops
spriteBatch.DrawString(Bold, "Tiletype: Soil", new Vector2(240, Size.Y * (tileSize + Spacing) + 42), Color.DarkBlue);
}
else if (Status == 3)
{
spriteBatch.DrawString(Bold, "Tiletype: Planted", new Vector2(240, Size.Y * (tileSize + Spacing) + 42), Color.DarkBlue);
}
else if (Status == 4)
{
int x = (int)(((float)Timer / fullTimer) * 100);
x = 100 - x;
spriteBatch.DrawString(Bold, "Tiletype: Crop ", new Vector2(240, Size.Y * (tileSize + Spacing) + 42), Color.DarkBlue);
spriteBatch.DrawString(Bold, "Completion: " + x + "%", new Vector2(240, Size.Y * (tileSize + Spacing) + 82), Color.DarkBlue);
}
if (Status != 4)
if (Status != 3)
{
spriteBatch.DrawString(Bold, "-------------", new Vector2(240, Size.Y * (tileSize + Spacing) + 82), Color.DarkRed);
}
@ -224,13 +268,22 @@ class Crops
spriteBatch.DrawString(Bold, "None", new Vector2(240, Size.Y * (tileSize + Spacing) + 62), Color.DarkBlue);
}
spriteBatch.DrawString(Bold, "Soil Properties:", new Vector2(240, Size.Y * (tileSize + Spacing) + 122), Color.DarkRed);
spriteBatch.DrawString(Bold, "Soil Type: " + soilProperties.soilType, new Vector2(240, Size.Y * (tileSize + Spacing) + 142), Color.DarkBlue);
spriteBatch.DrawString(Bold, "Temparature: " + soilProperties.Temperature, new Vector2(240, Size.Y * (tileSize + Spacing) + 162), Color.DarkBlue);
spriteBatch.DrawString(Bold, "Moisture: " + soilProperties.Moisture, new Vector2(240, Size.Y * (tileSize + Spacing) + 182), Color.DarkBlue);
spriteBatch.DrawString(Bold, "Humidity: " + soilProperties.Humidity, new Vector2(240, Size.Y * (tileSize + Spacing) + 202), Color.DarkBlue);
spriteBatch.DrawString(Bold, "Phosphorous: " + soilProperties.Phosphorous, new Vector2(240, Size.Y * (tileSize + Spacing) + 222), Color.DarkBlue);
spriteBatch.DrawString(Bold, "Potassium: " + soilProperties.Potassium, new Vector2(240, Size.Y * (tileSize + Spacing) + 242), Color.DarkBlue);
spriteBatch.DrawString(Bold, "Nitrogen: " + soilProperties.Nitrogen, new Vector2(240, Size.Y * (tileSize + Spacing) + 262), Color.DarkBlue);
spriteBatch.DrawString(Bold, "Soil Type: ", new Vector2(240, Size.Y * (tileSize + Spacing) + 142), Color.DarkRed);
spriteBatch.DrawString(Bold, soilProperties.soilType, new Vector2(370, Size.Y * (tileSize + Spacing) + 142), Color.DarkBlue);
spriteBatch.DrawString(Bold, "Temparature: ", new Vector2(240, Size.Y * (tileSize + Spacing) + 162), Color.DarkRed);
spriteBatch.DrawString(Bold, soilProperties.Temperature.ToString(), new Vector2(370, Size.Y * (tileSize + Spacing) + 162), Color.DarkBlue);
spriteBatch.DrawString(Bold, "Moisture: ", new Vector2(240, Size.Y * (tileSize + Spacing) + 182), Color.DarkRed);
spriteBatch.DrawString(Bold, soilProperties.Moisture.ToString(), new Vector2(370, Size.Y * (tileSize + Spacing) + 182), Color.DarkBlue);
spriteBatch.DrawString(Bold, "Humidity: ", new Vector2(240, Size.Y * (tileSize + Spacing) + 202), Color.DarkRed);
spriteBatch.DrawString(Bold, soilProperties.Humidity.ToString(), new Vector2(370, Size.Y * (tileSize + Spacing) + 202), Color.DarkBlue);
spriteBatch.DrawString(Bold, "Phosphorous: ", new Vector2(240, Size.Y * (tileSize + Spacing) + 222), Color.DarkRed);
spriteBatch.DrawString(Bold, Math.Round(soilProperties.Phosphorous,1).ToString(), new Vector2(370, Size.Y * (tileSize + Spacing) + 222), Color.DarkBlue);
spriteBatch.DrawString(Bold, "Potassium: ", new Vector2(240, Size.Y * (tileSize + Spacing) + 242), Color.DarkRed);
spriteBatch.DrawString(Bold, Math.Round(soilProperties.Potassium, 1).ToString(), new Vector2(370, Size.Y * (tileSize + Spacing) + 242), Color.DarkBlue);
spriteBatch.DrawString(Bold, "Nitrogen: ", new Vector2(240, Size.Y * (tileSize + Spacing) + 262), Color.DarkRed);
spriteBatch.DrawString(Bold, Math.Round(soilProperties.Nitrogen, 1).ToString(), new Vector2(370, Size.Y * (tileSize + Spacing) + 262), Color.DarkBlue);
spriteBatch.DrawString(Bold, "Production Rate: ", new Vector2(240, Size.Y * (tileSize + Spacing) + 282), Color.DarkRed);
spriteBatch.DrawString(Bold, Math.Round((ProductionRate * 100), 1).ToString() + "%", new Vector2(370, Size.Y * (tileSize + Spacing) + 282), Color.DarkBlue);
spriteBatch.End();
}
}

View File

@ -11,6 +11,7 @@ class Farm
private Crops[,] crops;
private Random r;
private CropTypesHolder PresetCrops = new CropTypesHolder();
private int Update;
//initializes the crops
@ -19,9 +20,9 @@ class Farm
PresetCrops.init();
r = new Random();
crops = new Crops[100, 100];
for (int i = 0; i < Size.X; i++)
for (int i = 0; i < 99; i++)
{
for (int j = 0; j < Size.Y; j++)
for (int j = 0; j < 99; j++)
{
int x = r.Next(0, 3);
if (x == 0)
@ -35,7 +36,8 @@ class Farm
crops[i, j] = new Crops();
crops[i, j].setStatus(x);
crops[i, j].setOriginalStatus();
crops[i, j].setCropType(x = r.Next(0, 4));
x = r.Next(0, 12);
crops[i, j].setCropType(x, PresetCrops.getPresetCropTypes(x));
crops[i, j].init();
}
}
@ -43,14 +45,20 @@ class Farm
public void updateFarm(Vector2 Size)
{
for (int i = 0; i < Size.X; i++)
Update++;
if (Update == 30)
{
for (int j = 0; j < Size.Y; j++)
for (int i = 0; i < Size.X; i++)
{
for (int j = 0; j < Size.Y; j++)
{
crops[i, j].updateCrop(Size);
crops[i, j].updateCrop(Size);
}
}
Update = 0;
}
}
//Changes the properties of the tile when the tractor reaches this tile.
@ -58,7 +66,7 @@ class Farm
{
int x = (int)xfloat;
int y = (int)yfloat;
if (crops[x, y].getStatus() >= 4)
if (crops[x, y].getStatus() >= 3)
{
crops[x, y].setStatus(2);
}
@ -69,10 +77,6 @@ class Farm
else if (crops[x, y].getStatus() == 2)
{
crops[x, y].setStatus(3);
}
else if (crops[x, y].getStatus() == 3)
{
crops[x, y].setStatus(4);
crops[x, y].setCropTimer();
}
}
@ -94,6 +98,45 @@ class Farm
public CropTypes getPresetCropTypes(int Index)
{
return PresetCrops.getPresetCropTypes(Index);
return PresetCrops.getPresetCropTypes(Index - 1);
}
public void setCropType(int x, int y, int Type)
{
crops[x, y].setCropType(Type, PresetCrops.getPresetCropTypes(Type));
}
public void UpdatePreferedCrops(Vector2 Size)
{
for (int i = 0; i < Size.X; i++)
{
for (int j = 0; j < Size.X; j++)
{
int x = getHighestProductionRate(i, j);
crops[i,j].setCropType(x, PresetCrops.getPresetCropTypes(x));
}
}
}
private int getHighestProductionRate(int x, int y)
{
int i = 1, holderIndex = 0;
float holder = 0, SampleHolder = 0;
do
{
holder = getProductionRate(x, y, i);
if (SampleHolder < holder)
{
holderIndex = i;
SampleHolder = holder;
}
i++;
} while (i < 12);
return holderIndex;
}
public float getProductionRate(int x, int y, int Type)
{
return crops[x, y].getProductionRate(PresetCrops.getPresetCropTypes(Type));
}
}

View File

@ -17,6 +17,9 @@ class SoilProperties
public float Nitrogen;
public float Potassium;
public float Phosphorous;
public float NitrogenDegradeRate = 0.01f;
public float PotassiumDegradeRate = 0.01f;
public float PhosphorousDegradeRate = 0.01f;
public void setSoilProperties()
{
@ -45,8 +48,8 @@ class SoilProperties
Humidity = Temperature * GetRandomNumber(1.9, 2.1);
Moisture = GetRandomNumber(20, 70);
Nitrogen = GetRandomNumber(4 , 55);
Potassium = GetRandomNumber(0, 28);
Phosphorous = GetRandomNumber(0, 60);
Potassium = GetRandomNumber(0.01f, 28);
Phosphorous = GetRandomNumber(0.01f, 60);
}
public float GetRandomNumber(double minimum, double maximum)

View File

@ -12,7 +12,7 @@ class DayNightCycle
private int dayTime = 0;
private int lengthOfDay = 20000;
private int lengthOfNight = 20000;
private int Days;
private int Days = 1;
public void updateTime(int Speed)
{

View File

@ -32,9 +32,8 @@ class AI
inventory.addItem(7, 1);
inventory.addItem(7, 1);
inventory.addItem(10, 1);
inventory.addItem(10, 1);
inventory.addItem(10, 1);
inventory.useItem(10, 1);
}

View File

@ -17,6 +17,7 @@ class SmartTractor
public Path returnChoice()
{
ai.update(farm, Size, tractorPos / (tileSize + Spacing), housePos / (tileSize + Spacing), Target / (tileSize + Spacing), Rotation);
farm.UpdatePreferedCrops(Size);
farm = ai.changeCropStatus();
astar.update(farm.getCrops(), Size, tractorPos / (tileSize + Spacing), housePos / (tileSize + Spacing), Rotation);
getTargetPosition(ai.newTarget());