public uint CalculateHScore (GraphNode node) {
uint v1;
uint v2;
switch (heuristic) {
case Heuristic.Euclidean:
v1 = (uint)(((GetHTarget () - node.position).costMagnitude)*heuristicScale);
v2 = hTargetNode != null ? AstarPath.active.euclideanEmbedding.GetHeuristic ( node.NodeIndex, hTargetNode.NodeIndex ) : 0;
return System.Math.Max (v1,v2);
case Heuristic.Manhattan:
Int3 p2 = node.position;
v1 = (uint)((System.Math.Abs (hTarget.x-p2.x) + System.Math.Abs (hTarget.y-p2.y) + System.Math.Abs (hTarget.z-p2.z))*heuristicScale);
v2 = hTargetNode != null ? AstarPath.active.euclideanEmbedding.GetHeuristic ( node.NodeIndex, hTargetNode.NodeIndex ) : 0;
return System.Math.Max (v1,v2);
case Heuristic.DiagonalManhattan:
Int3 p = GetHTarget () - node.position;
p.x = System.Math.Abs (p.x);
p.y = System.Math.Abs (p.y);
p.z = System.Math.Abs (p.z);
int diag = System.Math.Min (p.x,p.z);
int diag2 = System.Math.Max (p.x,p.z);
v1 = (uint)((((14*diag)/10) + (diag2-diag) + p.y) * heuristicScale);
v2 = hTargetNode != null ? AstarPath.active.euclideanEmbedding.GetHeuristic ( node.NodeIndex, hTargetNode.NodeIndex ) : 0;
return System.Math.Max (v1,v2);
}
return 0U;
}