using Managers; using UnityEngine; namespace Components { public class CropComponent : MonoBehaviour { // Crop properties public Crop crop; // Crop state public int isWatered; private SpriteRenderer _spriteRenderer; public void Awake() { _spriteRenderer = GetComponent(); } // Crop methods public void Grow() { // Grow the crop } public void Harvest() { // Harvest the crop Debug.Log("Harvesting Crop:" + crop.cropItem.itemName); // add crop to inventory var item = crop.cropItem; PlayerManager.Instance.AddItemToInventorySlot(item); // remove crop from tile crop = null; // delete visual Destroy(gameObject); } public void Water() { // Water the crop Debug.Log("Watering Crop"); crop.isWatered = true; } public bool isHarvestable() { // if crop has no values return crop.isHarvestable(); } public bool isToolRequired() { // if crop has no values if (crop.validToolTypes == null || crop.validToolTypes.Count == 0) return false; return true; } public void SetCrop(Crop tileCrop) { crop = tileCrop; // change the crop sprite // change the crop material if (_spriteRenderer != null && crop != null) { Debug.Log("CROP: SetCrop: " + crop.name + " Growth Stage: " + crop.currentGrowthStage); _spriteRenderer.sprite = crop.growthSprites[crop.currentGrowthStage - 1]; } } } }