예제 #1
0
    private List <InteractableIdentifier> IdentifyInteractables(Vector3 center, float range)
    {
        Collider[] interactableObjects       = Physics.OverlapSphere(center, range);
        Collider[] unInteractableObjects     = Physics.OverlapSphere(center, range + 2);
        List <InteractableIdentifier> result = new List <InteractableIdentifier>();

        foreach (Collider item in interactableObjects)
        {
            InteractableIdentifier id = item.GetComponent <InteractableIdentifier>();
            if (id)
            {
                if (_interactables.Contains(id))
                {
                    continue;
                }
                result.Add(id);
            }
        }

        foreach (Collider item in unInteractableObjects)
        {
            InteractableIdentifier id = item.GetComponent <InteractableIdentifier>();
            if (id)
            {
                if (_interactables.Contains(id))
                {
                    continue;
                }
                id.HideUI();
            }
        }
        return(result);
    }
예제 #2
0
    private void HandleInteraction(InteractableIdentifier id)
    {
        if (id.interactionType == InteractionType.QuestObject && !_hasItem)
        {
            // Acquired questItem
            _hasItem            = true;
            _holdingItem        = id.GetComponent <DisplayQuestObject>().MyQuestObject;
            _pathCreator.Target = _db.PrefabDB[_holdingItem.QuestNpc.ToString()].transform;
            if (!AcquiredQuestObjectProjectionParent.transform.HasChild())
            {
                id.GetComponent <InteractableIdentifier>().MyUIElement.gameObject.SetActive(false);

                GameObject questObjectSpriter = GameObject.Instantiate(id.gameObject, AcquiredQuestObjectProjectionParent.transform, false);
                questObjectSpriter.transform.Reset();

                questObjectSpriter.transform.Rotate(_holdingItem.RotateEulers);

                dialogManagement.InteractWithQuestObject(_holdingItem.QuestNpc);
                id.gameObject.SetActive(false);
            }
        }
        if (id.interactionType == InteractionType.Npc)
        {
            DisplayQuestObject displayQuestObject = id.GetComponent <DisplayQuestObject>();
            if (!displayQuestObject)
            {
                Npc_SO npc = id.GetComponent <NpcDisplay>().MyNPC;
                if (_hasItem)
                {
                    // Item Dialogs
                    QuestTracker.questObjectTracker[(QuestTracker.CurrentPhaseName, _holdingItem.KeyName)] = true;
예제 #3
0
    public void GetInteraction(float cursorPosx, float cursorPosy)
    {
        Vector2 cursorPos = new Vector2(cursorPosx, cursorPosy);

        if (!TalkingScreen.activeSelf)
        {
            Ray r = mainCamera.GetComponent <Camera>().ScreenPointToRay(cursorPos);
            if (Physics.Raycast(r, out RaycastHit hit, 100f, ~Ignore))
            {
                InteractableIdentifier id = hit.transform.GetComponent <InteractableIdentifier>() ?? hit.transform.parent.GetComponent <InteractableIdentifier>() ?? hit.transform?.parent?.parent?.GetComponent <InteractableIdentifier>();
                if (id)
                {
                    if (_interactables.Contains(id))
                    {
                        HandleInteraction(id);
                    }
                }
            }
        }
    }