Exemplo n.º 1
0
    // Display interaction message panel with reference to an item's interation text
    public void OpenMessagePanel(InteractableObjectBase item)
    {
        MessagePanel.SetActive(true);

        Text mpText = MessagePanel.transform.Find("Text").GetComponent <Text>();

        mpText.text = item.InteractText;

        mIsMessagePanelOpened = true;
    }
Exemplo n.º 2
0
    private void OnTriggerExit(Collider other)
    {
        // If the player leaves a trigger zone, hide the interaction prompt
        InteractableObjectBase item = other.GetComponent <InteractableObjectBase>();

        // Only remove the prompt if the item being left is the current item
        if (item == mInteractItem)
        {
            Hud.CloseMessagePanel();
            mInteractItem = null;
        }
    }
Exemplo n.º 3
0
    private void OnTriggerEnter(Collider other)
    {
        InteractableObjectBase item = other.GetComponent <InteractableObjectBase>();

        // If inside a trigger zone with a triggerable item, and the player is able to interact, display the interaction prompt to the user
        if (item != null)
        {
            if (item.CanInteract(heldItem))
            {
                mInteractItem = item;
                Hud.OpenMessagePanel(mInteractItem);
            }
        }
    }