Пример #1
0
        public static PillPath NearestPill(Node currentNode, GameState gs)
        {
            Node bestNode = null;

            Node.PathInfo bestPath = null;
            foreach (Node node in gs.Map.PillNodes)
            {
                //if( node.Walkable ) {
                //	if( node.Type == Node.NodeType.Pill || node.Type == Node.NodeType.PowerPill ) {
                if (bestPath == null)
                {
                    bestNode = node;
                    bestPath = gs.Pacman.Node.ShortestPath[node.X, node.Y];
                    continue;
                }
                Node.PathInfo curPath = currentNode.ShortestPath[node.X, node.Y];
                if (curPath != null && curPath.Distance < bestPath.Distance)
                {
                    bestNode = node;
                    bestPath = curPath;
                }
                //	}
                //}
            }
            return(new PillPath(bestNode, bestPath));
        }
Пример #2
0
        public List <Node> GetRoute(int startX, int startY, int endX, int endY)
        {
            Node.PathInfo pathInfo = Nodes[startX, startY].ShortestPath[endX, endY];
            if (pathInfo == null)
            {
                //Console.WriteLine("No path from " + startX + "," + startY + " to " + endX + "," + endY);
                return(null);
            }
            List <Node> path    = new List <Node>();
            Node        curNode = Nodes[startX, startY];

            while (!(curNode.X == endX && curNode.Y == endY))
            {
                curNode = curNode.GetNode(curNode.ShortestPath[endX, endY].Direction);
                path.Add(curNode);
            }
            return(path);
        }
Пример #3
0
 public PillPath(Node target, Node.PathInfo pathInfo)
 {
     this.Target   = target;
     this.PathInfo = pathInfo;
 }