public void CreateCustomer() { // only create customer if there isn't one already if (c == null) { c = Instantiate(customerClone); c.name = "Customer"; // finding all components from customer Customer customer = c.GetComponent <Customer>(); orderPanelHandler = GameObject.Find("EventSystem").GetComponent <OrderPanelHandler>(); // finding button, childing it to the main canvas orderFormButton = Instantiate(orderButtonClone, GameObject.FindGameObjectWithTag("Canvas").transform).GetComponent <Button>(); orderFormButton.transform.SetSiblingIndex(2); orderFormButton.transform.localPosition = new Vector3(110, -115, 0); // adding onClick listener to customer's order button orderFormButton.onClick.AddListener(() => orderPanelHandler.OpenClosePanel()); // setting customer's fields customer.CustomerName = OrderAssigner.nameList[Random.Range(0, OrderAssigner.nameList.Count - 1)]; customer.ClassType = OrderAssigner.classList[Random.Range(0, OrderAssigner.classList.Count - 1)]; customer.CreateOrder(); OrderAssigner.GiveSpecialForm(customer); customerSpawned = true; } }
// Constructor public Order(string classType) { orderType = OrderAssigner.SetOrderType(); orderPurpose = OrderAssigner.SetOrderPurpose(this, classType); orderPotion = OrderAssigner.SetOrderPotion(orderType); }