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,25 +12,30 @@ public class NodeMap : MonoBehaviour
public float cellSize;
public TileData[] TileDatas;
public Dictionary<TileBase, TileData> DataFromTiles = new Dictionary<TileBase, TileData>();
public bool hasEverRun = false;
public Tilemap tilemap;
// Start is called before the first frame update
void Start()
void LateUpdate()
{
DataFromTiles = new Dictionary<TileBase, TileData>();
foreach (var tileData in TileDatas)
{
foreach (var tile in tileData.Tiles)
if (!hasEverRun){
DataFromTiles = new Dictionary<TileBase, TileData>();
foreach (var tileData in TileDatas)
{
DataFromTiles.Add(tile, tileData);
foreach (var tile in tileData.Tiles)
{
DataFromTiles.Add(tile, tileData);
}
}
hasEverRun = true;
CreateNodes();
TileCheck();
}
CreateNodes();
TileCheck();
}
public void TileCheck()
{
foreach (var n in nodeGrid)