using System.Collections; using System.Collections.Generic; using System.Linq; using Logic.Graph; using Logic.Inventory.Scripts; using UnityEngine; namespace Logic { public class CustomerTableManager: MonoBehaviour { #region Singleton public static CustomerTableManager Instance; private void Awake() { Instance = this; availableRecipes = Resources.LoadAll("Items").ToList(); customerTables = GetComponentsInChildren().ToList(); int i = 0; foreach (CustomerTable table in customerTables) { table.tableNumber = i; i++; } } #endregion public int customerSpawnTime = 10; [SerializeField] private List customerTables; [SerializeField] private List availableRecipes; private void Start() { StartCoroutine(HandleCustomerSpawn(customerSpawnTime)); } IEnumerator HandleCustomerSpawn(int secs) { while (true) { int randomTableNumber = Random.Range(0, customerTables.Count); if (customerTables[randomTableNumber].state == TableState.Empty) { customerTables[randomTableNumber].state = TableState.WaitingForMenu; UIManager.Instance.uiTableManager.ChangeStatus(randomTableNumber, TableState.WaitingForMenu); } yield return new WaitForSeconds(secs); } } public ItemObject GetRandomRecipe() { return availableRecipes[Random.Range(0, availableRecipes.Count)]; } } }