Esempio n. 1
0
 private void OnWrongAnswer(LostFoundItem lfItem, CustomerBehaviour customer)
 {
     SetRiddleLabel(null);
     WrongSource.Play();
     Debug.Log("wrong answer");
     CustomerControl.ExitCustomer(customer);
 }
Esempio n. 2
0
    //waits a random amount dictated in RandomUtil to startcustomer. flag is to ensure this only happens once
    IEnumerator WaitToStartCustomer(CustomerBehaviour customer)
    {
        customer.isActive = true;
        yield return(new WaitForSecondsRealtime(RandomUtil.GetRandomWaitTime()));

        customer.StartCustomer();
    }
Esempio n. 3
0
 private void HandleCustomerOut(CustomerBehaviour customer)
 {
     GameObject.Destroy(customer.gameObject);
     if (_nOut-- <= 0)
     {
         //game end
     }
 }
Esempio n. 4
0
    public void ExitCustomer(CustomerBehaviour customer)
    {
        int entryIndex = customer.ID;

        _busy[entryIndex]             = false;
        _customerPerEntry[entryIndex] = null;
        customer.SetMovement(SpawnPoint, HandleCustomerOut);
    }
Esempio n. 5
0
 private void HandleCustomerReach(CustomerBehaviour customer)
 {
     customer.StartWait(t =>
     {
         OnCustomerOverwait.Invoke(t);
         ExitCustomer(t);
     });
 }
Esempio n. 6
0
 public void OnOverwait(CustomerBehaviour customer)
 {
     WrongSource.Play();
     if (_currentCustomer == customer)
     {
         SetRiddleLabel(null);
     }
 }
Esempio n. 7
0
 private void OnRightAnswer(LostFoundItem lfItem, CustomerBehaviour customer)
 {
     SetRiddleLabel(null);
     RightSource.Play();
     Debug.Log("right answer");
     Storage.RemoveItem(lfItem, true);
     CustomerControl.ExitCustomer(customer);
 }
Esempio n. 8
0
    public void SetCustomerRiddle(CustomerBehaviour customer)
    {
        int     index  = UnityEngine.Random.Range(0, _riddles.Count);
        Charade riddle = _riddles[index];

        _riddles.RemoveAt(index);
        customer.Riddle = riddle;
    }
Esempio n. 9
0
    private void SetupCustomer(GameObject customerObject, int entryIndex)
    {
        CustomerBehaviour custBehaviour = customerObject.GetComponent <CustomerBehaviour>();

        _customerPerEntry[entryIndex] = custBehaviour;
        custBehaviour.ID = entryIndex;
        custBehaviour.SetMovement(EntryPoints[entryIndex], HandleCustomerReach);
        OnCustomerSpawn.Invoke(custBehaviour);
    }
Esempio n. 10
0
 public void OnTriggerEnter(Collider other)
 {
     if (other.tag == "customer")
     {
         bScript          = other.GetComponent <CustomerBehaviour>();
         bScript.isCalled = false;
         DisplayLaptopOnCounter(true);
         chooseEvent();
     }
 }
Esempio n. 11
0
    void InitNextCustomer()
    {
        if (QuestInProgress)
        {
            //1 at a time
            return;
        }
        QuestInProgress = true;
        SetLostItem(GetRandomItem());                                                    //Pick a random lost item

        CustomerBehaviour NewCustomer = Instantiate(CustomerPrefab, CustomerSpawnPoint); //Create new customer

        NewCustomer.Set_SpeechBubbleIcon(LostItem.icon);                                 //Set the NPC speech bubble icon
        ListOfCustomers.Add(NewCustomer);                                                //Keep track of customers
    }
Esempio n. 12
0
    private void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Vector3 mousePos   = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            Vector2 mousePos2D = new Vector2(mousePos.x, mousePos.y);

            RaycastHit2D hit = Physics2D.Raycast(mousePos2D, Vector2.zero);
            if (hit.collider != null)
            {
                CustomerBehaviour customer = hit.collider.GetComponent <CustomerBehaviour>();
                if (customer.IsWaiting)
                {
                    SetRiddleLabel(customer);
                }
            }
        }
    }
Esempio n. 13
0
 private void SetRiddleLabel(CustomerBehaviour customer)
 {
     if (_currentCustomer != null && _currentCustomer.gameObject != null)
     {
         _currentCustomer.ExcMark.enabled = false;
     }
     _currentCustomer = customer;
     if (_currentCustomer)
     {
         RiddleLabel.text = customer.Riddle.charade;
         _currentCustomer.ExcMark.enabled = true;
         Debug.Log(customer.Riddle.answer);
     }
     else
     {
         RiddleLabel.text = "";
     }
 }
Esempio n. 14
0
    public void ProcessItemDrop(LostFoundItem lfItem, Action rejectCallback)
    {
        Vector3 pos = lfItem.transform.position;

        if (pos.y > BoardsTransform.position.y)
        {
            rejectCallback();
        }
        else
        {
            int   index     = 0;
            int   bestIndex = -1;
            float bestDist  = 1000000f;
            float dist;
            foreach (Transform t in BoardsTransform.Cast <Transform>().OrderBy(t => t.name))
            {
                dist = Vector3.Distance(t.position, pos);
                if (dist < bestDist)
                {
                    bestDist  = dist;
                    bestIndex = index;
                }
                index++;
            }
            CustomerBehaviour target = CustomerControl.GetCustomerAt(bestIndex);
            if (target == null) //no customer there
            {
                rejectCallback();
            }
            else if (!target.Riddle.answer.Equals(lfItem.Item))
            {
                //Wrong answer
                rejectCallback();
                OnWrongAnswer(lfItem, target);
            }
            else
            {
                //Right answer
                OnRightAnswer(lfItem, target);
            }
        }
    }
Esempio n. 15
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag == "customer")
        {
            CustomerBehaviour customerScript = other.GetComponent <CustomerBehaviour>();
            customerScript.isCalled           = true;
            customerScript.rendChassy.enabled = false;
            customerScript.rendLid.enabled    = false;
            StartCoroutine(TChangeText("Hello!", 2.5f));
        }

        else if (other.tag == "frontEmployee1")
        {
            tText = other.GetComponentInChildren <Text>();
        }

        else if (other.tag == "frontEmployee2")
        {
            tText2 = other.GetComponentInChildren <Text>();
        }
    }
Esempio n. 16
0
    //Handle the actual interaction
    void TryInteract(PlayerConstants.InteractMode mode, GameObject nearObj)
    {
        //Modes are drop and pickup
        switch (mode)
        {
        case PlayerConstants.InteractMode.Drop:
            //the player has something to drop?
            if (heldObjects.Count > 0)
            {
                switch (nearObj.tag)
                {
                //player is dropping object onto plate
                case GameConstants.PlateTag:
                    PlateBehaviour plate = nearObj.GetComponent <PlateBehaviour>();
                    //plate has no object stored
                    if (plate.heldObject.name == "")
                    {
                        var scoreObject = heldObjects.Dequeue();
                        if (scoreObject is Vegetable vegetable)
                        {
                            plate.heldObject = new Vegetable(vegetable);
                        }
                        else
                        {
                            plate.heldObject = new Salad((Salad)scoreObject);
                        }
                        didInteractThisFrame = true;
                    }
                    break;

                //player is dropping object onto customer
                case GameConstants.CustomerTag:
                    CustomerBehaviour customer = nearObj.GetComponent <CustomerBehaviour>();
                    //customer is active and ready for food
                    if (customer.canAcceptFood)
                    {
                        //dequeue object, getting ready to put it in front of customer
                        var activeObject = heldObjects.Dequeue();
                        if (activeObject is Salad salad1)
                        {
                            if (customer.submittedFood == null)
                            {
                                customer.submittedFood    = salad1;
                                customer.submittingPlayer = this;
                            }
                            //this shouldn't happen, but if there is a salad there already, put the salad we attempt to put there back
                            else
                            {
                                ScoreObject tempObject = null;
                                if (heldObjects.Count > 0)
                                {
                                    tempObject = heldObjects.Dequeue();
                                }
                                heldObjects.Enqueue(activeObject);
                                if (tempObject != null)
                                {
                                    heldObjects.Enqueue(tempObject);
                                }
                            }
                        }
                        //we can't give customers raw ingredients, put the thing back if it is not a salad
                        else
                        {
                            ScoreObject tempObject = null;
                            if (heldObjects.Count > 0)
                            {
                                tempObject = heldObjects.Dequeue();
                            }
                            heldObjects.Enqueue(activeObject);
                            if (tempObject != null)
                            {
                                heldObjects.Enqueue(tempObject);
                            }
                        }
                    }
                    didInteractThisFrame = true;
                    break;

                //player is dropping object onto cutting board
                case GameConstants.CuttingBoardTag:
                    CuttingBoardBehaviour cuttingBoard = nearObj.GetComponent <CuttingBoardBehaviour>();
                    //the cutting board is not busy, so objects can be dropped on it
                    if (!cuttingBoard.working)
                    {
                        var activeObject = heldObjects.Dequeue();
                        if (activeObject is Salad salad1)
                        {
                            if (cuttingBoard.activeSalad == null)
                            {
                                cuttingBoard.activeSalad = new Salad(salad1);
                                didInteractThisFrame     = true;
                            }
                            //there is already a salad there, so we shouldn't place one. Restore queue to previous state
                            else
                            {
                                ScoreObject tempObject = null;
                                if (heldObjects.Count > 0)
                                {
                                    tempObject = heldObjects.Dequeue();
                                }
                                heldObjects.Enqueue(activeObject);
                                if (tempObject != null)
                                {
                                    heldObjects.Enqueue(tempObject);
                                }
                            }
                        }
                        else if (activeObject is Vegetable vegetable)
                        {
                            //cutting board has no ingredients, and is ready to start chopping. Do so.
                            if (cuttingBoard.ingredient.name == "")
                            {
                                cuttingBoard.ingredient = new Vegetable(vegetable);
                                ProgressBarBehaviour progressBar = nearObj.GetComponentInChildren <ProgressBarBehaviour>();
                                progressBar.StartProgressBar(GameConstants.ChopTime);
                                isChopping           = true;
                                cuttingBoard.working = true;
                                StartCoroutine("DoChopping", cuttingBoard);
                                didInteractThisFrame = true;
                            }
                            //this shouldn't happen, but just in case restore queue to previous state
                            else
                            {
                                ScoreObject tempObject = null;
                                if (heldObjects.Count > 0)
                                {
                                    tempObject = heldObjects.Dequeue();
                                }
                                heldObjects.Enqueue(activeObject);
                                if (tempObject != null)
                                {
                                    heldObjects.Enqueue(tempObject);
                                }
                            }
                        }
                    }
                    break;

                //player is dropping object onto trash
                case GameConstants.TrashTag:
                default:
                    //get scene controller
                    var mainController = FindObjectOfType <MainSceneController>();
                    var droppedObject  = heldObjects.Dequeue();
                    //deduct points based on what player is throwing away
                    if (droppedObject is Salad salad)
                    {
                        switch (playerNumber)
                        {
                        case 1:
                            mainController.player1Score -= salad.GetIngredientCount() * GameConstants.ScorePerIngredient;
                            break;

                        case 2:
                            mainController.player2Score -= salad.GetIngredientCount() * GameConstants.ScorePerIngredient;
                            break;
                        }
                    }
                    else if (droppedObject is Vegetable)
                    {
                        switch (playerNumber)
                        {
                        case 1:
                            mainController.player1Score -= GameConstants.ScorePerIngredient;
                            break;

                        case 2:
                            mainController.player2Score -= GameConstants.ScorePerIngredient;
                            break;
                        }
                    }
                    break;
                }
            }
            break;

        //picking up food
        case PlayerConstants.InteractMode.PickUp:
            switch (nearObj.tag)
            {
            //player is picking up from vegetable dispenser
            case GameConstants.DispenserTag:
                VegetableDispenserBehaviour vegetableDispenser = nearObj.GetComponent <VegetableDispenserBehaviour>();
                //player has room for another item?
                if (heldObjects.Count < 2)
                {
                    heldObjects.Enqueue(new Vegetable(vegetableDispenser.vegetableType));
                }
                didInteractThisFrame = true;
                break;

            //player is picking up from plate
            case GameConstants.PlateTag:
                PlateBehaviour plate = nearObj.GetComponent <PlateBehaviour>();
                //plate has item and player can hold it?
                if (plate.heldObject.name != "" && heldObjects.Count < 2)
                {
                    if (plate.heldObject is Vegetable vegetable)
                    {
                        heldObjects.Enqueue(new Vegetable(vegetable));
                    }
                    else if (plate.heldObject is Salad salad)
                    {
                        heldObjects.Enqueue(new Salad(salad));
                    }
                    plate.heldObject = new ScoreObject();
                }
                didInteractThisFrame = true;
                break;

            case GameConstants.CuttingBoardTag:
                CuttingBoardBehaviour cuttingBoard = nearObj.GetComponent <CuttingBoardBehaviour>();
                //cutting board is not busy?
                if (!cuttingBoard.working)
                {
                    //cutting board has item to pick up and player can hold it?
                    if (cuttingBoard.activeSalad != null && heldObjects.Count < 2)
                    {
                        heldObjects.Enqueue(cuttingBoard.activeSalad);
                        cuttingBoard.activeSalad = null;
                        didInteractThisFrame     = true;
                    }
                }
                break;
            }
            break;
        }
        StringBuilder stringBuilder = new StringBuilder();

        foreach (var vegetable in heldObjects)
        {
            stringBuilder.Append(string.Format("{0}\n", vegetable.name));
        }
        //set player text to the names of the items held
        text.text = stringBuilder.ToString();
    }