30 lines
985 B
C#
30 lines
985 B
C#
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace DDD.Restaurant
|
|
{
|
|
public class BillHud : MonoBehaviour, IEventHandler<RestaurantOrderEvent>
|
|
{
|
|
[SerializeField] private RectTransform _billItemsLayoutTransform;
|
|
[SerializeField] private GameObject _billItemPrefab;
|
|
|
|
private void Start()
|
|
{
|
|
EventBus.Register(this);
|
|
|
|
Utils.DestroyAllChildren(_billItemsLayoutTransform);
|
|
}
|
|
|
|
public void HandleEvent(RestaurantOrderEvent evt)
|
|
{
|
|
var billItem = Instantiate(_billItemPrefab, _billItemsLayoutTransform);
|
|
var recipeData = DataManager.Instance.GetDataAsset<RecipeDataAsset>();
|
|
if (recipeData.TryGetDataById(evt.RecipeId, out var recipeDataEntry))
|
|
{
|
|
var sprite = DataManager.Instance.GetSprite(recipeDataEntry.RecipeResult);
|
|
billItem.GetComponent<Image>().sprite = sprite;
|
|
}
|
|
}
|
|
}
|
|
} |