static public void BStarStep(NLocate src, NLocate dst, NMap map, List <int> bufferIndex, NPathNode pathList) { if (src.Equals(dst)) { Console.WriteLine("FindPath with B*"); GPath = new List <NLocate>(pathList.GetPath()); return; } var dstLoc = src.NearLocTo(dst); if (!map.Alive(dstLoc)) { bufferIndex.Add(dstLoc.ToIndex(map)); BStarStep(dstLoc, dst, map, bufferIndex, pathList.AddChild(dstLoc.X, dstLoc.Y)); } else { foreach (var l in src.Branch(dstLoc)) { if (!bufferIndex.Contains(l.ToIndex(map.Width)) && !map.Alive(l)) { bufferIndex.Add(l.ToIndex(map)); BStarStep(l, dst, map, bufferIndex, pathList.AddChild(l.X, l.Y)); } } } }
public IEnumerable <NLocate> LineTo(NLocate dst) { NLocate curLoc = this; while (true) { curLoc = curLoc.NearLocTo(dst); if (curLoc.Equals(dst)) { yield break; } yield return(curLoc); } }