Ejemplo n.º 1
0
        public override void Step()
        {
            // Base case
            if (_fullTilesComplete >= (_path.Length - 1))
            {
                _context.WorkerContext().ClearJob();
                return;
            }

            // 1 speed ~= 1 tile/second
            _tilesComplete += _mover.GetSpeed() * _context.gameManager.DeltaTime;

            // When a "full step is completed"
            if ((int)_tilesComplete > _fullTilesComplete)
            {
                // Update "full step" progress tracker
                _fullTilesComplete = (int)_tilesComplete;

                // Prevent "over step" edge case
                if (_fullTilesComplete >= _path.Length)
                {
                    _fullTilesComplete = _path.Length - 1;
                }

                // Update unit state
                _context.OwnerContext().SetPosition(_path[_fullTilesComplete]);
            }
        }