2020-04-08 20:04:31 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Microsoft.Xna.Framework;
|
|
|
|
|
using Microsoft.Xna.Framework.Graphics;
|
2020-05-06 16:22:30 +02:00
|
|
|
|
using Microsoft.Xna.Framework.Input;
|
2020-04-08 20:04:31 +02:00
|
|
|
|
|
|
|
|
|
class Crops
|
|
|
|
|
{
|
2020-05-05 16:27:45 +02:00
|
|
|
|
private int Status;
|
|
|
|
|
private int originalStatus;
|
|
|
|
|
private int cropType = 0;
|
|
|
|
|
private int Timer = 1;
|
|
|
|
|
private int fullTimer;
|
|
|
|
|
private bool housePos = false;
|
2020-05-06 16:22:30 +02:00
|
|
|
|
private Vector2 Size;
|
|
|
|
|
SoilProperties soilProperties = new SoilProperties();
|
|
|
|
|
|
2020-05-03 13:05:05 +02:00
|
|
|
|
|
2020-04-08 20:04:31 +02:00
|
|
|
|
|
2020-05-06 16:22:30 +02:00
|
|
|
|
public void updateCrop(Vector2 newSize)
|
2020-04-08 20:04:31 +02:00
|
|
|
|
{
|
2020-05-06 16:22:30 +02:00
|
|
|
|
|
|
|
|
|
if (Status == 4 && Timer != 1)
|
|
|
|
|
{
|
2020-04-08 20:04:31 +02:00
|
|
|
|
Timer--;
|
2020-05-06 16:22:30 +02:00
|
|
|
|
}
|
|
|
|
|
Size = newSize;
|
2020-04-08 20:04:31 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getCropTimer()
|
|
|
|
|
{
|
|
|
|
|
return Timer;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-05 16:27:45 +02:00
|
|
|
|
public int getCropTimerBar(int tileSize)
|
|
|
|
|
{
|
2020-05-06 16:22:30 +02:00
|
|
|
|
|
|
|
|
|
int x = (int)((1 - ((float)Timer / fullTimer)) * (tileSize - tileSize / 3));
|
2020-05-05 16:27:45 +02:00
|
|
|
|
return x;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-06 16:22:30 +02:00
|
|
|
|
public void init()
|
|
|
|
|
{
|
|
|
|
|
soilProperties.setSoilProperties();
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-05 16:27:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Changes the time required for the crops to be harvestable
|
|
|
|
|
public void setCropTimer()
|
|
|
|
|
{
|
|
|
|
|
if (cropType == 0) // Carrots
|
|
|
|
|
{
|
|
|
|
|
Timer = 300;
|
|
|
|
|
fullTimer = Timer;
|
|
|
|
|
}
|
|
|
|
|
else if (cropType == 1) // Wheat
|
|
|
|
|
{
|
|
|
|
|
Timer = 600;
|
|
|
|
|
fullTimer = Timer;
|
|
|
|
|
}
|
|
|
|
|
else if (cropType == 2) // Berries
|
|
|
|
|
{
|
|
|
|
|
Timer = 1200;
|
|
|
|
|
fullTimer = Timer;
|
|
|
|
|
}
|
|
|
|
|
else // Fruit Trees
|
|
|
|
|
{
|
|
|
|
|
Timer = 2400;
|
|
|
|
|
fullTimer = Timer;
|
2020-05-06 16:22:30 +02:00
|
|
|
|
}
|
2020-05-05 16:27:45 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-03 13:05:05 +02:00
|
|
|
|
public int getCostOnMovement()
|
2020-04-08 20:04:31 +02:00
|
|
|
|
{
|
2020-05-04 01:50:43 +02:00
|
|
|
|
if (Status == 1) //grass
|
2020-05-03 13:05:05 +02:00
|
|
|
|
{
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2020-05-04 01:50:43 +02:00
|
|
|
|
else if (Status == 2) //dirt
|
2020-05-03 13:05:05 +02:00
|
|
|
|
{
|
2020-05-04 01:50:43 +02:00
|
|
|
|
return 8;
|
2020-05-03 13:05:05 +02:00
|
|
|
|
}
|
2020-05-04 01:50:43 +02:00
|
|
|
|
else if (Status == 3) //crops
|
2020-05-03 13:05:05 +02:00
|
|
|
|
{
|
2020-05-05 16:27:45 +02:00
|
|
|
|
if (cropType == 0)
|
|
|
|
|
{
|
|
|
|
|
return 15; //Carrots
|
|
|
|
|
}
|
|
|
|
|
else if (cropType == 1)
|
|
|
|
|
{
|
|
|
|
|
return 30; //Wheat
|
|
|
|
|
}
|
|
|
|
|
else if (cropType == 2)
|
|
|
|
|
{
|
|
|
|
|
return 40; //Berries
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return 50; //Fruit Trees
|
|
|
|
|
}
|
2020-05-03 13:05:05 +02:00
|
|
|
|
}
|
2020-05-05 16:27:45 +02:00
|
|
|
|
else //Harvestable Crops
|
2020-05-03 13:05:05 +02:00
|
|
|
|
{
|
2020-05-05 16:27:45 +02:00
|
|
|
|
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
|
|
|
|
|
}
|
2020-05-03 13:05:05 +02:00
|
|
|
|
}
|
2020-04-08 20:04:31 +02:00
|
|
|
|
}
|
2020-05-06 16:22:30 +02:00
|
|
|
|
|
2020-04-08 20:04:31 +02:00
|
|
|
|
|
2020-05-05 16:27:45 +02:00
|
|
|
|
public void setCropType(int Type)
|
2020-04-08 20:04:31 +02:00
|
|
|
|
{
|
2020-05-05 16:27:45 +02:00
|
|
|
|
cropType = Type;
|
2020-04-08 20:04:31 +02:00
|
|
|
|
}
|
2020-05-03 13:05:05 +02:00
|
|
|
|
|
2020-05-05 16:27:45 +02:00
|
|
|
|
public int getStatus()
|
|
|
|
|
{
|
|
|
|
|
if (Status != 4)
|
|
|
|
|
{
|
|
|
|
|
return Status;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return Status; // + cropType; When unique crop textures have been added
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getCropType()
|
|
|
|
|
{
|
|
|
|
|
return cropType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setStatus(int newStatus)
|
|
|
|
|
{
|
|
|
|
|
Status = newStatus;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setOriginalStatus()
|
|
|
|
|
{
|
|
|
|
|
originalStatus = Status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setHousePos(bool state)
|
|
|
|
|
{
|
|
|
|
|
housePos = state;
|
|
|
|
|
if (state)
|
|
|
|
|
{
|
|
|
|
|
Status = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Status = originalStatus;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool getHousePos()
|
2020-05-03 13:05:05 +02:00
|
|
|
|
{
|
2020-05-05 16:27:45 +02:00
|
|
|
|
return housePos;
|
2020-05-03 13:05:05 +02:00
|
|
|
|
}
|
2020-05-06 16:22:30 +02:00
|
|
|
|
|
|
|
|
|
public void Inspect(int tileSize, int Spacing, SpriteFont Bold, SpriteBatch spriteBatch, string[] cropTypesNames)
|
|
|
|
|
{
|
|
|
|
|
spriteBatch.Begin();
|
|
|
|
|
if (housePos)
|
|
|
|
|
{
|
|
|
|
|
spriteBatch.DrawString(Bold, "Tiletype: House", new Vector2(240, Size.Y * (tileSize + Spacing) + 42), Color.DarkBlue);
|
|
|
|
|
}
|
|
|
|
|
else if (Status == 0)
|
|
|
|
|
{
|
|
|
|
|
spriteBatch.DrawString(Bold, "Tiletype: Boulders", new Vector2(240, Size.Y * (tileSize + Spacing) + 42), Color.DarkBlue);
|
|
|
|
|
}
|
|
|
|
|
else if (Status == 1)
|
|
|
|
|
{
|
|
|
|
|
spriteBatch.DrawString(Bold, "Tiletype: Grassfield", new Vector2(240, Size.Y * (tileSize + Spacing) + 42), Color.DarkBlue);
|
|
|
|
|
}
|
|
|
|
|
else if (Status == 2)
|
|
|
|
|
{
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
spriteBatch.DrawString(Bold, "-------------", new Vector2(240, Size.Y * (tileSize + Spacing) + 82), Color.DarkRed);
|
|
|
|
|
}
|
|
|
|
|
if (Status > 1)
|
|
|
|
|
{
|
|
|
|
|
spriteBatch.DrawString(Bold, "Prefered Crop: " + cropTypesNames[cropType], new Vector2(240, Size.Y * (tileSize + Spacing) + 62), Color.DarkBlue);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
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);
|
2020-05-06 22:55:40 +02:00
|
|
|
|
spriteBatch.DrawString(Bold, "Temparature: " + soilProperties.Temperature, new Vector2(240, Size.Y * (tileSize + Spacing) + 162), Color.DarkBlue);
|
2020-05-06 16:22:30 +02:00
|
|
|
|
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.End();
|
|
|
|
|
}
|
2020-04-08 20:04:31 +02:00
|
|
|
|
}
|