Beispiel #1
0
        private IEnumerator AttackState()
        {
            _currentState    = AIEnemyState.ATTACK;
            _attackRateTimer = _attackRate;
            _personMover.Stop();

            while (_currentState == AIEnemyState.ATTACK)
            {
                if (DistanceToTarget() > _attackRange)
                {
                    SetState(AIEnemyState.IDLE);
                }

                _attackRateTimer += Time.deltaTime;
                if (_attackRateTimer >= _attackRate)
                {
                    _enemyAnimations.Attack();
                    _attackRateTimer = 0;
                }
                yield return(null);
            }
        }