diff --git a/Game1/Content/Content.mgcb b/Game1/Content/Content.mgcb index 73c3ac3..c286d3c 100644 --- a/Game1/Content/Content.mgcb +++ b/Game1/Content/Content.mgcb @@ -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 diff --git a/Game1/Content/MaizeIcon.png b/Game1/Content/MaizeIcon.png new file mode 100644 index 0000000..65d19b7 Binary files /dev/null and b/Game1/Content/MaizeIcon.png differ diff --git a/Game1/Content/MilletsIcon.png b/Game1/Content/MilletsIcon.png new file mode 100644 index 0000000..30c4dcf Binary files /dev/null and b/Game1/Content/MilletsIcon.png differ diff --git a/Game1/Content/PaddyIcon.png b/Game1/Content/PaddyIcon.png new file mode 100644 index 0000000..cac6ba5 Binary files /dev/null and b/Game1/Content/PaddyIcon.png differ diff --git a/Game1/Content/PulsesIcon.png b/Game1/Content/PulsesIcon.png new file mode 100644 index 0000000..a6c9712 Binary files /dev/null and b/Game1/Content/PulsesIcon.png differ diff --git a/Game1/Content/SeedOilIcon.png b/Game1/Content/SeedOilIcon.png new file mode 100644 index 0000000..0ae6fb4 Binary files /dev/null and b/Game1/Content/SeedOilIcon.png differ diff --git a/Game1/Content/SugarcaneIcon.png b/Game1/Content/SugarcaneIcon.png new file mode 100644 index 0000000..e2f173b Binary files /dev/null and b/Game1/Content/SugarcaneIcon.png differ diff --git a/Game1/Content/TobaccoIcon.png b/Game1/Content/TobaccoIcon.png new file mode 100644 index 0000000..9a2b8df Binary files /dev/null and b/Game1/Content/TobaccoIcon.png differ diff --git a/Game1/Game1.cs b/Game1/Game1.cs index eb3a5f7..a1372d0 100644 --- a/Game1/Game1.cs +++ b/Game1/Game1.cs @@ -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("Mountain"); tile[1] = Content.Load("tileunplantable"); tile[2] = Content.Load("Plantable"); - tile[3] = Content.Load("Planted"); - tile[4] = Content.Load("Crop"); + tile[3] = Content.Load("Crop"); Crops[0] = Content.Load("CarrotIcon"); Crops[1] = Content.Load("WheatIcon"); - Crops[2] = Content.Load("BerriesIcon"); //Replace 2 and 3 with the new crop Textures - Crops[3] = Content.Load("TreePlantationIcon"); + Crops[2] = Content.Load("BerriesIcon"); + + + + Crops[3] = Content.Load("MaizeIcon"); + Crops[4] = Content.Load("MilletsIcon"); + Crops[5] = Content.Load("SeedOilIcon"); + Crops[6] = Content.Load("PaddyIcon"); + Crops[7] = Content.Load("PulsesIcon"); + Crops[8] = Content.Load("SugarcaneIcon"); + Crops[9] = Content.Load("TobaccoIcon"); + Crops[10] = Content.Load("WheatIcon"); + ProgressionBar = Content.Load("ProgressionBar"); ProgressionBarStatus = Content.Load("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); + } } } diff --git a/Game1/Sources/Controlls/Controller.cs b/Game1/Sources/Controlls/Controller.cs index 08817cf..7f6cce5 100644 --- a/Game1/Sources/Controlls/Controller.cs +++ b/Game1/Sources/Controlls/Controller.cs @@ -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++; } diff --git a/Game1/Sources/Crops/Crops.cs b/Game1/Sources/Crops/Crops.cs index 6230d6e..04e14b2 100644 --- a/Game1/Sources/Crops/Crops.cs +++ b/Game1/Sources/Crops/Crops.cs @@ -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(); } } diff --git a/Game1/Sources/Crops/Farm.cs b/Game1/Sources/Crops/Farm.cs index ed4b416..09d2d6d 100644 --- a/Game1/Sources/Crops/Farm.cs +++ b/Game1/Sources/Crops/Farm.cs @@ -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(); } } diff --git a/Game1/Sources/Crops/SoilProperties.cs b/Game1/Sources/Crops/SoilProperties.cs index 1149557..6b241e7 100644 --- a/Game1/Sources/Crops/SoilProperties.cs +++ b/Game1/Sources/Crops/SoilProperties.cs @@ -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); diff --git a/Game1/Sources/Objects/DayNightCycle.cs b/Game1/Sources/Objects/DayNightCycle.cs index e111ea1..2efaa29 100644 --- a/Game1/Sources/Objects/DayNightCycle.cs +++ b/Game1/Sources/Objects/DayNightCycle.cs @@ -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) {