오늘은 손님이 요청한 음식과 플레이어가 서빙한 음식이 똑같으면
손님이 점프하는 애니메이션을 재생하고,
서빙한 음식이 사라지고,
식당을 나가는 것 까지 구현했다.
음식이 놓일 자리를 관리해주는
FoodPlace 클래스를 만들었다.
FoodPlace에 음식이 놓이면 그 자리에 있는 손님이 요청한 음식과 비교한다.
public class FoodPlace : MonoBehaviour
{
private const float _foodDestroyTime = 2.0f;
private CustomerController _currentCustomer;
public CustomerController CurrentCustomer
{
get { return _currentCustomer; }
set { _currentCustomer = value; }
}
private CookedFood _currentFood;
public CookedFood CurrentFood
{
get { return _currentFood; }
set
{
_currentFood = value;
if (_currentCustomer != null && _currentFood != null)
{
if (_currentCustomer.TargetFood.name == _currentFood.FoodName)
{
MatchWithCustomer();
}
}
}
}
public event Action OnCustomerGetFood;
private void MatchWithCustomer()
{
// TODO: Get Gold
OnCustomerGetFood.Invoke();
StartCoroutine(DestoryCurrentFood(_currentFood.gameObject));
_currentFood = null;
_currentCustomer = null;
}
IEnumerator DestoryCurrentFood(GameObject food)
{
yield return new WaitForSeconds(_foodDestroyTime);
Destroy(food);
}
}
'내일배움캠프(Unity)' 카테고리의 다른 글
TIL - 음식 먹기, 접시 치우기 (2) | 2024.01.23 |
---|---|
TIL - AI agent priority, Food Creater (0) | 2024.01.18 |
손님 AI 2 - 다른 손님이 없는 자리로 이동하기, ValueTuple (0) | 2024.01.15 |
GameManager 관련 미니 특강 (0) | 2024.01.15 |
TIL - 손님 AI 1 (1) | 2024.01.12 |