diff --git a/Episode 03 - astar/Assets/Scripts/Grid.cs b/Episode 03 - astar/Assets/Scripts/Grid.cs index 289b162..d57ebdc 100644 --- a/Episode 03 - astar/Assets/Scripts/Grid.cs +++ b/Episode 03 - astar/Assets/Scripts/Grid.cs @@ -8,6 +8,7 @@ public class Grid : MonoBehaviour { public Vector2 gridWorldSize; public float nodeRadius; Node[,] grid; + List neighbours = new List(); float nodeDiameter; int gridSizeX, gridSizeY; @@ -33,7 +34,7 @@ void CreateGrid() { } public List GetNeighbours(Node node) { - List neighbours = new List(); + neighbours.Clear(); for (int x = -1; x <= 1; x++) { for (int y = -1; y <= 1; y++) { diff --git a/Episode 04 - heap/Assets/Scripts/Grid.cs b/Episode 04 - heap/Assets/Scripts/Grid.cs index 315c645..4d4361a 100644 --- a/Episode 04 - heap/Assets/Scripts/Grid.cs +++ b/Episode 04 - heap/Assets/Scripts/Grid.cs @@ -9,6 +9,7 @@ public class Grid : MonoBehaviour { public Vector2 gridWorldSize; public float nodeRadius; Node[,] grid; + List neighbours = new List(); float nodeDiameter; int gridSizeX, gridSizeY; @@ -40,7 +41,7 @@ void CreateGrid() { } public List GetNeighbours(Node node) { - List neighbours = new List(); + neighbours.Clear(); for (int x = -1; x <= 1; x++) { for (int y = -1; y <= 1; y++) { diff --git a/Episode 05 - units/Assets/Scripts/Grid.cs b/Episode 05 - units/Assets/Scripts/Grid.cs index 37de93a..b11c11c 100644 --- a/Episode 05 - units/Assets/Scripts/Grid.cs +++ b/Episode 05 - units/Assets/Scripts/Grid.cs @@ -9,6 +9,7 @@ public class Grid : MonoBehaviour { public Vector2 gridWorldSize; public float nodeRadius; Node[,] grid; + List neighbours = new List(); float nodeDiameter; int gridSizeX, gridSizeY; @@ -40,7 +41,7 @@ void CreateGrid() { } public List GetNeighbours(Node node) { - List neighbours = new List(); + neighbours.Clear(); for (int x = -1; x <= 1; x++) { for (int y = -1; y <= 1; y++) { diff --git a/Episode 10 - threading/Assets/Scripts/Grid.cs b/Episode 10 - threading/Assets/Scripts/Grid.cs index f1a5033..551c3c1 100644 --- a/Episode 10 - threading/Assets/Scripts/Grid.cs +++ b/Episode 10 - threading/Assets/Scripts/Grid.cs @@ -12,6 +12,7 @@ public class Grid : MonoBehaviour { public int obstacleProximityPenalty = 10; Dictionary walkableRegionsDictionary = new Dictionary(); LayerMask walkableMask; + List neighbours = new List(); Node[,] grid; @@ -121,7 +122,7 @@ void BlurPenaltyMap(int blurSize) { } public List GetNeighbours(Node node) { - List neighbours = new List(); + neighbours.Clear(); for (int x = -1; x <= 1; x++) { for (int y = -1; y <= 1; y++) { diff --git a/Episode 10 - threading/Assets/Scripts/PathRequestManager.cs b/Episode 10 - threading/Assets/Scripts/PathRequestManager.cs index ae41d49..95a45a6 100644 --- a/Episode 10 - threading/Assets/Scripts/PathRequestManager.cs +++ b/Episode 10 - threading/Assets/Scripts/PathRequestManager.cs @@ -32,7 +32,7 @@ public static void RequestPath(PathRequest request) { ThreadStart threadStart = delegate { instance.pathfinding.FindPath (request, instance.FinishedProcessingPath); }; - threadStart.Invoke (); + new Thread(threadStart).Start(); } public void FinishedProcessingPath(PathResult result) { diff --git a/Episode 6 - weights/Assets/Scripts/Grid.cs b/Episode 6 - weights/Assets/Scripts/Grid.cs index 554ab13..158cc03 100644 --- a/Episode 6 - weights/Assets/Scripts/Grid.cs +++ b/Episode 6 - weights/Assets/Scripts/Grid.cs @@ -11,6 +11,7 @@ public class Grid : MonoBehaviour { public TerrainType[] walkableRegions; Dictionary walkableRegionsDictionary = new Dictionary(); LayerMask walkableMask; + List neighbours = new List(); Node[,] grid; @@ -61,7 +62,7 @@ void CreateGrid() { } public List GetNeighbours(Node node) { - List neighbours = new List(); + neighbours.Clear(); for (int x = -1; x <= 1; x++) { for (int y = -1; y <= 1; y++) { diff --git a/Episode 7 - smooth weights/Assets/Scripts/Grid.cs b/Episode 7 - smooth weights/Assets/Scripts/Grid.cs index f1a5033..551c3c1 100644 --- a/Episode 7 - smooth weights/Assets/Scripts/Grid.cs +++ b/Episode 7 - smooth weights/Assets/Scripts/Grid.cs @@ -12,6 +12,7 @@ public class Grid : MonoBehaviour { public int obstacleProximityPenalty = 10; Dictionary walkableRegionsDictionary = new Dictionary(); LayerMask walkableMask; + List neighbours = new List(); Node[,] grid; @@ -121,7 +122,7 @@ void BlurPenaltyMap(int blurSize) { } public List GetNeighbours(Node node) { - List neighbours = new List(); + neighbours.Clear(); for (int x = -1; x <= 1; x++) { for (int y = -1; y <= 1; y++) { diff --git a/Episode 8 - smooth path/Assets/Scripts/Grid.cs b/Episode 8 - smooth path/Assets/Scripts/Grid.cs index f1a5033..551c3c1 100644 --- a/Episode 8 - smooth path/Assets/Scripts/Grid.cs +++ b/Episode 8 - smooth path/Assets/Scripts/Grid.cs @@ -12,6 +12,7 @@ public class Grid : MonoBehaviour { public int obstacleProximityPenalty = 10; Dictionary walkableRegionsDictionary = new Dictionary(); LayerMask walkableMask; + List neighbours = new List(); Node[,] grid; @@ -121,7 +122,7 @@ void BlurPenaltyMap(int blurSize) { } public List GetNeighbours(Node node) { - List neighbours = new List(); + neighbours.Clear(); for (int x = -1; x <= 1; x++) { for (int y = -1; y <= 1; y++) { diff --git a/Episode 9 - smooth path 02/Assets/Scripts/Grid.cs b/Episode 9 - smooth path 02/Assets/Scripts/Grid.cs index f1a5033..551c3c1 100644 --- a/Episode 9 - smooth path 02/Assets/Scripts/Grid.cs +++ b/Episode 9 - smooth path 02/Assets/Scripts/Grid.cs @@ -12,6 +12,7 @@ public class Grid : MonoBehaviour { public int obstacleProximityPenalty = 10; Dictionary walkableRegionsDictionary = new Dictionary(); LayerMask walkableMask; + List neighbours = new List(); Node[,] grid; @@ -121,7 +122,7 @@ void BlurPenaltyMap(int blurSize) { } public List GetNeighbours(Node node) { - List neighbours = new List(); + neighbours.Clear(); for (int x = -1; x <= 1; x++) { for (int y = -1; y <= 1; y++) {