Esempio n. 1
0
        internal override string DebugString(PathLog logMode)
        {
            if (logMode == PathLog.None || (!error && logMode == PathLog.OnlyErrors))
            {
                return("");
            }

            System.Text.StringBuilder text = pathHandler.DebugStringBuilder;
            text.Length = 0;

            DebugStringPrefix(logMode, text);

            if (!error)
            {
                text.Append("\nShortest path was ");
                text.Append(chosenTarget == -1 ? "undefined" : nodePaths[chosenTarget].Count.ToString());
                text.Append(" nodes long");

                if (logMode == PathLog.Heavy)
                {
                    text.Append("\nPaths (").Append(targetsFound.Length).Append("):");
                    for (int i = 0; i < targetsFound.Length; i++)
                    {
                        text.Append("\n\n	Path ").Append(i).Append(" Found: ").Append(targetsFound[i]);

                        if (nodePaths[i] != null)
                        {
                            text.Append("\n		Length: ");
                            text.Append(nodePaths[i].Count);

                            GraphNode node = nodePaths[i][nodePaths[i].Count - 1];

                            if (node != null)
                            {
                                PathNode nodeR = pathHandler.GetPathNode(endNode);
                                if (nodeR != null)
                                {
                                    text.Append("\n		End Node");
                                    text.Append("\n			G: ");
                                    text.Append(nodeR.G);
                                    text.Append("\n			H: ");
                                    text.Append(nodeR.H);
                                    text.Append("\n			F: ");
                                    text.Append(nodeR.F);
                                    text.Append("\n			Point: ");
                                    text.Append(((Vector3)endPoint).ToString());
                                    text.Append("\n			Graph: ");
                                    text.Append(endNode.GraphIndex);
                                }
                                else
                                {
                                    text.Append("\n		End Node: Null");
                                }
                            }
                        }
                    }

                    text.Append("\nStart Node");
                    text.Append("\n	Point: ");
                    text.Append(((Vector3)endPoint).ToString());
                    text.Append("\n	Graph: ");
                    text.Append(startNode.GraphIndex);
                    text.Append("\nBinary Heap size at completion: ");
                    text.AppendLine(pathHandler.heap == null ? "Null" : (pathHandler.heap.numberOfItems - 2).ToString());                    // -2 because numberOfItems includes the next item to be added and item zero is not used
                }
            }

            DebugStringSuffix(logMode, text);

            return(text.ToString());
        }
Esempio n. 2
0
 public override bool TargetFound(PathNode node)
 {
     return(node.G >= maxGScore);
 }