public StepNode(Tile _tile, Tile _target, DistMethod method = DistMethod.GRID) { DrawLines += DrawLine; DestroyLines += DestroyLine; tile = _tile; if (method == DistMethod.GRID) { //Full Grid 450 float xDiff = Mathf.Abs(_tile.X - _target.X); int yDiff = Mathf.Abs(_tile.Y - _target.Y); float straight = Mathf.Abs(xDiff - yDiff); float diag = Mathf.Max(xDiff, yDiff) - straight; crowDist = straight + diag * 1.414f; } if (method == DistMethod.MANHATTEN) { // Manhatten - 800 crowDist = Math.Abs(_tile.X - _target.X) + Math.Abs(_tile.Y - _target.Y); } if (method == DistMethod.VECTOR_3) { //Naive - Unrelated - 1200 crowDist = Vector3.Distance(_tile.transform.position, _target.transform.position); } DrawLine(); }
void Start() { currentMethod = distanceMethod; Pathfind(); startingObj.SetPathfinder(Pathfind); targetObj.SetPathfinder(Pathfind); }
void Update() { if (isPathfinding) { PathfindLoop(); } if (currentMethod != distanceMethod) { currentMethod = distanceMethod; Pathfind(); } }