PotatoPlan/Game1/Sources/Crops/Crops.cs
2020-05-05 16:27:45 +02:00

165 lines
3.2 KiB
C#

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;
class Crops
{
private int Status;
private int originalStatus;
private int cropType = 0;
private int Timer = 1;
private int fullTimer;
private bool housePos = false;
public void updateCrop()
{
Timer--;
}
public int getCropTimer()
{
return Timer;
}
public int getCropTimerBar(int tileSize)
{
int x = (int)(( 1 - ((float)Timer / fullTimer)) * (tileSize - tileSize / 3));
return x;
}
// 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;
}
}
public int getCostOnMovement()
{
if (Status == 1) //grass
{
return 1;
}
else if (Status == 2) //dirt
{
return 8;
}
else if (Status == 3) //crops
{
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
}
}
else //Harvestable Crops
{
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
}
}
}
public void setCropType(int Type)
{
cropType = Type;
}
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()
{
return housePos;
}
}