-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNode.cs
54 lines (43 loc) · 1.16 KB
/
Node.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using UnityEngine;
using System.Collections;
using System;
namespace NPathfinding {
public class Node : IHeapItem<Node> {
//Node params
public bool walkable;
//Pathfinding Stuff
public int gCost;
public int hCost;
public int gridX;
public int gridY;
public Node parent;
private int heapIndex;
public Node(bool _walkable) {
this.walkable = _walkable;
}
public void SetPos(int x, int y) {
this.gridX = x;
this.gridY = y;
}
public int fCost {
get {
return gCost + hCost;
}
}
public int HeapIndex {
get {
return heapIndex;
}
set {
heapIndex = value;
}
}
public int CompareTo(Node nodeToCompare) {
int compare = fCost.CompareTo(nodeToCompare.fCost);
if (compare == 0) {
compare = hCost.CompareTo(nodeToCompare.hCost);
}
return -compare;
}
}
}