当前位置: 首页>>代码示例>>C#>>正文


C# Path.Pop方法代码示例

本文整理汇总了C#中Path.Pop方法的典型用法代码示例。如果您正苦于以下问题:C# Path.Pop方法的具体用法?C# Path.Pop怎么用?C# Path.Pop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Path的用法示例。


在下文中一共展示了Path.Pop方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetPath

        private void SetPath(Path path, bool isWaypoint)
        {
            _endOfResolvedPath = path.Last().position;
            _currentGrid = GridManager.instance.GetGrid(path.Peek().position);

            if (isWaypoint)
            {
                _remainingPathDistance += path.CalculateLength();

                _currentPath = _currentPath.AppendSegment(path);
            }
            else
            {
                if (!TrimPath(path))
                {
                    RequestPath(_transform.position, _wayPoints.desiredEndOfPath, InternalPathRequest.Type.Normal);
                    _currentPath = null;
                    return;
                }

                _currentPath = path;
                _remainingPathDistance = path.CalculateLength();

                //Pop the first node as our next destination.
                _currentDestination = path.Pop();
                _curPlannedDirection = _transform.position.DirToXZ(_currentDestination.position);
            }

            _unit.hasArrivedAtDestination = false;
        }
开发者ID:andrewstarnes,项目名称:wwtd2,代码行数:30,代码来源:SteerForPathComponent.cs

示例2: SetManualPath

        private void SetManualPath(Path path, ReplanCallback onReplan)
        {
            if (path == null || path.count == 0)
            {
                StopInternal();
                return;
            }

            _stop = false;
            _stopped = false;
            _onFinalApproach = false;
            _manualReplan = onReplan;
            _currentPath = path;
            _endOfResolvedPath = _currentPath.Last().position;
            _currentDestination = path.Pop();
            _currentGrid = GridManager.instance.GetGrid(_currentDestination.position);

            _endOfPath = _endOfResolvedPath;
            _lastPathRequestTime = Time.time;
        }
开发者ID:forwolk,项目名称:UnityApex,代码行数:20,代码来源:SteerForPathComponent.cs

示例3: CompletePathSegment

        private bool CompletePathSegment(PathingStatus status)
        {
            if (status != PathingStatus.Complete)
            {
                return false;
            }

            _currentResult.pathCost += _goal.g;

            //Fix the actual destination so it does not overlap obstructions
            FixupGoal(_segmentRequest);

            if (_segmentRequest.type == RequestType.IntelOnly)
            {
                return true;
            }

            var maxPathLength = Mathf.CeilToInt(_goal.g / (_goal.parent.cellSize * _costProvider.baseMoveCost));

            Path pathSegment;
            if (_segmentRequest.pathFinderOptions.usePathSmoothing)
            {
                pathSegment = _smoother.Smooth(_goal, maxPathLength, _segmentRequest, _cellCostStrategy);
            }
            else
            {
                pathSegment = new Path(maxPathLength);

                //Push the actual end position as the goal
                pathSegment.Push(new Position(_segmentRequest.to));

                IPathNode current = _goal.predecessor;
                while (current != null)
                {
                    pathSegment.Push(current);
                    current = current.predecessor;
                }

                //Instead of testing for it in the while loop, just pop off the start node and replace it with the actual start position
                if (pathSegment.count > 1)
                {
                    pathSegment.Pop();
                }

                pathSegment.Push(new Position(_segmentRequest.from));
            }

            _segments.Add(pathSegment);

            return true;
        }
开发者ID:andrewstarnes,项目名称:wwtd2,代码行数:51,代码来源:PathingEngineBase.cs

示例4: ConsumeResult

        private bool ConsumeResult()
        {
            //Since result processing may actually repath and consequently a new result may arrive we need to operate on locals and null the pending result
            PathResult result;
            lock (_syncLock)
            {
                result = _pendingResult;
                _pendingResult = null;
            }

            var req = result.originalRequest as InternalPathRequest;

            //Consume way points if appropriate. This must be done prior to the processing of the result, since if the request was a way point request, the first item in line is the one the result concerns.
            if (req.pathType == InternalPathRequest.Type.Waypoint)
            {
                _wayPoints.Dequeue();
            }
            else if (req.pathType == InternalPathRequest.Type.PathboundWaypoint)
            {
                _pathboundWayPoints.Dequeue();
            }

            //Reset current destination and path no matter what
            _previousDestination = _transform.position;
            _currentDestination = null;
            _currentPath = null;

            //Process the result
            if (!ProcessAndValidateResult(result))
            {
                return false;
            }

            //Consume the result
            _onFinalApproach = false;
            _currentPath = result.path;
            _currentGrid = req.fromGrid;
            _remainingSquaredDistance = _currentPath.CalculateSquaredLength();
            _endOfResolvedPath = _currentPath.Last().position;
            _endOfPath = _endOfResolvedPath;

            //Update pending way points
            UpdatePathboundWaypoints(result.pendingWaypoints);

            //Pop the first node as our next destination.
            _unit.hasArrivedAtDestination = false;
            _currentDestination = _currentPath.Pop();
            return true;
        }
开发者ID:forwolk,项目名称:UnityApex,代码行数:49,代码来源:SteerForPathComponent.cs


注:本文中的Path.Pop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。