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 = "CropInteractable", menuName = "Game Data/Farming/Crop Interactable")] public class CropInteractable : Interactable { // crop item public CropItem cropItem; public int currentGrowthStage; // will need to change the sprite depending on the growth stage public Sprite[] growthSprites; public int growthStages; public bool isWatered; public bool lightRequirement; public SeedItem seedItem; // 1 = daily, 2 = every other day, 3 = every third day, etc. ? public float waterRequirement; // crop properties public int yield; public CropInteractable() { type = InteractableType.Crop; } 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 override void OnEnter2D(Collider2D collider) { Debug.Log("Crop OnEnter2D"); } public override void OnExit2D(Collider2D collider) { Debug.Log("Crop OnExit2D"); } public override void OnInteract() { Debug.Log("Crop OnInteract"); if (IsHarvestable()) // harvest crop Debug.Log("Harvesting crop"); } public override void Interact() { Debug.Log("Crop Interact"); // 0. check if its ready to be harvested. // 1. check to see if the player is in range to interact // 2. check to see if this crop requires a tool and // 2. check to see if the player has the correct tool equipped if required // if the tool is a pickaxe - destroy the crop // watering can - water the tile/crop if (IsHarvestable()) // harvest crop Debug.Log("Harvesting crop"); else Debug.Log("Crop is not ready to harvest"); } public void SetCropItem(CropItem item) { cropItem = item; } }