59 lines
1.8 KiB
C#
59 lines
1.8 KiB
C#
|
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<ItemObject>("Items").ToList();
|
||
|
customerTables = GetComponentsInChildren<CustomerTable>().ToList();
|
||
|
int i = 0;
|
||
|
foreach (CustomerTable table in customerTables)
|
||
|
{
|
||
|
table.tableNumber = i;
|
||
|
i++;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
public int customerSpawnTime = 10;
|
||
|
[SerializeField] private List<CustomerTable> customerTables;
|
||
|
[SerializeField] private List<ItemObject> 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)];
|
||
|
}
|
||
|
}
|
||
|
}
|