evershade/Assets/Data/ScriptableObjects/Items/SeedItem.cs

40 lines
993 B
C#

using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "SeedItem", menuName = "Game Data/Seed")]
public class SeedItem : GameItem
{
public enum Season
{
Spring,
Summer,
Fall,
Winter
}
public CropItem crop;
public int growthTime;
public List<Season> growSeasons;
// set type on instantiation
public SeedItem()
{
type = ItemType.Seed;
}
public void Plant(Tile tile)
{
// checks if its the correct season to be plantable.
// checks if the tile is tilled and not occupied by another crop.
// sets the tile to be occupied by the crop.
// sets the crop to the correct growth stage.
Debug.Log("Planting seed");
var cropInteractable = CropManager.Instance.GetCropByName(crop.itemName);
cropInteractable.currentGrowthStage = 1;
cropInteractable.seedItem = this;
tile.SetInteractable(cropInteractable);
}
}