private void OnMouseClicked(Vector2 mousePos) { tilemap.SetEnemiesInfluence(); Vector2Int adjustedMousePos = tilemap.FromWorldToGrid(mousePos); if (adjustedMousePos.x >= tilemap.tiles.GetLength(0) || adjustedMousePos.x < 0) { return; } if (adjustedMousePos.y >= tilemap.tiles.GetLength(1) || adjustedMousePos.y < 0) { return; } if (selectedPosition == adjustedMousePos) { MovePlayer(); movementIsBlocked = true; return; } if (adjustedMousePos != tilemap.FromWorldToGrid(playerMovement.transform.position)) { if (!tilemap.tiles[adjustedMousePos.x, adjustedMousePos.y].CanBePathEnd()) { return; } selectedPosition = adjustedMousePos; CreatePath(adjustedMousePos); } }
private void SavePathNodes(Tile[,] tiles) { PathNode newNode; foreach (Tile tile in tiles) { newNode = new PathNode(manager.FromWorldToGrid(tile.transform.position), tile.IsWalkable()); allPathNodes[newNode.x, newNode.y] = newNode; } }