Exemplo n.º 1
0
    void OnMouseDown()
    {
        audioSource.PlayOneShot(audioClip);

        //Debug.Log("Clicked an NPC");
        if (objectController.HasItem(giveTag.ToString()))
        {
            DisplayDialogue(hasItem);
            return;
        }

        if (objectController.HasItem(requiredTag.ToString()))
        {
            //give item
            objectController.PickUpItem(giveTag.ToString());
            //show succes dialogue
            DisplayDialogue(giveItemSucceed);
            //play HandingOver animation
            animator.SetTrigger("GiveItem");
        }
        else
        {
            DisplayDialogue(giveItemFail);

            //show fail dialogue
        }
        //dialogueWindow.SetActive(true);
        //GetComponent<DialogueTrigger>().TriggerDialogue();
    }
    public void PickUp()
    {
        bool canPickup = false;

        if (controller == null)
        {
            GameObject player = GameObject.FindWithTag("Player");
            controller = player.GetComponent <ObjectController>();
        }

        if (requiredTag.ToString() != "Blank")
        {
            if (controller.HasRemoveItem(requiredTag.ToString()))
            {
                canPickup = true;
            }

            else
            {
                Debug.Log("You are missing the item" + requiredTag.ToString());
            }
        }
        else
        {
            canPickup = true;
        }

        if (canPickup)
        {
            hasItem = true;
            controller.PlayAudio(audioFile);
            controller.animator.SetTrigger("Grab");
            itemIcon.SetActive(true);
            DisableObjectVisual();

            Debug.Log("Picked up item " + itemTag.ToString());
        }
    }