Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (isBeingServed)
        {
            isAngry   = false;
            curTimer -= Time.deltaTime;
            //print("being serviced");
            Transform dummyDestination = gridRef.nodeGrid[1][1];
            if (curTimer <= 0)
            {
                //move to next task

                if (currentServiceState == serviceTypes.reception)
                {
                    currentServiceQueue.customerServed();
                    currentServiceState = serviceTypes.bedroom;
                    onDestinationCall   = findNextDestination();
                    //remove from old service queue

                    //travel to bedroom => wait on clean => sleep
                    //customerServed() call here....
                    gameManager.charge(100.0f);
                    Camera.main.transform.GetComponent <ObjectPlacer>().PlaySfx(0);
                    currentServiceQueue = onDestinationCall.GetComponent <ServiceQueue>();
                    //print("onDestinationCall: " + onDestinationCall.position);
                    //print("currentServiceQueuePos: " + currentServiceQueue.transform.position);
                    //print("Go to Bedroom serviceQueueType: " + currentServiceQueue.serviceType);
                    onDestinationCall.GetComponent <ServiceQueue>().customerTraveling.Add(this.transform);
                    GetComponent <NodeList>().travel(onDestinationCall, startWaitCall);
                }
                else if (currentServiceState == serviceTypes.bedroom)
                {
                    currentServiceQueue.customerServed();
                    currentServiceState = serviceTypes.kitchen;
                    onDestinationCall   = findNextDestination();

                    //travel to kitchen => wait => eat
                    currentServiceQueue = onDestinationCall.GetComponent <ServiceQueue>();
                    onDestinationCall.GetComponent <ServiceQueue>().customerTraveling.Add(this.transform);
                    GetComponent <NodeList>().travel(onDestinationCall, startWaitCall);
                }
                else if (currentServiceState == serviceTypes.kitchen)
                {
                    currentServiceQueue.customerServed();
                    currentServiceState = serviceTypes.exit;
                    onDestinationCall   = findNextDestination();

                    //travel to exit => destroy self
                    //currentServiceQueue = onDestinationCall.GetComponent<ServiceQueue>();
                    //onDestinationCall.GetComponent<ServiceQueue>().customerTraveling.Add(this.transform);
                    GetComponent <NodeList>().travel(onDestinationCall, destroyMe);
                }
                else
                {
                    currentServiceQueue.customerServed();
                    currentServiceState = serviceTypes.exit;
                    onDestinationCall   = findNextDestination();
                    print("npc is lost on improper service state");
                    print("exiting npc.....");
                    currentServiceQueue = onDestinationCall.GetComponent <ServiceQueue>();
                    GetComponent <NodeList>().travel(onDestinationCall, destroyMe);
                }
                isBeingServed = false;
            }
        }
        else if (isWaiting)
        {
            ;            if (curTimer > 0.0f)
            {
                curTimer -= Time.deltaTime;
            }
            else
            {
                isAngry = true;
            }
        }

        if (isAngry)
        {
            angerTimer += Time.deltaTime;

            if (angerTimer >= maxAngerTime)
            {
                print("A customer got angry and left...");
                currentServiceQueue.removeCustomer(this.transform);
                gameManager.charge(-20);
                //unoccupy hotel room
                currentServiceState = serviceTypes.exit;
                GetComponent <NodeList>().travel(onDestinationCall, destroyMe);
                isAngry = false;
            }
        }
    }