Exemplo n.º 1
0
 //------------------------------------------------------------------------------
 //
 //------------------------------------------------------------------------------
 public float onEvaluateHCost(AStarPathFinder finder, Vec2<short> curPos, Vec2<short> endPos)
 {
     return (float)(Math.Abs(endPos.x - curPos.x) + Math.Abs(endPos.y - curPos.y));
 }
 //------------------------------------------------------------------------------
 //
 //------------------------------------------------------------------------------
 public float onEvaluateHCost(AStarPathFinder finder, Vec2<short> curPos, Vec2<short> endPos)
 {
     int dx = Math.Abs(endPos.x - curPos.x);
     int dy = Math.Abs(endPos.y - curPos.y);
     return (float)Math.Pow(Math.Pow(dx, 2) + Math.Pow(dy, 2), 0.5);
 }
 //------------------------------------------------------------------------------
 //
 //------------------------------------------------------------------------------
 public float onEvaluateHCost(AStarPathFinder finder, Vec2<short> curPos, Vec2<short> endPos)
 {
     int d1 = Math.Abs(endPos.x - curPos.x);
     int d2 = Math.Abs(endPos.y - curPos.y);
     return Math.Max(d1, d2);
 }