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 NewCustomerGenerator()
    {
        int i = 0;

        yield return(new WaitForSeconds(1f));

        while (i < TotalCustomers)
        {
            if (purchaseQueue.Count < MaxCustomers && pickupQueue.Count < MaxCustomers)
            {
                Transform newNPC = (Transform)Instantiate(NPC, SpawnPoint.position, SpawnPoint.rotation);
                newNPC.name = "NPC " + i.ToString();
                TestNPCQueue NPCController = newNPC.GetComponent <TestNPCQueue>();
                newNPC.parent             = PurchasePoint;
                NPCController.PlaceInLine = purchaseQueue.Count;
                if (i == TotalCustomers - 1)
                {
                    NPCController.PlaceInLine = purchaseQueue.Count + 3;
                }
                NPCController.ChangeLine(TestNPCQueue.Line.purchase);
                purchaseQueue.Enqueue(newNPC);
                //NPCController.MoveToLine(PurchasePoint);
                newCustomerTime = Random.Range(2, 6);
                i++;
            }
            yield return(new WaitForSeconds(newCustomerTime));
        }
    }
Exemplo n.º 3
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag == "NPCCoffee")
     {
         TestNPCQueue npcController = other.transform.parent.parent.GetComponent <TestNPCQueue>();
         if (npcController.PurchasedCoffee)
         {
             if (!npcController.PickedupCoffee)
             {
                 //Debug.Log(other.transform.parent.parent.name + " entered pickup zone");
                 npcController.PickedupCoffee = true;
                 other.transform.root.GetComponent <QueueManager>().PickupCoffee(other.transform.parent.parent);
             }
         }
     }
 }
Exemplo n.º 4
0
 private void OnTriggerEnter(Collider other)
 {
     Debug.Log("Something enterd");
     if (other.tag == "NPCCoffee")
     {
         TestNPCQueue npcController = other.transform.parent.parent.GetComponent <TestNPCQueue>();
         if (!npcController.PurchasedCoffee)
         {
             currentCustomer = other.transform.parent.parent.name;
             //Debug.Log(other.transform.parent.parent.name + " entered purchase zone");
             customerPurchasing            = true;
             npcController.PurchasedCoffee = true;
             other.transform.root.GetComponent <QueueManager>().PurchaseCoffee(other.transform.parent.parent);
         }
     }
 }
Exemplo n.º 5
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.º 6
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);
    }