第一次提交
This commit is contained in:
49
Assets/Scripts/PathFinding/PathFinder.cs
Normal file
49
Assets/Scripts/PathFinding/PathFinder.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HxGame.PathFinding
|
||||
{
|
||||
public struct PathFinderNode
|
||||
{
|
||||
public float F;
|
||||
public float G;
|
||||
public float H; // f = gone + heuristic
|
||||
public int X;
|
||||
public int Y;
|
||||
public int PX; // Parent
|
||||
public int PY;
|
||||
}
|
||||
|
||||
public enum PathFinderNodeType
|
||||
{
|
||||
Start = 1,
|
||||
End = 2,
|
||||
Open = 4,
|
||||
Close = 8,
|
||||
Current = 16,
|
||||
Path = 32
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>㷨
|
||||
public enum HeuristicFormula
|
||||
{
|
||||
Manhattan = 1,
|
||||
MaxDXDY = 2,
|
||||
DiagonalShortCut = 3,
|
||||
Euclidean = 4,
|
||||
EuclideanNoSQR = 5,
|
||||
Custom1 = 6
|
||||
}
|
||||
|
||||
internal class ComparePFNode : IComparer<PathFinderNode>
|
||||
{
|
||||
public int Compare(PathFinderNode x, PathFinderNode y)
|
||||
{
|
||||
if (x.F > y.F)
|
||||
return 1;
|
||||
else if (x.F < y.F)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user