Пример #1
0
    void Update()
    {
        //Debug.Log(_currentState);
        if (_lineOfSight.IsInSight) //&& _squirrel.isVisible())
        {
            _currentState = BeetleStates.ChasingSquirrel;
        }
        else if (_currentState != BeetleStates.ChasingSound)
        {
            _currentState = BeetleStates.Patrolling;
        }

        switch (_currentState)
        {
        case BeetleStates.Patrolling:
            patrol();
            break;

        case BeetleStates.ChasingSquirrel:
            chase(_lineOfSight.inSight.position);
            break;

        case BeetleStates.ChasingSound:
            chase(_soundToChasePosition);
            if (InRange(_soundToChasePosition, radiusOfSoundToChase))
            {
                _currentState = BeetleStates.Patrolling;
            }
            break;
        }
    }
Пример #2
0
 public void hearSound(Vector3 sourcePoint)
 {
     if (_currentState != BeetleStates.ChasingSquirrel && InRange(sourcePoint, radiusOfHearing))
     {
         _soundToChasePosition = sourcePoint;
         _currentState         = BeetleStates.ChasingSound;
     }
 }
Пример #3
0
 void Awake()
 {
     _lineOfSight = GetComponent <LineOfSight>();
     //_squirrel = (Squirrel3D)FindObjectOfType(typeof(Squirrel3D));
     _lineOfSight.Target = _squirrel;
     _flocking           = GetComponent <Flocking>();
     _currentState       = BeetleStates.Patrolling;
     _currentWaypoint    = startPath;
     _flocking.Target    = _currentWaypoint.transform.position;
 }