ProjectDDD/Assets/_DDD/_Scripts/GameUi/New/ItemViewModel.cs
2025-07-28 07:55:07 +09:00

65 lines
1.9 KiB
C#

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<TasteData> 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;
}
}
}
}