Example #1
0
    // Update is called once per frame
    void Update()
    {
        movement.x = Input.GetAxisRaw("Horizontal");
        movement.y = Input.GetAxisRaw("Vertical"); //movement using wasd or arrow keys


        if (Input.GetKeyDown(KeyCode.E))
        {
            if (nearCheckout && checkoutTrigger.customerNear)
            {
                checkoutTrigger.StartCheckout();
                return;
            }

            if (nearCustomer)
            {
                //closestCustomer.GetComponent<DialogueTrigger>().TriggerDialogue();
                //UpdateStress(closestCustomer.GetComponent<DialogueTrigger>().causedStress); //make more efficent later
            }

            else if (currentInteraction != null)   //prioritizes customers over items, may need to change how this works later
            {
                if (itemScript.hasPrerequisite)
                {
                    hasPrerequisite = inventoryManager.itemCheck(itemScript.prerequisite); //true if prerequisite is held false if not

                    if (!hasPrerequisite)                                                  //end interaction
                    {
                        return;                                                            //show no prereq message here
                    }
                }
                if (itemScript.canHold)
                {
                    inventoryManager.addItem(itemScript.itemName, itemScript.amount);
                    Destroy(currentInteraction);  //Adds item to inventory and removes from overworld
                    //maybe only pickup 1 at a time, and only destroy if 0 left?
                }

                else if (itemScript.isMiniGameTrigger)
                {
                    UpdateStress(itemScript.causedStress);
                    itemScript.StartInteraction();

                    //trigger minigame
                }
            }
        }
    }