public InteractWithNearestState(NavMeshAgent agent, GameObject goal)
 {
     _agent              = agent;
     cam                 = _agent.gameObject.GetComponent <CharacterAnimMovement>();
     _intaractableGoal   = goal.GetComponent <IInteractable>();
     _interactGameObject = goal;
 }
 public InteractWithNearestState(NavMeshAgent agent, GameObject goal)
 {
     _agent = agent;
     cam = _agent.gameObject.GetComponent<CharacterAnimMovement>();
     _intaractableGoal = goal.GetComponent<IInteractable>();
     _interactGameObject = goal;
 }
        public InteractWithNearestState(NavMeshAgent agent, string tag, GameObject pickup)
        {
            _agent = agent;

            cam = _agent.gameObject.GetComponent<CharacterAnimMovement>();

            _interactGameObject = pickup;

            var interactables = GameObject.FindGameObjectsWithTag(tag);
            if (interactables.Length < 1)
            {
                GameObject.FindGameObjectWithTag("AudioManager").GetComponent<AudioManager>().FemaleNoSoundPlay();
                _state = State.Done;
                return;
            }

            foreach (var i in interactables)
            {
                _interactGameObject = i;
                var dest = i.GetComponent<IInteractable>();
                if(!dest.CanThisBeInteractedWith(pickup)) continue;
                var path = new NavMeshPath();
                agent.CalculatePath(dest.InteractPosition(_agent.transform.position), path);

                if (path.status != NavMeshPathStatus.PathComplete) continue;

                _intaractableGoal = dest;
                break;
            }

            if(_intaractableGoal == null)
                _state = State.Done;
        }
        public InteractWithNearestState(NavMeshAgent agent, string tag, GameObject pickup)
        {
            _agent = agent;

            cam = _agent.gameObject.GetComponent <CharacterAnimMovement>();

            _interactGameObject = pickup;

            var interactables = GameObject.FindGameObjectsWithTag(tag);

            if (interactables.Length < 1)
            {
                GameObject.FindGameObjectWithTag("AudioManager").GetComponent <AudioManager>().FemaleNoSoundPlay();
                _state = State.Done;
                return;
            }

            foreach (var i in interactables)
            {
                _interactGameObject = i;
                var dest = i.GetComponent <IInteractable>();
                if (!dest.CanThisBeInteractedWith(pickup))
                {
                    continue;
                }
                var path = new NavMeshPath();
                agent.CalculatePath(dest.InteractPosition(_agent.transform.position), path);

                if (path.status != NavMeshPathStatus.PathComplete)
                {
                    continue;
                }

                _intaractableGoal = dest;
                break;
            }

            if (_intaractableGoal == null)
            {
                _state = State.Done;
            }
        }