예제 #1
0
 void TryToChaseTarget(Transform lastSeenPlace)
 {
     if (lastSeenPlace != null && _myNavMeshAgent != null && Time.time > _nextCheck && isServer) //&& !_botMaster.isNavPaused
     {
         _nextCheck = Time.time + _checkRate;
         _myNavMeshAgent.ResetPath();
         _myNavMeshAgent.stoppingDistance = 4f;
         _myNavMeshAgent.acceleration     = 8f;
         _myNavMeshAgent.SetDestination(lastSeenPlace.position);
         _botMaster.CallEventEnemyWalk(lastSeenPlace.position);
     }
 }
예제 #2
0
    void RandomDodgeTarget()
    {
        if (!isServer)
        {
            return;
        }

        Vector3 randomPoint;

        do
        {
            randomPoint = transform.position + Random.insideUnitSphere * _dodgeRange;
        }while(!(NavMesh.SamplePosition(randomPoint, out _navHit, 10f, GameConstants.WalkableLayer) && Vector3.Distance(transform.position, _navHit.position) > 2));
        _isDodging           = true;
        _botMaster.isOnRoute = true;
        _navMeshAgent.SetDestination(_navHit.position);
        _botMaster.CallEventEnemyWalk(_navHit.position);
    }
예제 #3
0
    void SearchInPatrols()
    {
        //Usage: Bot searches in predifined places
        //get a random portal not equal to the current one
        if (!_isEnemySeen && _isCurrentTargetReached && _nextCheck < Time.time)
        {
            _nextCheck = Time.time + _checkRate;

            int       nextPatrolIndex = Random.Range(0, _patrolPoints.Count - 1);
            Transform nextPatrol      = (Transform)_patrolPoints[nextPatrolIndex];

            if (nextPatrol != _currentTargetPatrol && !_botMaster.isOnRoute && !_botMaster.isNavPaused)
            {
                _isCurrentTargetReached = false;
                _currentTargetPatrol    = nextPatrol;
                _myNavMeshAgent.SetDestination(nextPatrol.position);
                _botMaster.CallEventEnemyWalk(nextPatrol.position);
            }
            else
            {
                SearchInPatrols();
            }
        }
    }