예제 #1
0
    public override void Interact()
    {
        if (isUsed)
        {
            return;
        }
        base.Interact();

        //Debug.Log("[ButtonInteractable] Interacting with " + transform.name);

        //Disable Interaction if this is one-time only
        if (!disableInteraction)
        {
            //If key is not needed or was already used
            if (!useKey || keyWasUsed)
            {
                interaction.Action();

                if (oneTimeUse)
                {
                    disableInteraction = true;
                }
            }
            //if key is needed
            else
            {
                if (PlayerController.UseKey())
                {
                    interaction.Action();
                    keyWasUsed = true;
                    if (oneTimeUse)
                    {
                        disableInteraction = true;
                    }
                }
            }
        }
    }
예제 #2
0
    void DoAction()
    {
        Collider[] hitColliders = Physics.OverlapSphere(transform.position, radius);
        int        i            = 0;

        while (i < hitColliders.Length)
        {
            Interaction interaction = hitColliders[i].GetComponent <Interaction>();
            if (interaction != null)
            {
                interaction.Action();
            }
            i++;
        }

        lastActionTime = Time.time;
    }