using System.Collections.Generic; using UnityEngine; namespace DDD { public class ItemViewModel { public string Id; public ItemType ItemType; public string NameKey; public string DescriptionKey; public Sprite Icon; public int Count; public RecipeType RecipeType => ItemType == ItemType.Recipe ? DataManager.Instance.RecipeDataSo.GetDataById(Id).RecipeType : RecipeType.None; public void UpdateCount(int newCount) { if (ItemType == ItemType.Recipe) { int craftableCount = 0; if (RecipeType == RecipeType.FoodRecipe) { craftableCount = DataManager.Instance.FoodDataSo.GetDataById(Id).GetCraftableCount(); } else if (RecipeType == RecipeType.DrinkRecipe) { craftableCount = DataManager.Instance.DrinkDataSo.GetDataById(Id).GetCraftableCount(); } Count = craftableCount; } else if (ItemType == ItemType.Ingredient) { Count = newCount; } } public string GetItemKey { get { if (ItemType != ItemType.Recipe) return null; return DataManager.Instance.RecipeDataSo.GetDataById(Id).ItemKey; } } public List GetTasteDatas { get { switch (RecipeType) { case RecipeType.FoodRecipe: return DataManager.Instance.FoodDataSo.GetDataById(GetItemKey).GetTasteDatas(); case RecipeType.DrinkRecipe: return DataManager.Instance.DrinkDataSo.GetDataById(GetItemKey).GetTasteDatas(); } return null; } } } }