예제 #1
0
    private static Vector3 GetPointerPos(Vector3 pointer, BlockSelectingType type = BlockSelectingType.ThisBlock) // Возвращает позицию блока в чанке
    {
        var heading   = pointer - Camera.main.transform.position;
        var distance  = heading.magnitude;
        var direction = heading / distance;

        return(pointer - ((direction / 100) * (int)type));
    }
예제 #2
0
    public static void InstantiateBlockToChunk(BlockSelectingType typeOfInstance, byte instantiateBlockId, ref Vector3 globalPointer, ref VoxelMapGenerator _VMG)
    {
        globalPointer = GetPointerPos(globalPointer, typeOfInstance);
        ArrayDimensions pointerInChunckMap = GetCorrectBlockPos(globalPointer);
        Point           chunkIndex         = GetChunkIndexFromPointer(globalPointer, pointerInChunckMap);
        Chunk           selectedChunk      = _VMG.worldResources.WorldMap[chunkIndex.Y, chunkIndex.X];

        selectedChunk.ChunkMap[pointerInChunckMap.Y, pointerInChunckMap.Z, pointerInChunckMap.X] = instantiateBlockId;
        selectedChunk.UpdateChunk();
        TryToUpdateNeighborChuncks(pointerInChunckMap, chunkIndex, ref _VMG);
    }
예제 #3
0
 public void ChangeDeformMode()
 {
     DeformMode = (DeformMode == BlockSelectingType.ThisBlock) ? BlockSelectingType.OutOfThisBlock : BlockSelectingType.ThisBlock;
 }