Example #1
0
        protected virtual void Update()
        {
            switch (_state)
            {
            case State.Initialize:
                InitLerp(0);
                _state = State.Running;
                break;

            case State.Running:
                var effectiveSpeed = CalculateEffectiveSpeed();
                var deltaTime      = _gameManager.GetDeltaTime();
                _lerpPosition += (effectiveSpeed * deltaTime) / _lerpLength;
                LerpPosition(_lerpPosition);
                if (_lerpPosition >= 1.0f)
                {
                    if (_currentIndex < _path.Length - 2)
                    {
                        InitLerp(_currentIndex + 1);
                    }
                    else
                    {
                        _state = State.Finished;
                        _gameManager.EnemyExits(this);
                    }
                }
                break;
            }
        }