NodeMap for A* improvement

This commit is contained in:
Jakub Sztuba 2023-01-13 14:11:17 +01:00
parent f4c3020cfb
commit 6877176a0a

View File

@ -12,11 +12,12 @@ public class NodeMap : MonoBehaviour
public float cellSize; public float cellSize;
public TileData[] TileDatas; public TileData[] TileDatas;
public Dictionary<TileBase, TileData> DataFromTiles = new Dictionary<TileBase, TileData>(); public Dictionary<TileBase, TileData> DataFromTiles = new Dictionary<TileBase, TileData>();
public bool hasEverRun = false;
public Tilemap tilemap; public Tilemap tilemap;
// Start is called before the first frame update // Start is called before the first frame update
void Start() void LateUpdate()
{ {
if (!hasEverRun){
DataFromTiles = new Dictionary<TileBase, TileData>(); DataFromTiles = new Dictionary<TileBase, TileData>();
foreach (var tileData in TileDatas) foreach (var tileData in TileDatas)
{ {
@ -26,11 +27,15 @@ public class NodeMap : MonoBehaviour
} }
} }
hasEverRun = true;
CreateNodes(); CreateNodes();
TileCheck(); TileCheck();
} }
}
public void TileCheck() public void TileCheck()
{ {
foreach (var n in nodeGrid) foreach (var n in nodeGrid)