private Tile addToAStarHighlight(Tile toadd, Tile prev) { int x = toadd.getX(); int y = toadd.getY(); int mapx = toadd.getMapX(); int mapy = toadd.getMapY(); int len = toadd.getLength(); if(DEBUG) Console.WriteLine("Adding tile at (" + mapx + "," + mapy + ") to bestpath! Cost is " + toadd.getTotalCost()); Tile newadd = new Tile(mapx, mapy, x, y, len, new Tool(WorldTile.BLACK, astarwaypoint)); newadd.setPrevious(prev); return newadd; }
private void addTile(Tile toadd, Tile prev, List<Tile> open, Tile goal) { if (DEBUG) { Console.WriteLine("Adding node (" + toadd.getMapX() + "," + toadd.getMapY() + "), with cost " + toadd.getTotalCost() + " to open list, open count is = " + open.Count); if (prev != null) Console.WriteLine("Previous is (" + prev.getMapX() + "," + prev.getMapY() + ")"); else Console.WriteLine("Previous is null!"); } toadd.setPrevious(prev); int distance = getCumulativeCost(toadd); //int distance = 0; toadd.addToTotalCost(distance + Math.Abs(toadd.getMapX() - goal.getMapX()) + Math.Abs(toadd.getMapY() - goal.getMapY())); open.Add(toadd); if (DEBUG) Console.WriteLine("Node added."); }