Add Delivery Manager UI and UI logic
This commit is contained in:
parent
8c5f4f2acf
commit
3ec46256e8
89 changed files with 14001 additions and 12 deletions
52
Assets/Scripts/UI/DeliveryManagerUI.cs
Normal file
52
Assets/Scripts/UI/DeliveryManagerUI.cs
Normal file
|
@ -0,0 +1,52 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DeliveryManagerUI : MonoBehaviour
|
||||
{
|
||||
|
||||
[SerializeField] private Transform container;
|
||||
[SerializeField] private Transform recipeTemplate;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
recipeTemplate.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
UpdateVisual();
|
||||
|
||||
DeliveryManager.Instance.OnRecipeSpawned += DeliveryManager_OnRecipeSpawned;
|
||||
DeliveryManager.Instance.OnRecipeCompleted += DeliveryManager_OnRecipeCompleted;
|
||||
}
|
||||
|
||||
private void DeliveryManager_OnRecipeSpawned(object sender, System.EventArgs e)
|
||||
{
|
||||
UpdateVisual();
|
||||
}
|
||||
|
||||
private void DeliveryManager_OnRecipeCompleted(object sender, System.EventArgs e)
|
||||
{
|
||||
UpdateVisual();
|
||||
}
|
||||
|
||||
private void UpdateVisual()
|
||||
{
|
||||
foreach (Transform child in container)
|
||||
{
|
||||
if (child == recipeTemplate) continue;
|
||||
Destroy(child.gameObject);
|
||||
}
|
||||
|
||||
foreach (RecipeSO recipeSO in DeliveryManager.Instance.GetWaitingRecipeSOList())
|
||||
{
|
||||
Transform recipeTransform = Instantiate(recipeTemplate, container);
|
||||
|
||||
recipeTransform.GetComponent<DeliveryManagerSingleUI>().SetRecipeSO(recipeSO);
|
||||
|
||||
recipeTransform.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue