38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
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;
|
|
}
|
|
}
|
|
}
|
|
} |