public Node(bool _walkable, PathFinding.Int2 _worldPos, int _gridX, int _gridY) { walkable = _walkable; worldPosition = _worldPos; gridX = _gridX; gridY = _gridY; }
public static float CalculateNoiseValue(PathFinding.Int2 pos, Vector2 offset, float scale) { float noiseX = Mathf.Abs((pos.x + offset.x) * scale); float noiseY = Mathf.Abs((pos.y + offset.y) * scale); //return Mathf.Max( 0, Noise.Generate( noiseX, noiseY ) ); return(Mathf.Max(0, Mathf.PerlinNoise(noiseX, noiseY))); //Just remember we can change this to 1d noise later! }
public PathFinding.Int2 GetTileInt2(Vector3 position) { GridLayout gridLayout = levels[currentLevel - 1].GetComponent <GridLayout>(); Vector3Int cellPosition = gridLayout.WorldToCell(position); Debug.Log(string.Format("Cell Position {0}", cellPosition)); PathFinding.Int2 pos = new PathFinding.Int2(cellPosition.x, cellPosition.y); return(pos); }
public void GenerateNodes(Vector3Int size) { for (int x = 0; x <= size.x; x++) { for (int y = 0; y <= size.y; y++) { Debug.Log(string.Format("X {0} Y {1}", x, y)); //grid[x, y] = new Node(walkable, worldPoint, x, y, _reachableIndex); var _worldPos = new PathFinding.Int2(x, y); grid[x, y] = new Node(true, _worldPos, x, y); } } }
//void Start( ) { // float _timer = .5f; // InvokeRepeating( "TryProcessNext", _timer, _timer ); //} public static void RequestPath(PathFinding.Int2 pathStart, PathFinding.Int2 pathEnd, Action <PathFinding.Int2[], bool> callback, bool walkableOverride) { if (pathStart != pathEnd) { Debug.Log(string.Format("Path Requested: Start {0} End {1}", pathStart, pathEnd)); PathRequest newRequest = new PathRequest(pathStart, pathEnd, callback); instance.pathRequestQueue.Enqueue(newRequest); instance.TryProcessNext(walkableOverride); } else { Debug.Log("You can not request a path for the same hex as you are in"); } }
public void TrackPlayer() { //Start = Enemy Position //End = Players Position var posTile = gamemanager.instance.GetTile(transform.position); PathFinding.Int2 start = new PathFinding.Int2(posTile.x, posTile.y); var enPos = gamemanager.instance.GetTile(gamemanager.instance.player.transform.position); PathFinding.Int2 end = new PathFinding.Int2(enPos.x, enPos.y); bool overrideWalkable = false; PathRequestManager.RequestPath(start, end, OnPathFound, overrideWalkable); }
public PathRequest(PathFinding.Int2 _start, PathFinding.Int2 _end, Action <PathFinding.Int2[], bool> _callback) { pathStart = _start; pathEnd = _end; callback = _callback; }
public Node NodeFromWorldPoint(PathFinding.Int2 worldPosition) { //return GameData.grid[worldPosition.x, worldPosition.y]; return(new Node()); //THIS IS NOT RIGHT JUST PLACEHOLDER }