Ejemplo n.º 1
0
    void Update()
    {
        PlayerCanvas.ClearHint();
        if (!GameManager.FirstPersonMode)
        {
            return;
        }

        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, RaycastRange, ObjectsLayer, QueryTriggerInteraction.Collide))
        {
            if (!hit.collider.CompareTag(InteractiveTag))
            {
                return;
            }

            _currentSelection = hit.collider.GetComponent <InteractiveObject>();
            if (_currentSelection != null)
            {
                PlayerCanvas.ShowHint(_currentSelection.Title.ToUpper());
            }

            if (HasSelection)
            {
                if (Input.GetButtonDown(UseCmd))
                {
                    if (hit.distance > InteractionRange)
                    {
                        DialogueManager.PlayDialogue("toofar");
                        return;
                    }
                    _currentSelection.Use();
                    _currentSelection = null;
                }
                else if (Input.GetButtonDown(ExamineCmd))
                {
                    if (hit.distance > InteractionRange)
                    {
                        DialogueManager.PlayDialogue("toofar");
                        return;
                    }
                    _currentSelection.Examine();
                    _currentSelection = null;
                }
                else if (Input.GetButtonDown(CombineCmd))
                {
                    if (hit.distance > InteractionRange)
                    {
                        DialogueManager.PlayDialogue("toofar");
                        return;
                    }

                    _currentSelection.Combine();
                    _currentSelection = null;
                }
            }
        }
        else
        {
            _currentSelection = null;
        }
    }