mirror of
				https://github.com/DerTyp7/grow-ai-unity.git
				synced 2025-10-30 12:57:09 +01:00 
			
		
		
		
	added pathfinding
This commit is contained in:
		
							
								
								
									
										49
									
								
								Assets/Scripts/Pathfinding/PathNode.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								Assets/Scripts/Pathfinding/PathNode.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,49 @@ | ||||
| /*  | ||||
|     ------------------- Code Monkey ------------------- | ||||
|  | ||||
|     Thank you for downloading this package | ||||
|     I hope you find it useful in your projects | ||||
|     If you have any questions let me know | ||||
|     Cheers! | ||||
|  | ||||
|                unitycodemonkey.com | ||||
|     -------------------------------------------------- | ||||
|  */ | ||||
|  | ||||
| using System.Collections; | ||||
| using System.Collections.Generic; | ||||
| using UnityEngine; | ||||
|  | ||||
| public class PathNode { | ||||
|  | ||||
|     private Grid<PathNode> grid; | ||||
|     public int x; | ||||
|     public int y; | ||||
|  | ||||
|     public int gCost; | ||||
|     public int hCost; | ||||
|     public int fCost; | ||||
|  | ||||
|     public bool isWalkable; | ||||
|     public PathNode cameFromNode; | ||||
|  | ||||
|     public PathNode(Grid<PathNode> grid, int x, int y) { | ||||
|         this.grid = grid; | ||||
|         this.x = x; | ||||
|         this.y = y; | ||||
|         isWalkable = false; | ||||
|     } | ||||
|  | ||||
|     public void CalculateFCost() { | ||||
|         fCost = gCost + hCost; | ||||
|     } | ||||
|  | ||||
|     public void SetIsWalkable(bool isWalkable) { | ||||
|         this.isWalkable = isWalkable; | ||||
|     } | ||||
|  | ||||
|     public override string ToString() { | ||||
|         return x + "," + y; | ||||
|     } | ||||
|  | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 Janis M
					Janis M