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


C# FastList.Reverse方法代码示例

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


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

示例1: FindPath


//.........这里部分代码省略.........
                    retX = (steep ? y : x);
                    retY = (steep ? x : y);

                    if (GridManager.Grid [retX * GridManager.NodeCount + retY].Unwalkable) {
                        break;
                    } else if (x == x1) {
                        OutputPath.FastClear ();
                        OutputPath.Add (startNode);
                        OutputPath.Add (endNode);
                        return true;
                    }

                    error = error - dy;
                    if (error < 0) {
                        y += ystep;
                        error += dx;
                    }
                }
                #endregion
            }

            GridHeap.FastClear ();
            GridClosedSet.FastClear ();
            #endregion

            #region AStar Algorithm
            GridHeap.Add (startNode);
            GridNode.HeuristicTargetX = endNode.gridX;
            GridNode.HeuristicTargetY = endNode.gridY;
            while (GridHeap.Count > 0) {
                currentNode = GridHeap.RemoveFirst ();

                GridClosedSet.Add (currentNode);

                if (currentNode.gridIndex == endNode.gridIndex) {
                    OutputPath.FastClear ();

                    //Retraces the path then outputs it into OutputPath
                    //Also Simplifies the path

                    oldNode = endNode;
                    currentNode = endNode.parent;

                    oldX = int.MaxValue;
                    oldY = int.MaxValue;

                    StartNodeIndex = startNode.gridIndex;

                    //if (!endNode.Obstructed) OutputPath.Add (endNode);

                    while (oldNode.gridIndex != StartNodeIndex) {
                        newX = currentNode.gridX - oldNode.gridX;
                        newY = currentNode.gridY - oldNode.gridY;
                        if ((newX != oldX || newY != oldY))
                        {
                            OutputPath.Add (oldNode);
                            oldX = newX;
                            oldY = newY;
                        }

                        oldNode = currentNode;
                        currentNode = currentNode.parent;
                    }

                    OutputPath.Add (startNode);
                    OutputPath.Reverse ();
                    return true;
                }

                for (i = 0; i < 8; i++) {
                    neighbor = currentNode.NeighborNodes [i];

                    if (neighbor == null|| neighbor.Unwalkable || GridClosedSet.Contains (neighbor)) {
                        continue;
                    }

                    newMovementCostToNeighbor = currentNode.gCost + (currentNode.NeighborDiagnal [i] ? 141 : 100);

                    if (!GridHeap.Contains (neighbor)) {
                        neighbor.gCost = newMovementCostToNeighbor;

                        //Optimized heuristic calculation
                        neighbor.CalculateHeurustic ();
                        neighbor.parent = currentNode;

                        GridHeap.Add (neighbor);
                    } else if (newMovementCostToNeighbor < neighbor.gCost) {
                        neighbor.gCost = newMovementCostToNeighbor;

                        //Optimized heuristic calculation
                        neighbor.CalculateHeurustic ();
                        neighbor.parent = currentNode;

                        GridHeap.UpdateItem (neighbor);
                    }
                }
            }
            #endregion
            return false;
        }
开发者ID:B1sounours,项目名称:Lockstep-Framework,代码行数:101,代码来源:Pathfinder.cs


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