2025-07-25 07:58:53 +00:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
namespace DDD
|
|
|
|
{
|
|
|
|
public class ItemViewModel
|
|
|
|
{
|
|
|
|
public string Id;
|
|
|
|
public ItemType ItemType;
|
|
|
|
public string NameKey;
|
|
|
|
public string DescriptionKey;
|
|
|
|
public Sprite Icon;
|
2025-07-27 19:32:41 +00:00
|
|
|
public int Count;
|
2025-07-25 07:58:53 +00:00
|
|
|
|
2025-07-27 19:32:41 +00:00
|
|
|
public RecipeType RecipeType => ItemType == ItemType.Recipe ? DataManager.Instance.RecipeDataSo.GetDataById(Id).RecipeType : RecipeType.None;
|
|
|
|
|
|
|
|
public void UpdateCount(int newCount)
|
2025-07-25 07:58:53 +00:00
|
|
|
{
|
2025-07-27 19:32:41 +00:00
|
|
|
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;
|
|
|
|
}
|
2025-07-25 07:58:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|