/// <summary> /// Спавн покупателя с текущим заказом /// </summary> /// <param name="bSpawnPoint"> Точка спавна </param> void Spawn(BuyerSpawnPoint bSpawnPoint) { int index = UnityEngine.Random.Range(0, buyerPrefabs.Length); var newBuyer = Instantiate(buyerPrefabs[index], bSpawnPoint.spawnPoint); Buyer buyer = newBuyer.GetComponent <Buyer>(); newBuyer.name = $"Char_{currentIndex}"; var orderPanel = Instantiate(orderUI, canvas.transform); OrderUI orderPanelUI = orderPanel.GetComponent <OrderUI>(); orderPanel.name = $"{newBuyer.name}_orderUI"; buyer.orderUI = orderPanelUI; orderPanelUI.buyer = buyer; orderPanel.GetComponent <RectTransform>().anchoredPosition = GetCoordinates(bSpawnPoint.spawnPoint, charUI_offsetX, charUI_offsetY, canvas); bSpawnPoint.IsEmpty = false; var order = orders[currentIndex]; orderPanelUI.meals[order.Length - 1].SetActive(true); foreach (var meal in order) { var food = Instantiate(meal, orderPanelUI.meals[order.Length - 1].transform); buyer.dishList.Add(food); } buyers.Add(buyer); countBuyers--; currentIndex++; UpdateBuyersCount(); }
/// <summary> /// Новый покуупатель /// </summary> /// <param name="bSpawnPoint"> Точка спавна </param> void NewBuyer(BuyerSpawnPoint bSpawnPoint) { SpawnCurrent(bSpawnPoint); }
/// <summary> /// Спавн покупателя с текущим заказом /// </summary> /// <param name="bSpawnPoint"> Точка спавна </param> void SpawnCurrent(BuyerSpawnPoint bSpawnPoint) { Spawn(bSpawnPoint); }
private void Start() { buyerSpawn = GetComponentInParent <BuyerSpawnPoint>(); }