2025-07-23 03:27:34 +00:00
|
|
|
using System;
|
2025-07-24 08:41:20 +00:00
|
|
|
using UnityEngine;
|
2025-07-25 07:58:53 +00:00
|
|
|
using UnityEngine.EventSystems;
|
2025-07-23 03:27:34 +00:00
|
|
|
using UnityEngine.InputSystem;
|
|
|
|
|
|
|
|
namespace DDD
|
|
|
|
{
|
|
|
|
public class RestaurantManagementUi : PopupUi<RestaurantUiActions>
|
|
|
|
{
|
2025-07-25 07:58:53 +00:00
|
|
|
[SerializeField] private InventoryView _inventoryView;
|
|
|
|
[SerializeField] private TabGroupUi<RestaurantManagementSectionType> _sectionTabs;
|
|
|
|
[SerializeField] private TabGroupUi<InventoryCategoryType> _categoryTabs;
|
2025-07-24 08:41:20 +00:00
|
|
|
|
|
|
|
public override void Open()
|
|
|
|
{
|
|
|
|
base.Open();
|
|
|
|
|
2025-07-25 07:58:53 +00:00
|
|
|
_sectionTabs.Initialize(OnSectionTabSelected);
|
|
|
|
_categoryTabs.Initialize(OnCategoryTabSelected);
|
2025-07-24 08:41:20 +00:00
|
|
|
}
|
|
|
|
|
2025-07-23 03:27:34 +00:00
|
|
|
protected override void OnInputPerformed(RestaurantUiActions actionEnum, InputAction.CallbackContext context)
|
|
|
|
{
|
|
|
|
switch (actionEnum)
|
|
|
|
{
|
|
|
|
case RestaurantUiActions.Cancel:
|
|
|
|
HandleCancel();
|
|
|
|
break;
|
|
|
|
case RestaurantUiActions.PreviousTab:
|
|
|
|
HandleMoveTab(-1);
|
|
|
|
break;
|
|
|
|
case RestaurantUiActions.NextTab:
|
|
|
|
HandleMoveTab(1);
|
|
|
|
break;
|
|
|
|
case RestaurantUiActions.Interact1:
|
|
|
|
HandleInteract1();
|
|
|
|
break;
|
2025-07-25 07:58:53 +00:00
|
|
|
case RestaurantUiActions.Interact2:
|
|
|
|
HandleInteract2();
|
|
|
|
break;
|
2025-07-23 03:27:34 +00:00
|
|
|
default:
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(actionEnum), actionEnum, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void HandleCancel()
|
|
|
|
{
|
|
|
|
var evt = GameEvents.ClosePopupUiEvent;
|
|
|
|
evt.UiType = GetType();
|
|
|
|
EventBus.Broadcast(evt);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void HandleMoveTab(int direction)
|
|
|
|
{
|
2025-07-25 07:58:53 +00:00
|
|
|
_sectionTabs.Move(direction);
|
2025-07-23 03:27:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void HandleInteract1()
|
2025-07-25 07:58:53 +00:00
|
|
|
{
|
|
|
|
var selected = EventSystem.current.currentSelectedGameObject;
|
|
|
|
var interactable = selected?.GetComponent<IInteractableUi>();
|
|
|
|
interactable?.OnInteract();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void HandleInteract2()
|
2025-07-23 03:27:34 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2025-07-24 08:41:20 +00:00
|
|
|
|
2025-07-25 07:58:53 +00:00
|
|
|
private void OnSectionTabSelected(RestaurantManagementSectionType section)
|
2025-07-24 08:41:20 +00:00
|
|
|
{
|
2025-07-25 07:58:53 +00:00
|
|
|
// 추후 Menu, Cookware, Worker에 맞춰 다른 콘텐츠 노출 처리
|
2025-07-24 08:41:20 +00:00
|
|
|
}
|
|
|
|
|
2025-07-25 07:58:53 +00:00
|
|
|
private void OnCategoryTabSelected(InventoryCategoryType category)
|
2025-07-24 08:41:20 +00:00
|
|
|
{
|
2025-07-25 07:58:53 +00:00
|
|
|
_inventoryView.ShowItems(itemData =>
|
|
|
|
{
|
|
|
|
switch (category)
|
|
|
|
{
|
|
|
|
case InventoryCategoryType.Food:
|
|
|
|
case InventoryCategoryType.Drink:
|
|
|
|
if (itemData.ItemType != ItemType.Recipe) return false;
|
|
|
|
|
|
|
|
RecipeType recipeType = DataManager.Instance.RecipeDataSo.GetDataById(itemData.Id).RecipeType;
|
|
|
|
return category switch
|
|
|
|
{
|
|
|
|
InventoryCategoryType.Food => recipeType == RecipeType.FoodRecipe,
|
|
|
|
InventoryCategoryType.Drink => recipeType == RecipeType.DrinkRecipe,
|
|
|
|
_ => false
|
|
|
|
};
|
|
|
|
case InventoryCategoryType.Ingredient:
|
|
|
|
return itemData.ItemType == ItemType.Ingredient;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
2025-07-24 08:41:20 +00:00
|
|
|
}
|
2025-07-23 03:27:34 +00:00
|
|
|
}
|
|
|
|
}
|