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
39
Assets/Scripts/UI/DeliveryManagerSingleUI.cs
Normal file
39
Assets/Scripts/UI/DeliveryManagerSingleUI.cs
Normal file
|
@ -0,0 +1,39 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class DeliveryManagerSingleUI : MonoBehaviour
|
||||
{
|
||||
|
||||
[SerializeField] private TextMeshProUGUI recipeNameText;
|
||||
[SerializeField] private Transform iconContainer;
|
||||
[SerializeField] private Transform iconTemplate;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
iconTemplate.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public void SetRecipeSO(RecipeSO recipeSO)
|
||||
{
|
||||
recipeNameText.text = recipeSO.recipeName;
|
||||
|
||||
foreach (Transform child in iconContainer)
|
||||
{
|
||||
if (child == iconTemplate) continue;
|
||||
Destroy(child.gameObject);
|
||||
}
|
||||
|
||||
foreach (KitchenObjectSO kitchenObjectSO in recipeSO.kitchenObjectSoList)
|
||||
{
|
||||
Transform iconTransform = Instantiate(iconTemplate, iconContainer);
|
||||
|
||||
iconTransform.GetComponent<Image>().sprite = kitchenObjectSO.sprite;
|
||||
|
||||
iconTransform.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
11
Assets/Scripts/UI/DeliveryManagerSingleUI.cs.meta
Normal file
11
Assets/Scripts/UI/DeliveryManagerSingleUI.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3099d20f5c3187d4194b982b16b8b7d4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
11
Assets/Scripts/UI/DeliveryManagerUI.cs.meta
Normal file
11
Assets/Scripts/UI/DeliveryManagerUI.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4ef59cd396e471c4aa88b6e877446288
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
16
Assets/Scripts/UI/PlateIconSingleUI.cs
Normal file
16
Assets/Scripts/UI/PlateIconSingleUI.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class PlateIconSingleUI : MonoBehaviour
|
||||
{
|
||||
// For some reason it was pulling Image from somewhere else randomly near the end of development so I had to specify UnityEngine.UI.Image??
|
||||
[SerializeField] private UnityEngine.UI.Image image;
|
||||
|
||||
public void SetKitchenObjectSO(KitchenObjectSO kitchenObjectSO)
|
||||
{
|
||||
image.sprite = kitchenObjectSO.sprite;
|
||||
}
|
||||
|
||||
}
|
11
Assets/Scripts/UI/PlateIconSingleUI.cs.meta
Normal file
11
Assets/Scripts/UI/PlateIconSingleUI.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bb1226f765ef3974789570cd9ab1d05d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
43
Assets/Scripts/UI/PlateIconsUI.cs
Normal file
43
Assets/Scripts/UI/PlateIconsUI.cs
Normal file
|
@ -0,0 +1,43 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlateIconsUI : MonoBehaviour
|
||||
{
|
||||
|
||||
[SerializeField] private PlateKitchenObject plateKitchenObject;
|
||||
[SerializeField] private Transform iconTemplate;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
iconTemplate.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
plateKitchenObject.OnIngreedientAdded += PlateKitchenObject_OnIngreedientAdded;
|
||||
}
|
||||
|
||||
private void PlateKitchenObject_OnIngreedientAdded(object sender, PlateKitchenObject.OnIngreedientAddedEventArgs e)
|
||||
{
|
||||
UpdateVisual();
|
||||
}
|
||||
|
||||
private void UpdateVisual()
|
||||
{
|
||||
foreach (Transform child in transform)
|
||||
{
|
||||
if (child == iconTemplate) continue;
|
||||
Destroy(child.gameObject);
|
||||
}
|
||||
|
||||
foreach (KitchenObjectSO kitchenObjectSO in plateKitchenObject.GetKitchenObjectSOList())
|
||||
{
|
||||
Transform iconTransform = Instantiate(iconTemplate, transform);
|
||||
|
||||
iconTransform.GetComponent<PlateIconSingleUI>().SetKitchenObjectSO(kitchenObjectSO);
|
||||
|
||||
iconTransform.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/UI/PlateIconsUI.cs.meta
Normal file
11
Assets/Scripts/UI/PlateIconsUI.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f1353c3b53a138c4ab06cfb45514baf6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
50
Assets/Scripts/UI/ProgressBarUI.cs
Normal file
50
Assets/Scripts/UI/ProgressBarUI.cs
Normal file
|
@ -0,0 +1,50 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ProgressBarUI : MonoBehaviour
|
||||
{
|
||||
|
||||
[SerializeField] private GameObject hasProgressGameObject;
|
||||
[SerializeField] private Image barImage;
|
||||
|
||||
private IHasProgress hasProgress;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
hasProgress = hasProgressGameObject.GetComponent<IHasProgress>();
|
||||
if (hasProgress == null) {
|
||||
Debug.LogError("Game Object " + hasProgressGameObject + " does not have a componenet that implements IHasProgress!");
|
||||
}
|
||||
|
||||
hasProgress.OnProgressChange += HasProgress_OnProgressChange;
|
||||
|
||||
barImage.fillAmount = 0f;
|
||||
|
||||
Hide();
|
||||
}
|
||||
|
||||
private void HasProgress_OnProgressChange(object sender, IHasProgress.OnProgressChangeEventsArgs e)
|
||||
{
|
||||
barImage.fillAmount = e.progressNormalized;
|
||||
|
||||
if (e.progressNormalized == 0f || e.progressNormalized == 1f) {
|
||||
Hide();
|
||||
} else
|
||||
{
|
||||
Show();
|
||||
}
|
||||
}
|
||||
|
||||
private void Show()
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
private void Hide()
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
}
|
11
Assets/Scripts/UI/ProgressBarUI.cs.meta
Normal file
11
Assets/Scripts/UI/ProgressBarUI.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 26eaed537ed747c47a98ae12d77258c9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in a new issue