public CustomerViewModelSecond() { customerOperationsObj = new CustomerOperations(); LoadData(); addCustomerCommand = new CustomerCommands(Add); searchCustomerCommand = new CustomerCommands(Search); updateCustomerCommand = new CustomerCommands(Update); CurrentCustomer = new Customer(); }
public void CallingAllCustomers(CustomerCommands commands) { /* Gather all Customer GameObjects and line them up based on the CustomerQueue * gameobject X position. Set a X pos gap between each customer and assign each * customer with an order layer */ Customer[] allCustomerArray = GetAllCustomerArray(customerCount); float customerXPos = queuePos.GetLocation().x; int customerOrderLayer = topOrderLayer; foreach (Customer customer in allCustomerArray) { Vector2 customerQueuePosition = new Vector2(customerXPos, queuePos.GetLocation().y); Customer newCustomer = Instantiate(customer, customerQueuePosition, Quaternion.identity) as Customer; GameObject customerBody = newCustomer.transform.Find("Body").gameObject; customerBody.GetComponent <Renderer>().sortingOrder = customerOrderLayer; newCustomer.GetComponent <Customer>().CustomerCommands = commands; newCustomer.transform.parent = transform; customerXPos += queueGap; customerOrderLayer -= 1; } }
private void Update() { /* If StartMoving is enabled, move left till target location is reached * then check the staus. If is Serve, meaning that is the current customer. * Will need to display the food order in speech bubble. If is Wait, * meaning the customer still in queue and just moved up in queu. Passing this * customer object to figure out which customer queue behind. */ if (StartMoving) { if (transform.position.x > MoveTargetLocation) { if (CustomerStatus == status.WAIT) { transform.Translate(Vector2.left * moveUpSpeed * Time.deltaTime); } else { transform.Translate(Vector2.left * speed * Time.deltaTime); } customerAnimator.SetBool("StartWalk", true); } else { StartMoving = false; customerAnimator.SetBool("StartWalk", false); if (CustomerStatus == status.SERVE) { CustomerCommands.ShowFoodOrder(); } else if (CustomerStatus == status.WAIT) { CustomerList.MoveCustomerUpInQueue(this); } } } }