bool SetupCustomerQueue(int tries = 0)
    {
        if (tries >= maxTries)
        {
            return(false);
        }

        CashRegister foundRegister = stateMachine.mapManager.GetRandomCashRegister();

        if (foundRegister)
        {
            // Retry if the register queue is full
            if (foundRegister.IsFull())
            {
                SetupCustomerQueue(tries++);
            }

            // Get queuing position
            Vector3 customerPosition = foundRegister.AddToQueue(stateMachine.gameObject);

            // Attach queue change event to QueueState
            foundRegister.QueueChanged.AddListener(stateMachine.queuingState.QueueChanged);

            stateMachine.taskDestination         = foundRegister.transform;
            stateMachine.taskDestinationPosition = customerPosition;
        }

        return(true);
    }
Exemplo n.º 2
0
    private bool SetupDestination()
    {
        // Grab random shelf component on map with wanted product
        register = stateMachine.mapManager.GetRandomCashRegister();

        if (!register)
        {
            return(false);
        }

        // Get shelf transform
        stateMachine.taskDestination = register.transform;

        // Get pickup position
        stateMachine.taskDestinationPosition = register.AddToQueue(stateMachine.gameObject);

        // Attach queue change event
        register.QueueChanged.AddListener(QueueChanged);
        register.CustomerCashedOut.AddListener(CashingOut);

        return(true);
    }