public void CheckNeighborPaths(int recursion) { bool hasValidPath = false; for (int i = 0; i < PathDirs.Length; i++) { if (PathCode.HasByte(PathDirs[i])) { if (m_PathRenderers[i]) { bool valid = grid.CheckNeighborPaths(coords, i); m_PathRenderers[i].material.color = valid ? grid.ValidPathColor : m_Visited ? grid.InvalidPathVistedColor : m_Goal ? grid.InvalidPathGoalColor : grid.InvalidPathColor; if (valid) { hasValidPath = true; HexPathTile nbor = grid.GetNeighbor(coords, i); if (nbor && recursion > 0) { nbor.CheckNeighborPaths(recursion - 1); } } } } else { HexPathTile nbor = grid.GetNeighbor(coords, i); if (nbor && recursion > 0) { nbor.CheckNeighborPaths(recursion - 1); } } } m_PathHubRenderer.material.color = hasValidPath ? grid.ValidPathColor : m_Visited ? grid.InvalidPathVistedColor : m_Goal ? grid.InvalidPathGoalColor : grid.InvalidPathColor; }
private void MoveInDirection(int direction) { if (m_Moving) { return; } HexPathTile nbor = m_Grid.GetNeighbor(m_Coords, direction); if (nbor && nbor.PathCode.HasByte(HexPathTile.PathDirs[(int)Mathf.Repeat(direction + 3, 6)])) { StartCoroutine(MoveTo(nbor.transform.position, direction)); } }