public Vector2Int[] Diagonals(Vector3Int CubePos) { Vector2Int[] Diagonal = { HaxCoordAlgorithms.CubeToOddr(new Vector3Int(CubePos.x + 1, CubePos.y - 2, CubePos.z + 1)), HaxCoordAlgorithms.CubeToOddr(new Vector3Int(CubePos.x - 1, CubePos.y - 1, CubePos.z + 2)), HaxCoordAlgorithms.CubeToOddr(new Vector3Int(CubePos.x - 2, CubePos.y + 1, CubePos.z + 1)), HaxCoordAlgorithms.CubeToOddr(new Vector3Int(CubePos.x - 1, CubePos.y + 2, CubePos.z - 1)), HaxCoordAlgorithms.CubeToOddr(new Vector3Int(CubePos.x + 1, CubePos.y + 1, CubePos.z - 2)), HaxCoordAlgorithms.CubeToOddr(new Vector3Int(CubePos.x + 2, CubePos.y - 1, CubePos.z - 1)) }; return(Diagonal); }
public Vector2Int[] GetNeighborsOffset(Vector3Int CubePos) { Vector2Int[] neighborsPositions = { HaxCoordAlgorithms.CubeToOddr(new Vector3Int(CubePos.x + 1, CubePos.y - 1, CubePos.z)), HaxCoordAlgorithms.CubeToOddr(new Vector3Int(CubePos.x, CubePos.y - 1, CubePos.z + 1)), HaxCoordAlgorithms.CubeToOddr(new Vector3Int(CubePos.x - 1, CubePos.y, CubePos.z + 1)), HaxCoordAlgorithms.CubeToOddr(new Vector3Int(CubePos.x - 1, CubePos.y + 1, CubePos.z)), HaxCoordAlgorithms.CubeToOddr(new Vector3Int(CubePos.x, CubePos.y + 1, CubePos.z - 1)), HaxCoordAlgorithms.CubeToOddr(new Vector3Int(CubePos.x + 1, CubePos.y, CubePos.z - 1)) }; return(neighborsPositions); }
public Vector2Int[] CubeLineDraw(Vector3 a, Vector3 b) { float N = GetDistanceCube(a, b); List <Vector3Int> Pre = new List <Vector3Int>(); Vector2Int[] result = new Vector2Int[(int)N]; for (int i = 0; i < N; i++) { Pre.Add(CubeRound(CubeLerp(a, b, 1.0f / N * i))); result[i] = HaxCoordAlgorithms.CubeToOddr(new Vector3Int(Pre[i].x, Pre[i].y, Pre[i].z)); } return(result); }
public List <HaxNode> GetNeighborsHax(HaxNode haxnode) { Vector2Int[] neighborsPositions = { HaxCoordAlgorithms.CubeToOddr(new Vector3Int(haxnode.HaxCoordinate.CubeCoordinate.x + 1, haxnode.HaxCoordinate.CubeCoordinate.y - 1, haxnode.HaxCoordinate.CubeCoordinate.z)), HaxCoordAlgorithms.CubeToOddr(new Vector3Int(haxnode.HaxCoordinate.CubeCoordinate.x, haxnode.HaxCoordinate.CubeCoordinate.y - 1, haxnode.HaxCoordinate.CubeCoordinate.z + 1)), HaxCoordAlgorithms.CubeToOddr(new Vector3Int(haxnode.HaxCoordinate.CubeCoordinate.x - 1, haxnode.HaxCoordinate.CubeCoordinate.y, haxnode.HaxCoordinate.CubeCoordinate.z + 1)), HaxCoordAlgorithms.CubeToOddr(new Vector3Int(haxnode.HaxCoordinate.CubeCoordinate.x - 1, haxnode.HaxCoordinate.CubeCoordinate.y + 1, haxnode.HaxCoordinate.CubeCoordinate.z)), HaxCoordAlgorithms.CubeToOddr(new Vector3Int(haxnode.HaxCoordinate.CubeCoordinate.x, haxnode.HaxCoordinate.CubeCoordinate.y + 1, haxnode.HaxCoordinate.CubeCoordinate.z - 1)), HaxCoordAlgorithms.CubeToOddr(new Vector3Int(haxnode.HaxCoordinate.CubeCoordinate.x + 1, haxnode.HaxCoordinate.CubeCoordinate.y, haxnode.HaxCoordinate.CubeCoordinate.z - 1)) }; List <HaxNode> neighbors = new List <HaxNode>(); for (int i = 0; i < neighborsPositions.Length; i++) { if (IsIndexValid(m_Nodes, neighborsPositions[i].x, neighborsPositions[i].y)) { neighbors.Add(m_Nodes[neighborsPositions[i].x, neighborsPositions[i].y]); } } return(neighbors); }