void OnTriggerEnter2D(Collider2D other) { if (!this.name.Equals("barberChair")) { Debug.Log("Char Triggered: " + other.name + " entered in the " + this.name); GameObject customer = (GameObject)other.gameObject; this.occupyChair(customer); //TODO: reference bug here...sometimes we cant reach this script barberScript = GameObject.Find("Barber").GetComponent <Barber>(); // awake the barber if he is sleeping if (barberScript) { if (!barberScript.isAwake()) { barberScript.wakeUp(); } // else { // Debug.LogError("barberscript not found!"); // } } } }
public void handleCustomerInReception(GameObject customer) { if (!isLocked()) { GameObject chair; lockMutex(); // if we have a free chair if (chair = this.checkForEmptyChair()) { // Debug.Log(customer.name + " will wait in: " + chair.name); waitingCount++; textWaitingValue.text = waitingCount.ToString(); customer.GetComponent <CustomerController>().waiting = true; //this need to be a coroutine, because we need to set a timer if (!checkForEmptyChair()) { barberScript.wakeUp(); } sendToChair(customer, chair); } else // dont have a free chair, customer leaving { Debug.Log("All chairs occupied. Customer leaving!"); customer.GetComponent <CustomerController>().leaving = true; customersTotalCount--; this.textCustomersValue.text = this.customersTotalCount.ToString(); } unlockMutex(); } }
public void handleCustomerInReception(GameObject customer) { GameObject chair; if (!isLocked()) { lockMutex(); // wakeup barber anyway barberScript.wakeUp(); // if we have a free chair if (chair = this.checkForEmptyChair()) { Debug.Log(customer.name + " will wait in: " + chair.name); waitingCount++; textWaitingValue.text = waitingCount.ToString(); customer.GetComponent <CustomerController>().waiting = true; sendToChair(customer, chair); unlockMutex(); } else // dont have a free chair, customer leaving { Debug.Log("All chairs occupied. Customer leaving!"); customer.GetComponent <CustomerController>().leaving = true; customersTotalCount--; sendTo(customer, waypointExit); unlockMutex(); } } }
private GameObject chairAssociated; // chair that the player will seat public void wakeUpBarber(Barber barber) { //TODO animate Customer going to the barber and waking up him // or maybe just yelling at him barber.wakeUp(); }