+ 화면 밖에서 손님이 요구하는 중일 때, Indicator를 통해서 Ui 표시 + Open, Closed Ui 추가 및 기능 연결 + 테이블 찾는 로직 변경 (전부 랜덤) - 기존에는 항상 같은 순서로 자리를 채움 + 통계용 데이터 CustomerVisitInfo 추가 (추후에 통계Ui 생길 때 연결) + 대화 조건 변경 + 일부 가구들 상호작용 조건 변경 + Outline shader Render Face(Front -> Both 변경 - Front면 x축 뒤집는 경우 안나옴) + GraphicMaterialOverride를 사용하는 경우, 에디터에서 전체화면 등 특정 상황에서 material이 사라지는 버그 수정 + InteractionFuniture Open, Closed 공통 기능으로 병합
220 lines
7.1 KiB
C#
220 lines
7.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using BlueWater.Items;
|
|
using BlueWater.Tycoons;
|
|
using Sirenix.OdinInspector;
|
|
using UnityEngine;
|
|
using UnityEngine.Serialization;
|
|
|
|
namespace BlueWater.Uis
|
|
{
|
|
public class DailyFoodMenuUi : MonoBehaviour
|
|
{
|
|
[Title("프리팹 생성 위치")]
|
|
[SerializeField, Required]
|
|
private Transform _soupFoodSlotLocation;
|
|
|
|
[FormerlySerializedAs("_fryingPanFoodSlotLocation")]
|
|
[SerializeField, Required]
|
|
private Transform _grillFoodSlotLocation;
|
|
|
|
[SerializeField, Required]
|
|
private Transform _skewerFoodSlotLocation;
|
|
|
|
[SerializeField, Required]
|
|
private Transform _dessertFoodSlotLocation;
|
|
|
|
[Title("프리팹")]
|
|
[SerializeField, Required]
|
|
private TycoonItemSlotUi _dailyFoodSlotUi;
|
|
|
|
[Title("실시간 데이터")]
|
|
[SerializeField]
|
|
private List<TycoonItemSlotUi> _soupFoodSlotUis = new(3);
|
|
|
|
[FormerlySerializedAs("_fryingPanFoodSlotUis")]
|
|
[SerializeField]
|
|
private List<TycoonItemSlotUi> _grillFoodSlotUis = new(3);
|
|
|
|
[SerializeField]
|
|
private List<TycoonItemSlotUi> _skewerFoodSlotUis = new(3);
|
|
|
|
[SerializeField]
|
|
private List<TycoonItemSlotUi> _dessertPanFoodSlotUis = new(3);
|
|
|
|
[field: SerializeField]
|
|
public List<TycoonItemSlotUi> DailyFoodSlotUis { get; private set; } = new(12);
|
|
|
|
[SerializeField]
|
|
private List<Pot> _pots = new(3);
|
|
|
|
[SerializeField]
|
|
private List<Grill> _grills = new(3);
|
|
|
|
[SerializeField]
|
|
private List<Skewer> _skewers = new(3);
|
|
|
|
private CookUi _cookUi;
|
|
|
|
private void Start()
|
|
{
|
|
Initialize();
|
|
}
|
|
|
|
private void Initialize()
|
|
{
|
|
_cookUi = TycoonUiManager.Instance.TycoonManagementUi.CookMenuUi.CookUi;
|
|
|
|
foreach (var element in _grillFoodSlotUis)
|
|
{
|
|
element.AddButtonClickListener(() => RemoveDailyFood(element));
|
|
}
|
|
|
|
foreach (var element in _soupFoodSlotUis)
|
|
{
|
|
element.AddButtonClickListener(() => RemoveDailyFood(element));
|
|
}
|
|
|
|
foreach (var element in _skewerFoodSlotUis)
|
|
{
|
|
element.AddButtonClickListener(() => RemoveDailyFood(element));
|
|
}
|
|
|
|
foreach (var element in _dessertPanFoodSlotUis)
|
|
{
|
|
element.AddButtonClickListener(() => RemoveDailyFood(element));
|
|
}
|
|
}
|
|
|
|
private void RemoveDailyFood(TycoonItemSlotUi tycoonItemSlotUi)
|
|
{
|
|
tycoonItemSlotUi.SetFoodData(null);
|
|
DailyFoodSlotUis.Remove(tycoonItemSlotUi);
|
|
_cookUi.CheckCookable();
|
|
}
|
|
|
|
public bool IsEmptyDailyFoodMenu(FoodData selectedFoodData)
|
|
{
|
|
var selectedTypeItemSlotUis = GetDailyFoodType(selectedFoodData.Type);
|
|
|
|
foreach (var element in selectedTypeItemSlotUis)
|
|
{
|
|
if (!element.GetIsLocked() && element.FoodData is null or { Idx: 0 })
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public void AddDailyFoodMenu(FoodData selectedFoodData)
|
|
{
|
|
var selectedTypeItemSlotUis = GetDailyFoodType(selectedFoodData.Type);
|
|
|
|
foreach (var element in selectedTypeItemSlotUis)
|
|
{
|
|
if (!element.GetIsLocked() && element.FoodData is null or { Idx: 0 })
|
|
{
|
|
element.SetFoodData(selectedFoodData);
|
|
DailyFoodSlotUis.Add(element);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
private List<TycoonItemSlotUi> GetDailyFoodType(FoodType foodType)
|
|
{
|
|
switch (foodType)
|
|
{
|
|
case FoodType.None:
|
|
Debug.LogError($"FoodType이 None입니다.");
|
|
return null;
|
|
case FoodType.Skewer:
|
|
return _skewerFoodSlotUis;
|
|
case FoodType.Soup:
|
|
return _soupFoodSlotUis;
|
|
case FoodType.Grill:
|
|
return _grillFoodSlotUis;
|
|
case FoodType.Dessert:
|
|
return _dessertPanFoodSlotUis;
|
|
default:
|
|
throw new ArgumentOutOfRangeException(nameof(foodType), foodType, null);
|
|
}
|
|
}
|
|
|
|
public bool CanOpen()
|
|
{
|
|
return _grillFoodSlotUis.Any(slot => slot.FoodData is not null and not { Idx: 0 }) ||
|
|
_soupFoodSlotUis.Any(slot => slot.FoodData is not null and not { Idx: 0 }) ||
|
|
_skewerFoodSlotUis.Any(slot => slot.FoodData is not null and not { Idx: 0 }) ||
|
|
_dessertPanFoodSlotUis.Any(slot => slot.FoodData is not null and not { Idx: 0 });
|
|
}
|
|
|
|
public TycoonItemSlotUi InitializeGrill(Grill grill)
|
|
{
|
|
_grills.Add(grill);
|
|
var index = _grills.Count - 1;
|
|
_grillFoodSlotUis[index].SetIsLocked(false);
|
|
_grillFoodSlotUis[index].SetFoodData(null);
|
|
return _grillFoodSlotUis[index];
|
|
}
|
|
|
|
public TycoonItemSlotUi InitializePot(Pot pot)
|
|
{
|
|
_pots.Add(pot);
|
|
var index = _pots.Count - 1;
|
|
_soupFoodSlotUis[index].SetIsLocked(false);
|
|
_soupFoodSlotUis[index].SetFoodData(null);
|
|
return _soupFoodSlotUis[index];
|
|
}
|
|
|
|
|
|
public TycoonItemSlotUi InitializeSkewer(Skewer skewer)
|
|
{
|
|
_skewers.Add(skewer);
|
|
var index = _skewers.Count - 1;
|
|
_skewerFoodSlotUis[index].SetIsLocked(false);
|
|
_skewerFoodSlotUis[index].SetFoodData(null);
|
|
return _skewerFoodSlotUis[index];
|
|
}
|
|
|
|
public void TycoonClosed()
|
|
{
|
|
DailyFoodSlotUis.Clear();
|
|
|
|
foreach (var element in _grillFoodSlotUis)
|
|
{
|
|
if (!element.GetIsLocked() && element.FoodData is not null)
|
|
{
|
|
element.SetFoodData(null);
|
|
}
|
|
}
|
|
|
|
foreach (var element in _soupFoodSlotUis)
|
|
{
|
|
if (!element.GetIsLocked() && element.FoodData is not null)
|
|
{
|
|
element.SetFoodData(null);
|
|
}
|
|
}
|
|
|
|
foreach (var element in _skewerFoodSlotUis)
|
|
{
|
|
if (!element.GetIsLocked() && element.FoodData is not null)
|
|
{
|
|
element.SetFoodData(null);
|
|
}
|
|
}
|
|
|
|
foreach (var element in _dessertPanFoodSlotUis)
|
|
{
|
|
if (!element.GetIsLocked() && element.FoodData is not null)
|
|
{
|
|
element.SetFoodData(null);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |