IEnumerator _PurchaseCoffee(Transform _npc) { //Transform npc = purchaseQueue.Peek(); TestNPCQueue npcController = _npc.GetComponent <TestNPCQueue>(); //Debug.Log(npc.name + " buying coffee..."); yield return(new WaitForSeconds(npcController.TimeToOrder)); //Debug.Log(npc.name + " bought coffee."); purchaseQueue.Dequeue(); pickupQueue.Enqueue(_npc); Debug.Log(_npc.name + " added to pickupQueue"); _npc.parent = PickupPoint; npcController.PlaceInLine = pickupQueue.Count - 1; npcController.ChangeLine(TestNPCQueue.Line.pickup); npcController.MoveToLine(PickupPoint, TestNPCQueue.Line.pickup); int i = 0; foreach (Transform _npcs in purchaseQueue.ToArray()) { TestNPCQueue _npcsController = _npcs.GetComponent <TestNPCQueue>(); //Debug.Log("Moving " + _npc.name + " up one spot"); _npcsController.PlaceInLine = i; _npcsController.MoveUp(); i++; } yield return(null); }
IEnumerator _PickupCoffee(Transform _npc) { //Transform npc = pickupQueue.Peek(); //Debug.Log(npc.name + " is the first in pickupQueue"); TestNPCQueue npcController = _npc.GetComponent <TestNPCQueue>(); Debug.Log(_npc.name + " picking up coffee..."); yield return(new WaitForSeconds(npcController.TimeToPickup)); //Debug.Log(npc.name + " picked up coffee."); float f = 0; while (f <= 1) { _npc.GetComponentInChildren <Animator>().SetFloat("HasCoffee", f); f = f + 0.1f; yield return(null); } npcController.Coffee.gameObject.SetActive(true); pickupQueue.Dequeue(); _npc.parent = null; Debug.Log(_npc.name + " removed from pickupQueue"); npcController.MoveToLine(SpawnPoint, TestNPCQueue.Line.pickup); npcController.FadeOutAndDie(); int i = 0; foreach (Transform _npcs in pickupQueue.ToArray()) { TestNPCQueue _npcsController = _npcs.GetComponent <TestNPCQueue>(); //Debug.Log("Moving " + _npc.name + " up one spot"); _npcsController.PlaceInLine = i; _npcsController.MoveUp(); i++; } //Destroy(npc.gameObject); yield return(null); }