61 lines
1.6 KiB
C#
61 lines
1.6 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
// This is a base class for all crops in the game. It is for the actual crop in the ground.
|
|
// It is not for the seeds that are planted or the harvested crops. (CropItem)
|
|
[CreateAssetMenu(fileName = "Crop", menuName = "Game Data/Farming/Crop")]
|
|
public class Crop : ScriptableObject
|
|
{
|
|
// crop item
|
|
public CropItem cropItem;
|
|
|
|
// seed item
|
|
public SeedItem seedItem;
|
|
|
|
// crop properties
|
|
public int yield;
|
|
public int experience;
|
|
public int growthStages;
|
|
public int currentGrowthStage;
|
|
|
|
public bool isWatered;
|
|
|
|
// 1 = daily, 2 = every other day, 3 = every third day, etc. ?
|
|
public float waterRequirement;
|
|
|
|
public bool lightRequirement;
|
|
|
|
// null = no tool required
|
|
public List<ToolItem.ToolType> validToolTypes;
|
|
|
|
// will need to change the sprite depending on the growth stage
|
|
public Sprite[] growthSprites;
|
|
|
|
public bool IsToolRequired()
|
|
{
|
|
// if crop has no values
|
|
if (validToolTypes == null)
|
|
return false;
|
|
|
|
// also if one of the valid tool types is none then we dont need a tool
|
|
return !validToolTypes.Contains(ToolItem.ToolType.None);
|
|
}
|
|
|
|
public bool isHarvestable()
|
|
{
|
|
// if crop has no values
|
|
if (currentGrowthStage < growthStages)
|
|
{
|
|
Debug.Log("Crop is not ready to harvest");
|
|
return false;
|
|
}
|
|
|
|
Debug.Log("Crop is ready to harvest");
|
|
return true;
|
|
}
|
|
|
|
public void setCropItem(GameItem randomCropItem)
|
|
{
|
|
cropItem = (CropItem)randomCropItem;
|
|
}
|
|
} |