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

58 lines
2.0 KiB
C#
Raw Normal View History

2025-07-29 18:18:16 +00:00
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.AddressableAssets;
namespace DDD
2025-07-29 15:56:47 +00:00
{
public class TodayMenuSlotUiStrategy : IItemSlotUiStrategy
{
2025-07-29 18:18:16 +00:00
private RestaurantManagementSo _restaurantManagementSo;
2025-07-29 15:56:47 +00:00
private readonly RecipeType _recipeType;
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;
}
2025-07-29 18:18:16 +00:00
public async Task Setup(ItemSlotUi ui, ItemViewModel model)
2025-07-29 15:56:47 +00:00
{
2025-07-29 18:18:16 +00:00
if (!_restaurantManagementSo)
{
_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 18:18:16 +00:00
ui.SetBackgroundColor(_restaurantManagementSo.EmptyBackgroundColor);
2025-07-29 15:56:47 +00:00
ui.SetIcon(DataManager.Instance.GetSprite(emptySpriteKey));
ui.HideCount();
ui.HideMark();
ui.SetButtonInteractable(false);
return;
}
2025-07-29 18:18:16 +00:00
ui.SetBackgroundColor(_restaurantManagementSo.AddedBackgroundColor);
2025-07-29 15:56:47 +00:00
ui.SetIcon(model.ItemSprite);
ui.HideCount();
ui.ShowMark(DataManager.Instance.GetSprite(SpriteConstants.CheckNoSpriteKey)); // TODO : 추후에 장비와 매칭
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
}
}