ProjectDDD/Assets/_DDD/_Scripts/GameUi/RestaurantManagementUi/TodayMenuUi/TodayMenuSlotUiStrategy.cs

62 lines
2.1 KiB
C#
Raw Normal View History

2025-07-29 18:18:16 +00:00
using System.Threading.Tasks;
using UnityEngine;
namespace DDD
2025-07-29 15:56:47 +00:00
{
public class TodayMenuSlotUiStrategy : IItemSlotUiStrategy
{
private readonly RecipeType _recipeType;
private RestaurantManagementSo _restaurantManagementSo;
2025-07-29 18:18:16 +00:00
public string AnimatorControllerKey => "TodayMenuSlotUi";
2025-07-29 15:56:47 +00:00
public TodayMenuSlotUiStrategy(RecipeType recipeType)
{
_recipeType = recipeType;
}
public async Task Setup(ItemSlotUi ui, ItemViewModel model)
2025-07-29 15:56:47 +00:00
{
_restaurantManagementSo = await AssetManager.LoadAsset<RestaurantManagementSo>(DataConstants.RestaurantManagementSo);
2025-07-29 15:56:47 +00:00
if (model == null)
{
string emptySpriteKey = null;
if (_recipeType == RecipeType.FoodRecipe)
{
emptySpriteKey = SpriteConstants.EmptyFoodSpriteKey;
}
else if (_recipeType == RecipeType.DrinkRecipe)
{
emptySpriteKey = SpriteConstants.EmptyDrinkSpriteKey;
}
2025-07-29 20:57:19 +00:00
2025-07-29 15:56:47 +00:00
ui.SetIcon(DataManager.Instance.GetSprite(emptySpriteKey));
2025-08-03 23:09:01 +00:00
ui.HideCountText();
2025-07-29 15:56:47 +00:00
ui.HideMark();
ui.SetButtonInteractable(false);
2025-07-29 15:56:47 +00:00
return;
}
string markSpriteKey = null;
if (_restaurantManagementSo.IsCookwareMatched(ui.Model.Id))
{
markSpriteKey = SpriteConstants.CheckYesSpriteKey;
}
else
{
markSpriteKey = SpriteConstants.CheckNoSpriteKey;
}
2025-07-29 15:56:47 +00:00
ui.SetIcon(model.ItemSprite);
2025-08-03 23:09:01 +00:00
ui.HideCountText();
ui.ShowMark(DataManager.Instance.GetSprite(markSpriteKey));
2025-07-29 15:56:47 +00:00
ui.SetButtonInteractable(true);
}
2025-07-29 18:18:16 +00:00
public async Task<RuntimeAnimatorController> GetAnimatorController()
{
return await AssetManager.LoadAsset<RuntimeAnimatorController>(AnimatorControllerKey);
}
2025-07-29 15:56:47 +00:00
}
}