Example #1
0
    public void SetNextDestination()
    {
        if (_stateMachine.navMeshAgent != null &&
            !_stateMachine.navMeshAgent.pathPending &&
            !_stateMachine.navMeshAgent.hasPath &&
            _stateMachine.currentTarget == null &&
            !_reachedLastDestination)
        {
            _currentDestination++;
            if (_currentDestination >= _destinations.Count)
            {
                _currentDestination = 0;
                // We do the metamorphosis if possible
                _stateMachine.MetamorphosisTrigger();

                // We are also going to prevent the player from moving
                GoneWrong.Player.instance.canMove = false;

                if (_reachedDestinationEvents != null)
                {
                    _reachedDestinationEvents.Invoke();
                }

                _reachedLastDestination = true;
                return;
            }

            Target target = new Target();
            target.transform = _destinations[_currentDestination];
            target.type      = TargetType.Audio;
            target.position  = _destinations[_currentDestination].position;

            _stateMachine.currentTarget = target;
        }
    }