Beispiel #1
0
 public VoxelVisualComponent GetComponent(GroundQuad quad, bool onTopHalf)
 {
     if (onTopHalf)
     {
         return(topComponents[quad]);
     }
     return(bottomComponents[quad]);
 }
Beispiel #2
0
    public VoxelVisualComponent(VoxelCell coreCell, GroundQuad quad, bool onTopHalf)
    {
        Core      = coreCell;
        Quad      = quad;
        OnTopHalf = onTopHalf;
        VoxelCell bottomCell = onTopHalf ? coreCell : (coreCell.CellBelow ?? coreCell);
        VoxelCell topCell    = onTopHalf ? (coreCell.CellAbove ?? coreCell) : coreCell;

        bottomLayer     = new VoxelVisualsLayer(bottomCell, quad);
        topLayer        = new VoxelVisualsLayer(topCell, quad);
        ContentPosition = coreCell.CellPosition + (onTopHalf ? new Vector3(0, .5f, 0) : Vector3.zero);
    }
Beispiel #3
0
        public VoxelVisualsLayer(VoxelCell basisCell, GroundQuad basisQuad)
        {
            BasisCell = basisCell;
            BasisQuad = basisQuad;
            Center    = new Vector3(basisQuad.Center.x, basisCell.Height, basisQuad.Center.y);

            GroundPoint diagonalPoint = basisQuad.GetDiagonalPoint(basisCell.GroundPoint);

            DiagonalCell = diagonalPoint.Voxels[basisCell.Height];

            GroundPoint[] otherPoints = basisQuad.Points.Where(item => item != basisCell.GroundPoint && item != diagonalPoint).ToArray();
            AdjacentCellA = otherPoints[0].Voxels[basisCell.Height];
            AdjacentCellB = otherPoints[1].Voxels[basisCell.Height];
        }
Beispiel #4
0
    private VoxelVisualComponent GetHorizontalNeighbor(GroundPoint parallelPoint, GroundPoint perpendicularPoint)
    {
        GroundPoint basePoint    = Core.GroundPoint;
        GroundEdge  dividingEdge = Quad.GetEdge(basePoint, perpendicularPoint);

        if (dividingEdge.IsBorder)
        {
            return(null);
        }
        GroundQuad  neighborQuad     = dividingEdge.Quads.First(quad => quad != Quad);
        GroundPoint neighborDiagonal = neighborQuad.GetDiagonalPoint(basePoint);
        GroundPoint moneyPoint       = neighborQuad.Points.First(point => point != perpendicularPoint && point != neighborDiagonal);

        return(moneyPoint.Voxels[Core.Height].Visuals.GetComponent(neighborQuad, OnTopHalf));
    }