Exemplo n.º 1
0
    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);
    }
Exemplo n.º 2
0
    IEnumerator PickupLineManager()
    {
        while (true)
        {
            while (pickupQueue.Count > 0)
            {
                Transform    firstNPC      = pickupQueue.Peek();
                TestNPCQueue NPCController = firstNPC.GetComponent <TestNPCQueue>();
                yield return(new WaitForSeconds(NPCController.TimeToPickup));

                pickupQueue.Dequeue();
                Debug.Log("Destroying " + firstNPC.name);
                Destroy(firstNPC.gameObject);
                foreach (Transform NPC in pickupQueue.ToArray())
                {
                    TestNPCQueue _NPCController = NPC.GetComponent <TestNPCQueue>();
                    _NPCController.MoveUp();
                }
            }
            yield return(null);
        }
    }
Exemplo n.º 3
0
    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);
    }