1
0
forked from s425077/PotatoPlan

ProductionRate

This commit is contained in:
Joel 2020-05-07 01:55:52 +02:00
parent a439485bf2
commit da7a7822d4
14 changed files with 220 additions and 59 deletions

View File

@ -68,6 +68,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 +92,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 +128,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 +188,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 +248,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

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[11];
private Texture2D tractor;
private Texture2D house;
private Texture2D markers;
@ -95,13 +95,23 @@ 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>("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");
Crops[2] = Content.Load<Texture2D>("BerriesIcon");
Crops[3] = Content.Load<Texture2D>("MaizeIcon");
Crops[4] = Content.Load<Texture2D>("MilletsIcon");
Crops[5] = Content.Load<Texture2D>("SeedOilIcon");
Crops[6] = Content.Load<Texture2D>("PaddyIcon");
Crops[7] = Content.Load<Texture2D>("PulsesIcon");
Crops[8] = Content.Load<Texture2D>("SugarcaneIcon");
Crops[9] = Content.Load<Texture2D>("TobaccoIcon");
Crops[10] = Content.Load<Texture2D>("WheatIcon");
ProgressionBar = Content.Load<Texture2D>("ProgressionBar");
ProgressionBarStatus = Content.Load<Texture2D>("ProgressionBarStatus");
@ -217,6 +227,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 +245,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

@ -13,21 +13,34 @@ class Crops
private int originalStatus;
private int cropType = 0;
private int Timer = 1;
private int UpdateCrop;
private int fullTimer;
private bool housePos = false;
private Vector2 Size;
private CropTypes DataSet;
SoilProperties soilProperties = new SoilProperties();
public void updateCrop(Vector2 newSize)
{
if (Status == 4 && Timer != 1)
if (Status == 3 && Timer != 1)
{
Timer--;
}
Size = newSize;
UpdateCrop++;
if (UpdateCrop == 60)
{
degradeSoil();
UpdateCrop = 0;
}
}
public SoilProperties getSoilProperties()
{
return soilProperties;
}
public int getCropTimer()
@ -47,8 +60,6 @@ class Crops
soilProperties.setSoilProperties();
}
// Changes the time required for the crops to be harvestable
public void setCropTimer()
{
@ -84,7 +95,7 @@ class Crops
{
return 8;
}
else if (Status == 3) //crops
else
{
if (cropType == 0)
{
@ -103,36 +114,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;
}
@ -176,6 +187,47 @@ class Crops
return housePos;
}
public float getProductionRate()
{
if (DataSet != null)
{
int ProductionRate = 100;
ProductionRate = (int)(ProductionRate * compareToDatset(soilProperties.Temperature, DataSet.Temparature));
ProductionRate = (int)(ProductionRate * compareToDatset(soilProperties.Moisture , DataSet.Moisture));
ProductionRate = (int)(ProductionRate * compareToDatset(soilProperties.Humidity , DataSet.Humidity));
ProductionRate = (int)(ProductionRate * compareToDatset(soilProperties.Phosphorous , DataSet.Phosphorous));
ProductionRate = (int)(ProductionRate * compareToDatset(soilProperties.Potassium , DataSet.Potassium));
ProductionRate = (int)(ProductionRate * compareToDatset(soilProperties.Nitrogen , DataSet.Nitrogen));
if (ProductionRate < 0)
{
return 0;
}
else
{
return ProductionRate;
}
}
else
{
return 0;
}
}
public float compareToDatset(float i, float j)
{
if (i < j)
{
return (i / j) * 0.2f;
}
else
{
return i / j;
}
}
public void Inspect(int tileSize, int Spacing, SpriteFont Bold, SpriteBatch spriteBatch, string[] cropTypesNames)
{
spriteBatch.Begin();
@ -196,17 +248,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);
}
@ -219,13 +267,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.Temparature, 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, soilProperties.Phosphorous.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, soilProperties.Potassium.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, soilProperties.Nitrogen.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, getProductionRate().ToString(), new Vector2(370, Size.Y * (tileSize + Spacing) + 282), Color.DarkBlue);
spriteBatch.End();
}
}

View File

@ -35,7 +35,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, 11);
crops[i, j].setCropType(x, PresetCrops.getPresetCropTypes(x));
crops[i, j].init();
}
}
@ -58,7 +59,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 +70,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();
}
}

View File

@ -11,12 +11,15 @@ class SoilProperties
public string soilType = "potato";
public float Temparature;
public float Temperature;
public float Humidity;
public float Moisture;
public float Nitrogen;
public float Potassium;
public float Phosphorous;
public float NitrogenDegradeRate = 0.001f;
public float PotassiumDegradeRate = 0.001f;
public float PhosphorousDegradeRate = 0.001f;
public void setSoilProperties()
{
@ -41,8 +44,8 @@ class SoilProperties
{
soilType = "Clayey";
}
Temparature = GetRandomNumber(22, 30);
Humidity = Temparature * 2 + GetRandomNumber(1.9, 2.2);
Temperature = GetRandomNumber(22, 30);
Humidity = Temperature * GetRandomNumber(1.9, 2.1);
Moisture = GetRandomNumber(20, 70);
Nitrogen = GetRandomNumber(4 , 55);
Potassium = GetRandomNumber(0, 28);

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)
{