Last active
November 15, 2020 01:19
-
-
Save Xevion/80cf4f09eef1239f27a9eeb9c776c207 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Node { | |
public Node Parent; | |
public Vector2Int Position; | |
// A* Algorithm variables | |
public float DistanceToTarget; | |
public float Cost; | |
public float Weight; | |
public float F { | |
get { | |
if (DistanceToTarget != -1 && Cost != -1) | |
return DistanceToTarget + Cost; | |
return -1; | |
} | |
} | |
public bool Walkable; | |
public Node(Vector2Int pos, bool walkable, float weight = 1) { | |
Parent = null; | |
Position = pos; | |
DistanceToTarget = -1; | |
Cost = 1; | |
Weight = weight; | |
Walkable = walkable; | |
} | |
public override string ToString() { | |
return $"Node({Position.x}, {Position.y}, {Walkable})"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment